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
/* | |
* Copyright © 2023 Alex Facciorusso | |
* | |
* Licensed under MIT The MIT License (MIT) | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | |
* documentation files (the “Software”), to deal in the Software without restriction, including without limitation the | |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
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
fun main() = application { | |
Window(onCloseRequest = ::exitApplication) { | |
LaunchedEffect(Unit) { | |
window.attachSkiaDebugger() | |
} | |
MaterialTheme { | |
Row( | |
verticalAlignment = Alignment.CenterVertically, | |
modifier = Modifier.background(Color.LightGray).height(IntrinsicSize.Min) | |
) { |
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
/** | |
* Delegates a field to an AtomicReference. | |
*/ | |
fun <T> atomicReference(): ReadWriteProperty<Any?, T?> = object : ReadWriteProperty<Any?, T?> { | |
private val atomic = AtomicReference<T>() | |
override operator fun getValue(thisRef: Any?, property: KProperty<*>): T? = atomic.get() | |
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) { | |
atomic.set(value) |
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 Cat { | |
val meow = "Meowww...? :3" | |
} | |
fun main(args: Array<String>) { | |
var aBoringClassInstance: Cat? = Cat() | |
aBoringClassInstance!! | |
val sureNull: Cat? = null | |
sureNull!! |
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 DaggerViewModelFactory | |
@Inject constructor( | |
private val creators: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>> | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
val creator = creators[modelClass] ?: | |
creators.asIterable().firstOrNull { modelClass.isAssignableFrom(it.key) }?.value | |
?: throw IllegalArgumentException("unknown model class " + modelClass) |
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 static class ExampleViewHolder extends RecyclerView.ViewHolder | |
implements View.OnClickListener { | |
private int originalHeight = 0; | |
private boolean isViewExpanded = false; | |
private YourCustomView yourCustomView | |
public ExampleViewHolder(View v) { | |
super(v); | |
v.setOnClickListener(this); |
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 retrofit.Call | |
import retrofit.Callback | |
import retrofit.Response | |
import retrofit.Retrofit | |
/** | |
* @author Alex Facciorusso | |
* @since 06/11/15 | |
*/ |
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 android.databinding.DataBindingUtil; | |
import android.databinding.ViewDataBinding; | |
import android.support.v7.app.AppCompatActivity; | |
import android.view.View; | |
import android.view.ViewGroup; | |
/** | |
* @author alexfacciorusso | |
* @since 11/08/15. | |
*/ |
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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.design.widget.CoordinatorLayout | |
android:id="@+id/main_content" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<android.support.design.widget.AppBarLayout |
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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.design.widget.CoordinatorLayout | |
android:id="@+id/main_content" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:fitsSystemWindows="true"> | |
NewerOlder