This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyUseCase @Inject constructor() { | |
private val getUserFlow: Flow<Int> = flowOf<Int>(1, 2, 3, 4) | |
private val getUserSessionFlow: Flow<Int> = flowOf<Int>(5, 6, 7, 8) | |
operator fun invoke(): Flow<Unit> { | |
return getUserFlow.zip(getUserSessionFlow) { user, session -> | |
// Do transformation here | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object RemoteConfigHelper { | |
private const val REMOTE_KEY_IN_APP_REVIEW_ENABLED = | |
BuildConfig.REMOTE_CONFIG_KEY_PREFIX + "in_app_review_enabled" | |
private const val REMOTE_KEY_APP_UPDATES = BuildConfig.REMOTE_CONFIG_KEY_PREFIX + "app_updates" | |
private const val REMOTE_KEY_WORDS_MANIFEST = BuildConfig.REMOTE_CONFIG_KEY_PREFIX + "words_manifest" | |
init { | |
val settings = remoteConfigSettings { | |
minimumFetchIntervalInSeconds = BuildConfig.REMOTE_CONFIG_MIN_FETCH_INTERVAL_SECONDS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CalendarController( | |
val listener: (CalendarEvent) -> Unit | |
) : TypedEpoxyController<CalendarState.Data>() { | |
override fun buildModels(data: CalendarState.Data) { | |
for (row in data.rows) { | |
calendarRow { | |
onDaySelectedListener { day -> this@CalendarController.listener(CalendarEvent.OnDaySelectedChanged(day)) } | |
onDayTouchedListener { day -> this@CalendarController.listener(CalendarEvent.OnDayTouchedChanged(day)) } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseAdapter<T : Any, VH : BaseItemViewHolder<T, out BaseItemViewModel<T>>>( | |
parentLifecycle: Lifecycle, | |
private val dataList: ArrayList<T> | |
) : RecyclerView.Adapter<VH>() { | |
private var recyclerView: RecyclerView? = null | |
init { | |
parentLifecycle.addObserver(object : LifecycleObserver { | |
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postCollection.aggregate<Post>( | |
lookup( | |
"user", | |
listOf(Post::likes.variableDefinition()), | |
User::userId | |
), | |
match( | |
expr( | |
MongoOperator.and from listOf( | |
MongoOperator.`in` from listOf(User::userId, Post::likes), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS") | |
class ImageCompressor(context: Context) { | |
companion object { | |
private const val maxWidth = 612 | |
private const val maxHeight = 816 | |
private val compressFormat = CompressFormat.JPEG | |
private const val quality = 50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.annotation.SuppressLint | |
import android.content.Context | |
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.graphics.Paint | |
import android.graphics.Path | |
import android.graphics.PointF | |
import android.util.AttributeSet | |
import android.util.Log | |
import android.view.View |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val compressedFile = ImageCompressor(requireContext()).compressToFile(----the file here----) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DetailBrowsePeopleAdapter : BaseRecyclerViewAdapter<DetailBrowsePeopleItem>(mutableListOf()) { | |
override fun registerItemClick(holder: BaseBindingViewHolder, viewType: Int, position: Int) { | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Himanshu Singh on 27-10-2020. | |
**/ | |
abstract class IBaseRecyclerViewAdapter<Item : IRecyclerItemViewModel?>(var items: MutableList<Item>) : RecyclerView.Adapter<BaseRecyclerViewAdapter.BaseBindingViewHolder>() { | |
private var position = 0 | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseBindingViewHolder { | |
// here the viewType is the actual layoutId to make it generic | |
val layoutInflater = LayoutInflater.from(parent.context) |
NewerOlder