mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-21 00:18:18 +00:00
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.GeodeLauncherTheme
|
||||||
import com.geode.launcher.ui.theme.Typography
|
import com.geode.launcher.ui.theme.Typography
|
||||||
import com.geode.launcher.utils.LaunchUtils
|
import com.geode.launcher.utils.LaunchUtils
|
||||||
import com.geode.launcher.utils.countdownTimerWatcher
|
import com.geode.launcher.utils.useCountdownTimer
|
||||||
import com.geode.launcher.utils.preferenceWatcher
|
import com.geode.launcher.utils.usePreference
|
||||||
|
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
@@ -61,7 +61,7 @@ fun onSettings(context: Context) {
|
|||||||
fun MainScreen(gdInstalled: Boolean = true) {
|
fun MainScreen(gdInstalled: Boolean = true) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
val shouldAutomaticallyLaunch = preferenceWatcher(
|
val shouldAutomaticallyLaunch = usePreference(
|
||||||
preferenceFileKey = R.string.preference_file_key,
|
preferenceFileKey = R.string.preference_file_key,
|
||||||
preferenceId = R.string.preference_load_automatically
|
preferenceId = R.string.preference_load_automatically
|
||||||
)
|
)
|
||||||
@@ -83,7 +83,7 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
|||||||
)
|
)
|
||||||
if (gdInstalled) {
|
if (gdInstalled) {
|
||||||
if (shouldAutomaticallyLaunch.value) {
|
if (shouldAutomaticallyLaunch.value) {
|
||||||
val countdownTimer = countdownTimerWatcher(
|
val countdownTimer = useCountdownTimer(
|
||||||
time = 3000,
|
time = 3000,
|
||||||
onCountdownFinish = {
|
onCountdownFinish = {
|
||||||
// just in case this changed async
|
// just in case this changed async
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import androidx.lifecycle.LifecycleOwner
|
|||||||
const val MS_TO_SEC = 1000
|
const val MS_TO_SEC = 1000
|
||||||
|
|
||||||
@Composable
|
@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 {
|
val timeData = remember {
|
||||||
mutableStateOf(time / MS_TO_SEC % MS_TO_SEC)
|
mutableStateOf(time / MS_TO_SEC % MS_TO_SEC)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -12,7 +12,7 @@ import androidx.lifecycle.LifecycleOwner
|
|||||||
|
|
||||||
|
|
||||||
@Composable
|
@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 context = LocalContext.current
|
||||||
val preferences = context.getSharedPreferences(
|
val preferences = context.getSharedPreferences(
|
||||||
context.getString(preferenceFileKey), Context.MODE_PRIVATE
|
context.getString(preferenceFileKey), Context.MODE_PRIVATE
|
||||||
Reference in new issue
Block a user