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
<ScrollView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layoutAnimation="@anim/layout_animation" | |
android:orientation="vertical"> | |
</ScrollView> |
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
inline fun <reified T> SharedPreferences.observeKey(key: String, default: T): Flow<T> = channelFlow { | |
send(getItem(key, default)) | |
val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, k -> | |
if (key == k) { | |
trySend(getItem(key, default)) | |
} | |
} | |
registerOnSharedPreferenceChangeListener(listener) |
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.security.keystore.KeyGenParameterSpec | |
import android.security.keystore.KeyProperties | |
import java.security.* | |
import javax.crypto.* | |
import javax.crypto.spec.GCMParameterSpec | |
import android.util.Base64 | |
import androidx.annotation.VisibleForTesting | |
class EncryptionAES { |
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 ViewModelFactory constructor( | |
private val baseRepository: BaseRepository, // your repository class to handle database, network, shared preferences, etc. | |
owner: SavedStateRegistryOwner, | |
defaultArgs: Bundle? = null | |
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) { | |
// usage in activity: | |
// val sharedVM by viewModels<MySharedViewModel> { ViewModelFactory(App.getRep(), this) } | |
// App.getRep() returns instance of BaseRepository, replace with your actual logic | |
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 LifecycleRecyclerView @JvmOverloads constructor( | |
context: Context, | |
attrs: AttributeSet? = null, | |
defStyleAttr: Int = 0 | |
) : RecyclerView(context, attrs, defStyleAttr), LifecycleObserver { | |
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) | |
private fun onDestroy() { | |
adapter = null | |
} |
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 CountryFlags { | |
private val A = getEmojiByUnicode(0x1F1E6) | |
private val B = getEmojiByUnicode(0x1F1E7) | |
private val C = getEmojiByUnicode(0x1F1E8) | |
private val D = getEmojiByUnicode(0x1F1E9) | |
private val E = getEmojiByUnicode(0x1F1EA) | |
private val F = getEmojiByUnicode(0x1F1EB) | |
private val G = getEmojiByUnicode(0x1F1EC) | |
private val H = getEmojiByUnicode(0x1F1ED) | |
private val I = getEmojiByUnicode(0x1F1EE) |
OlderNewer