Skip to content

Instantly share code, notes, and snippets.

View meet30997's full-sized avatar

MEET PRAJAPATI meet30997

View GitHub Profile
@meet30997
meet30997 / db.txt
Last active September 24, 2022 08:19
algebra
group: Borrower Example
borrower = {customerName loanNumber
adams L16
curry L93
hayes L15
jackson L14
jones L17
smith L11
smith L23
williams L17
@meet30997
meet30997 / ScaleAnim.kt
Last active September 8, 2022 05:05
Scale Animation
fun View.scale(
alpha: Float = 0f,
scaleBy: Float = 1f,
duration: Long = 0L,
startingDelay: Long = 0
) {
animate().alpha(alpha).scaleX(scaleBy).scaleY(scaleBy)
.setStartDelay(startingDelay)
.setDuration(duration).start()
}
@meet30997
meet30997 / TranslateAnimX.kt
Created September 8, 2022 04:43
X-Axis Animation
fun View.translateXBy(
alpha: Float = 0f,
translateBy: Float = 50f,
duration: Long = 0L,
startingDelay: Long = 0
) {
animate().alpha(alpha).translationXBy(context.toPx(translateBy))
.setStartDelay(startingDelay)
.setDuration(duration).start()
}
@meet30997
meet30997 / TranslateAnimStart.kt
Created September 7, 2022 12:02
TranslateY Start Animation
val duration = 300L
val startDelay = 300L
// View1
binding.bannerPager.translateYBy(1f, -50, duration, startDelay)
// View2
binding.smallBannerPager.translateYBy(
1f,
-50,
duration,
startDelay + 150
@meet30997
meet30997 / TranslateOncreate.kt
Created September 7, 2022 11:56
Translate Views
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.bannerPager.translateYBy()
binding.smallBannerPager.translateYBy()
binding.subCategoryRv.translateYBy()
}
@meet30997
meet30997 / TranslateAnim.kt
Created September 7, 2022 11:50
Translate Anim
fun View.translateYBy(
alpha: Float = 0f,
translateBy: Float = 50f,
duration: Long = 0L,
startingDelay: Long = 0
) {
animate().alpha(alpha).translationYBy(context.toPx(translateBy))
.setStartDelay(startingDelay)
.setDuration(duration).start()
}
@meet30997
meet30997 / DataStoreMigrate.kt
Created September 6, 2022 06:00
Migrate Shared Preference To DataStore
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(
name = "MyDataStore",
produceMigrations = { context ->
listOf(
SharedPreferencesMigration(context, "MySharedPref")
)
})
@meet30997
meet30997 / SharedPref.kt
Created September 6, 2022 05:57
SharedPref
this.getSharedPreferences("MySharedPref", Context.MODE_PRIVATE).edit()
.putString("MySharedPrefUserName", "Meet").apply()
@meet30997
meet30997 / DataStoreClear.kt
Created September 6, 2022 05:22
Clear Data Store
suspend fun clearDatStore() {
dataStore.edit { myDataStore ->
myDataStore.clear()
}
}
@meet30997
meet30997 / DataStoreSync.kt
Last active September 6, 2022 04:56
Synchronous DataStore
// Using runBlocking
// It blocks the UI Thread
val userName = runBlocking {
dataStore.data.first()[DataStoreManager.userNameKey]
}
binding.userName.text = userName
// Using UI thread safe lifecycleScope
lifecycleScope.launch {
val userName = dataStoreManager.dataStore.data.first()[DataStoreManager.userNameKey]