fixed start issue

This commit is contained in:
gdlbo
2023-03-21 16:13:18 +03:00
parent d557abe6e9
commit 2d19254d51
2 changed files with 8 additions and 4 deletions
@@ -15,6 +15,10 @@ import static ru.vtosters.lite.utils.AndroidUtils.getCenterScreenCoords;
public class SystemThemeChangerHook {
public static void onThemeChanged(Configuration configuration) {
onThemeChanged(configuration, true);
}
public static void onThemeChanged(Configuration configuration, Boolean restartActivity) {
if (Preferences.systemtheme()) {
var uiMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK;
@@ -26,7 +30,7 @@ public class SystemThemeChangerHook {
theme = ThemesUtils.getLightTheme();
if (theme != null && theme != ThemesUtils.getCurrentTheme()) {
ThemesUtils.applyTheme(theme);
ThemesUtils.applyTheme(theme, restartActivity);
}
}
}
@@ -34,6 +38,6 @@ public class SystemThemeChangerHook {
public static void themeOnStart(Activity activity) {
if (activity == null) activity = LifecycleUtils.getCurrentActivity();
onThemeChanged(activity.getResources().getConfiguration());
onThemeChanged(activity.getResources().getConfiguration(), false);
}
}
@@ -40,9 +40,9 @@ import static ru.vtosters.lite.utils.AndroidUtils.*;
import static ru.vtosters.lite.utils.Preferences.*;
public class ThemesUtils {
public static void applyTheme(VKTheme theme) {
public static void applyTheme(VKTheme theme, Boolean restartActivity) {
try {
setTheme(theme, LifecycleUtils.getCurrentActivity(), true);
setTheme(theme, LifecycleUtils.getCurrentActivity(), restartActivity);
} catch (Exception e) {
e.printStackTrace();
}