本文整理了Java中androidx.appcompat.app.AppCompatDelegate.getDefaultNightMode()
方法的一些代码示例,展示了AppCompatDelegate.getDefaultNightMode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppCompatDelegate.getDefaultNightMode()
方法的具体详情如下:
包路径:androidx.appcompat.app.AppCompatDelegate
类名称:AppCompatDelegate
方法名:getDefaultNightMode
暂无
代码示例来源:origin: PureWriter/about-page
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_about, menu);
MenuItem dayNight = menu.findItem(R.id.menu_night_mode);
dayNight.setChecked(AppCompatDelegate.getDefaultNightMode() == MODE_NIGHT_YES);
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: MCMrARM/revolution-irc
@Override
protected void onCreate(Bundle savedInstanceState) {
ThemeManager helper = ThemeManager.getInstance(this);
helper.addThemeChangeListener(this);
mDarkMode = AppCompatDelegate.getDefaultNightMode();
super.onCreate(savedInstanceState);
}
代码示例来源:origin: MCMrARM/revolution-irc
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (AppCompatDelegate.getDefaultNightMode() == mDarkMode) {
if (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) {
newConfig.uiMode &= ~(Configuration.UI_MODE_NIGHT_MASK);
newConfig.uiMode |= Configuration.UI_MODE_NIGHT_YES;
getResources().updateConfiguration(newConfig, getResources().getDisplayMetrics());
}
}
ThemeManager helper = ThemeManager.getInstance(this);
helper.applyThemeToActivity(this);
super.onConfigurationChanged(newConfig);
}
代码示例来源:origin: y20k/transistor
public static void restoreSavedState(Context context) {
int savedNightModeState = loadNightModeState(context);
int currentNightModeState = AppCompatDelegate.getDefaultNightMode();
if (savedNightModeState != currentNightModeState) {
switch (savedNightModeState) {
case AppCompatDelegate.MODE_NIGHT_NO:
// turn on day mode
activateDayMode(context, false);
break;
case AppCompatDelegate.MODE_NIGHT_YES:
// turn on night mode
activateNightMode(context, false);
break;
default:
// turn on mode "follow system"
activateFollowSystemMode(context, false);
break;
}
}
}
代码示例来源:origin: y20k/transistor
public static void switchMode(Activity activity) {
// SWITCH: undefined -> night / night -> day / day - undefined
switch (AppCompatDelegate.getDefaultNightMode()) {
case AppCompatDelegate.MODE_NIGHT_NO:
// currently: day mode -> switch to: follow system
displayDefaultStatusBar(activity); // necessary hack :-/
activateFollowSystemMode(activity, true);
break;
case AppCompatDelegate.MODE_NIGHT_YES:
// currently: night mode -> switch to: day mode
displayLightStatusBar(activity); // necessary hack :-/
activateDayMode(activity, true);
break;
default:
// currently: follow system / undefined -> switch to: day mode
displayLightStatusBar(activity); // necessary hack :-/
activateNightMode(activity, true);
break;
}
}
内容来源于网络,如有侵权,请联系作者删除!