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 kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.IO | |
import kotlinx.coroutines.withContext | |
import kotlinx.serialization.decodeFromString | |
import kotlinx.serialization.json.Json | |
import kotlinx.serialization.encodeToString | |
import okio.Path | |
object DiskDataSource { |
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 <T> Flow<T>.throttleFirst( | |
delayMillis: Long, | |
dispatcher: CoroutineDispatcher = Dispatchers.IO, // Unbounded dispatcher by default | |
): Flow<T> { | |
val delayScope = CoroutineScope(SupervisorJob() + dispatcher) | |
var isOpen = true | |
return this | |
.transform { | |
if (isOpen) { |
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
/** | |
* Invokes the given [block] once. | |
* Doesn't invoke again after config changes (screen rotation) on Android. | |
* Helpful for screen appearance logging. | |
*/ | |
@Composable | |
fun doOnceSavable(block: () -> Unit) { | |
val done = rememberSaveable { mutableStateOf(false) } | |
LaunchedEffect(Unit) { | |
if (!done.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
tasks.withType<Test>().configureEach { | |
maxParallelForks = 3 | |
} | |
// Another File | |
object TestSharedObject { | |
@Volatile |
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 kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.SupervisorJob | |
import kotlinx.coroutines.flow.Flow | |
import kotlinx.coroutines.flow.FlowCollector | |
import kotlinx.coroutines.flow.MutableStateFlow | |
import kotlinx.coroutines.flow.SharingStarted | |
import kotlinx.coroutines.flow.shareIn | |
import kotlinx.coroutines.flow.update |
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
keytool -importkeystore | |
-srckeystore path\to\android\file.jks | |
-destkeystore path\to\keystore\file.keystore | |
-srcstorepass your_pass | |
-deststorepass your_pass | |
java -jar "path\to\Downloads\pepk.jar" | |
--keystore="path\to\keystore\file.keystore" | |
--alias=your_alias_here |
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 kotlinx.coroutines.CancellationException | |
import kotlinx.coroutines.delay | |
suspend fun <T> retrying( | |
timesMax: Int = 3, | |
delayMillis: (Int) -> Long = { (it + 1) * 1000L }, | |
needRetry: (Int, Throwable) -> Boolean = { _, _ -> true }, | |
block: suspend () -> T, | |
onResult: suspend (T) -> Unit, |
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.annotation.SuppressLint | |
import android.view.View | |
import android.widget.FrameLayout | |
import androidx.core.view.updateLayoutParams | |
import com.google.android.exoplayer2.TracksInfo | |
import com.google.android.exoplayer2.util.MimeTypes | |
import com.google.android.exoplayer2.video.VideoSize | |
import timber.log.Timber |
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.app.Activity | |
import android.content.Context | |
import android.os.Bundle | |
import android.os.Parcelable | |
import androidx.annotation.IdRes | |
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.lifecycleScope | |
import androidx.navigation.NavController | |
import androidx.navigation.NavOptions |
NewerOlder