forked from geode-sdk/android-launcher
rename lifecycle hooks
This commit is contained in:
3 files changed
+6
-6
No files matched your search
@@ -22,8 +22,8 @@ import androidx.compose.ui.unit.sp
|
||||
import com.geode.launcher.ui.theme.GeodeLauncherTheme
|
||||
import com.geode.launcher.ui.theme.Typography
|
||||
import com.geode.launcher.utils.LaunchUtils
|
||||
import com.geode.launcher.utils.countdownTimerWatcher
|
||||
import com.geode.launcher.utils.preferenceWatcher
|
||||
import com.geode.launcher.utils.useCountdownTimer
|
||||
import com.geode.launcher.utils.usePreference
|
||||
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
@@ -61,7 +61,7 @@ fun onSettings(context: Context) {
|
||||
fun MainScreen(gdInstalled: Boolean = true) {
|
||||
val context = LocalContext.current
|
||||
|
||||
val shouldAutomaticallyLaunch = preferenceWatcher(
|
||||
val shouldAutomaticallyLaunch = usePreference(
|
||||
preferenceFileKey = R.string.preference_file_key,
|
||||
preferenceId = R.string.preference_load_automatically
|
||||
)
|
||||
@@ -83,7 +83,7 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
||||
)
|
||||
if (gdInstalled) {
|
||||
if (shouldAutomaticallyLaunch.value) {
|
||||
val countdownTimer = countdownTimerWatcher(
|
||||
val countdownTimer = useCountdownTimer(
|
||||
time = 3000,
|
||||
onCountdownFinish = {
|
||||
// just in case this changed async
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import androidx.lifecycle.LifecycleOwner
|
||||
const val MS_TO_SEC = 1000
|
||||
|
||||
@Composable
|
||||
fun countdownTimerWatcher(lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, time: Int, onCountdownFinish: () -> Unit): MutableState<Int> {
|
||||
fun useCountdownTimer(lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current, time: Int, onCountdownFinish: () -> Unit): MutableState<Int> {
|
||||
val timeData = remember {
|
||||
mutableStateOf(time / MS_TO_SEC % MS_TO_SEC)
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ import androidx.lifecycle.LifecycleOwner
|
||||
|
||||
|
||||
@Composable
|
||||
fun preferenceWatcher(@StringRes preferenceFileKey: Int, @StringRes preferenceId: Int, lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current): MutableState<Boolean> {
|
||||
fun usePreference(@StringRes preferenceFileKey: Int, @StringRes preferenceId: Int, lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current): MutableState<Boolean> {
|
||||
val context = LocalContext.current
|
||||
val preferences = context.getSharedPreferences(
|
||||
context.getString(preferenceFileKey), Context.MODE_PRIVATE
|
||||
Reference in new issue
Block a user