This file contains 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 androidx.compose.animation.animate | |
import androidx.compose.animation.core.AnimationSpec | |
import androidx.compose.animation.core.TweenSpec | |
import androidx.compose.foundation.* | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.preferredSize | |
import androidx.compose.foundation.shape.RoundedCornerShape | |
import androidx.compose.material.Card | |
import androidx.compose.material.icons.Icons | |
import androidx.compose.material.icons.filled.Close |
This file contains 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
interface ConnectivityObserver { | |
fun start(onConnectionAvailable: () -> Unit, onConnectionLost: () -> Unit = {}) | |
fun stop() | |
} | |
This file contains 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 FilterAdapter @Inject constructor( | |
private val adapterDelegates: Map<Int, @JvmSuppressWildcards FilterAdapterDelegate> | |
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { | |
... | |
} |
This file contains 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
@Binds | |
@IntoMap | |
@FilterMapKey(RedFilterDelegate.RED_FILTER_VIEW_TYPE) | |
fun provideRedFilterDelegate(redFilterDelegate: RedFilterDelegate): FilterAdapterDelegate | |
@Binds | |
@IntoMap | |
@FilterMapKey(GreenFilterDelegate.GREEN_FILTER_VIEW_TYPE) | |
fun provideGreenFilterDelegate(greenFilterDelegate: GreenFilterDelegate): FilterAdapterDelegate |
This file contains 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
interface FilterAdapterDelegate { | |
val viewType: Int | |
fun isForViewType(filterData: FilterData): Boolean | |
fun onCreateViewHolder(parent: ViewGroup): RecyclerView.ViewHolder | |
fun onBindViewHolder(filterData: FilterData, holder: RecyclerView.ViewHolder) | |
} |
This file contains 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
public int getItemViewType(int position) { | |
return 0; | |
} |
This file contains 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
public abstract void onBindViewHolder(@NonNull VH holder, int position) | |
@NonNull | |
public abstract VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) | |
public abstract int getItemCount() |
This file contains 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
public interface Provider<T> { | |
T get(); | |
} |
This file contains 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
@Singleton | |
class ViewModelFactory @Inject constructor( | |
private val viewModelProviderMap: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>>) | |
: ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
val viewModelProvider = viewModelProviderMap.get(modelClass) | |
?: throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}") | |
return viewModelProvider.get() as T | |
} |
This file contains 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
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) | |
@MapKey | |
annotation class ViewModelKey(val value: KClass<out ViewModel>) |