本文整理匯總了Java中android.app.UiModeManager.MODE_NIGHT_YES屬性的典型用法代碼示例。如果您正苦於以下問題:Java UiModeManager.MODE_NIGHT_YES屬性的具體用法?Java UiModeManager.MODE_NIGHT_YES怎麽用?Java UiModeManager.MODE_NIGHT_YES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.app.UiModeManager
的用法示例。
在下文中一共展示了UiModeManager.MODE_NIGHT_YES屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mapNightModeToYesNo
@BinaryNightMode
private int mapNightModeToYesNo(@NightMode final int mode) {
switch (mode) {
case MODE_NIGHT_AUTO:
return getTwilightManager().isNight() ? MODE_NIGHT_YES : MODE_NIGHT_NO;
case MODE_NIGHT_FOLLOW_SYSTEM:
final UiModeManager uiModeManager = (UiModeManager)
mContext.getSystemService(Context.UI_MODE_SERVICE);
switch (uiModeManager.getNightMode()) {
case UiModeManager.MODE_NIGHT_YES:
return MODE_NIGHT_YES;
case UiModeManager.MODE_NIGHT_AUTO:
return MODE_NIGHT_AUTO;
case UiModeManager.MODE_NIGHT_NO:
default:
return MODE_NIGHT_NO;
}
case MODE_NIGHT_YES:
return MODE_NIGHT_YES;
case MODE_NIGHT_NO:
default:
return MODE_NIGHT_NO;
}
}
示例2: onResume
@Override
protected void onResume() {
Log.d(AnotherRSS.TAG, "onResume");
AnotherRSS.withGui = true;
new DbExpunge().execute();
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean night = mPreferences.getBoolean("nightmode_use", false);
if (night) {
int startH = mPreferences.getInt("nightmode_use_start", AnotherRSS.Config.DEFAULT_NIGHT_START);
int stopH = mPreferences.getInt("nightmode_use_stop", AnotherRSS.Config.DEFAULT_NIGHT_STOP);
if (AnotherRSS.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_YES) {
umm.setNightMode(UiModeManager.MODE_NIGHT_YES);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}
if (!AnotherRSS.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_NO) {
umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
} else {
if (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES) {
umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}
super.onResume();
}
示例3: onResume
@Override
protected void onResume() {
Log.d(ViboraApp.TAG, "onResume");
ViboraApp.withGui = true;
new DbExpunge().execute();
SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
boolean night = mPreferences.getBoolean("nightmode_use", false);
if (night) {
int startH = mPreferences.getInt("nightmode_use_start", ViboraApp.Config.DEFAULT_NIGHT_START);
int stopH = mPreferences.getInt("nightmode_use_stop", ViboraApp.Config.DEFAULT_NIGHT_STOP);
if (ViboraApp.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_YES) {
umm.setNightMode(UiModeManager.MODE_NIGHT_YES);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}
if (!ViboraApp.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_NO) {
umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
} else {
if (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES) {
umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}
super.onResume();
}