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
Box(modifier = Modifier.fillMaxSize()) { | |
var count by remember { mutableIntStateOf(0) } | |
StateDependentComposable(count) | |
Button( | |
onClick = { count++ }, | |
content = { Text("Increment") }, | |
modifier = Modifier.align(Alignment.Center) | |
) | |
} |
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
@Composable | |
fun LogsCausingRecompositions() { | |
Box(modifier = Modifier.fillMaxSize()) { | |
var count by remember { mutableIntStateOf(0) } | |
Log.d("MyTag:", "Count: $count") | |
Button( | |
onClick = { count++ }, | |
content = { Text("Increment") }, |
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
@Composable | |
fun Screen() { | |
LifecycleObserver { event -> | |
if (event == Lifecycle.Event.ON_RESUME) { | |
// doSomething() | |
} | |
} | |
} | |
/** Inspired by: https://medium.com/@mohammadjoumani/life-cycle-in-jetpack-compose-2e96136ab936 **/ |
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
// 1. Add following snippet in your build.gradle.kts(:app) | |
// Run this command in terminal -> ./gradlew copyDebugApkToDesktopWithTime | |
// Note: It will replace "/" in your branch name with "-" as "/" creates a directory. | |
// fix/bug becomes fix-bug. You can adjust it as per your needs. | |
import java.text.SimpleDateFormat | |
import java.util.Date | |
tasks.register("copyDebugApkToDesktopWithTime") { |
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
// 1. Add following snippet in your build.gradle.kts(:app) | |
// Run this command in terminal -> ./gradlew copyDebugApkToDesktop | |
// Note: It will replace "/" in your branch name with "-" as "/" creates a directory. | |
// fix/bug becomes fix-bug. You can adjust it as per your needs. | |
tasks.register("copyDebugApkToDesktop") { | |
dependsOn("assembleDebug") | |
doLast { | |
val sourceDir = "build/outputs/apk/debug/app-debug.apk" |
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.content.Context | |
import android.content.Context.CONNECTIVITY_SERVICE | |
import android.net.ConnectivityManager | |
import android.net.Network | |
import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET | |
import android.net.NetworkRequest | |
import android.util.Log | |
import androidx.lifecycle.LiveData | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Dispatchers |