Skip to content

Instantly share code, notes, and snippets.

View Nimrodda's full-sized avatar

Nimrod Dayan Nimrodda

View GitHub Profile
private val globalId = AtomicInteger(1)
typealias OnGenreExpanded = (genre: Genre) -> Unit
data class Container(
val genres: List<GamesPerGenre>,
val onGenreExpanded: OnGenreExpanded
)
data class GamesPerGenre(
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable name="game" type="com.nimroddayan.epoxysample.Game"/>
</data>
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable name="genre" type="com.nimroddayan.epoxysample.Genre"/>
<variable name="onHeaderExpanded" type="android.view.View.OnClickListener"/>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
@Nimrodda
Nimrodda / glide_v3_to_v4_cheatsheet.md
Last active February 5, 2021 15:34
Glide migration from v3 to v4 cheatsheet

Glide v3 Migration to v4 Cheatsheet

Description V3 V4
Entry point - optional unless you have a custom GlideModule Glide GlideApp
Bitmap transformations bitmapTransform() transform()
Release bitmap Glide.clear() GlideApp.with(context).clear()
Custom animations animate(android.R.anim.fade_in) transition(GenericTransitionOptions.with(android.R.anim.fade_in))
Request builder DrawableRequestBuilder<CustomModel> RequestBuilder<Drawable>
Request builder DrawableRequestBuilder<String> RequestBuilder<Drawable>
class DetailActivity : DaggerAppCompatActivity() {
@Inject
lateinit var viewModelFactory: ViewModelFactory
private val viewModel by viewModels { viewModelFactory }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Use viewModel here
viewModel.loadData()
@Module
public abstract class DetailModule {
@Binds
@IntoMap
@ViewModelKey(DetailViewModel.class)
abstract ViewModelAssistedFactory<? extends ViewModel> bindFactory(DetailViewModel.Factory factory);
@Binds
abstract SavedStateRegistryOwner bindSavedStateRegistryOwner(DetailActivity detailActivity);
class ViewModelFactory @Inject constructor(
private val viewModelMap: MutableMap<Class<out ViewModel>, ViewModelAssistedFactory<out ViewModel>>,
owner: SavedStateRegistryOwner,
defaultArgs: Bundle?
) : AbstractSavedStateVMFactory(owner, defaultArgs) {
override fun <T : ViewModel?> create(
key: String,
modelClass: Class<T>,
handle: SavedStateHandle): T {
@Module
abstract class DetailModule {
@Binds
@IntoMap
@ViewModelKey(DetailViewModel::class)
abstract fun bindFactory(DetailViewModel viewModel): ViewModelAssistedFactory<out ViewModel>
}
@AssistedModule
@Module(includes = [AssistedInject_ViewModelAssistedFactoriesModule::class])
abstract class ViewModelAssistedFactoriesModule
@AssistedInject.Factory
interface Factory : ViewModelAssistedFactory<DetailViewModel>