本文整理了Java中android.support.v7.app.AppCompatDelegate.getDefaultNightMode()
方法的一些代码示例,展示了AppCompatDelegate.getDefaultNightMode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppCompatDelegate.getDefaultNightMode()
方法的具体详情如下:
包路径:android.support.v7.app.AppCompatDelegate
类名称:AppCompatDelegate
方法名:getDefaultNightMode
暂无
代码示例来源:origin: chrisbanes/cheesesquare
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
switch (AppCompatDelegate.getDefaultNightMode()) {
case AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM:
menu.findItem(R.id.menu_night_mode_system).setChecked(true);
break;
case AppCompatDelegate.MODE_NIGHT_AUTO:
menu.findItem(R.id.menu_night_mode_auto).setChecked(true);
break;
case AppCompatDelegate.MODE_NIGHT_YES:
menu.findItem(R.id.menu_night_mode_night).setChecked(true);
break;
case AppCompatDelegate.MODE_NIGHT_NO:
menu.findItem(R.id.menu_night_mode_day).setChecked(true);
break;
}
return true;
}
代码示例来源:origin: 348476129/gank.io-with-MVVM
public boolean isDarkTheme() {
return AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES;
}
}
代码示例来源:origin: 348476129/gank.io-with-MVVM
public boolean isDarkTheme() {
return AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES;
}
}
代码示例来源:origin: google-developer-training/android-fundamentals
/**
* Creates the night mode menu option
* @param menu The menu in the action bar
* @return True to display the menu, false to hide it
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
//Inflate the menu from XML
getMenuInflater().inflate(R.menu.main_menu, menu);
//Change the label of the menu based on the state of the app
int nightMode = AppCompatDelegate.getDefaultNightMode();
if(nightMode == AppCompatDelegate.MODE_NIGHT_YES){
menu.findItem(R.id.night_mode).setTitle(R.string.day_mode);
} else{
menu.findItem(R.id.night_mode).setTitle(R.string.night_mode);
}
return true;
}
代码示例来源:origin: google-developer-training/android-fundamentals-apps-v2
/**
* Creates the night mode menu option.
*
* @param menu The menu in the action bar
* @return True to display the menu, false to hide it
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
// Change the label of the menu based on the state of the app.
int nightMode = AppCompatDelegate.getDefaultNightMode();
if(nightMode == AppCompatDelegate.MODE_NIGHT_YES){
menu.findItem(R.id.night_mode).setTitle(R.string.day_mode);
} else{
menu.findItem(R.id.night_mode).setTitle(R.string.night_mode);
}
return true;
}
代码示例来源:origin: google-developer-training/android-fundamentals
/**
* Method that handles menu item clicks
* @param item The item that was pressed
* @return returns true since the item click wa handled
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//Check if the correct item was clicked
if(item.getItemId()==R.id.night_mode){
//Get the night mode state of the app
int nightMode = AppCompatDelegate.getDefaultNightMode();
//Set the theme mode for the restarted activity
if(nightMode == AppCompatDelegate.MODE_NIGHT_YES) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}
//Recreate the activity for the theme change to take effect
recreate();
return true;
}
return super.onOptionsItemSelected(item);
}
代码示例来源:origin: google-developer-training/android-fundamentals-apps-v2
/**
* Handles options menu item clicks.
*
* @param item The item that was pressed
* @return returns true since the item click wa handled
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Check if the correct item was clicked.
if (item.getItemId() == R.id.night_mode) {
// Get the night mode state of the app.
int nightMode = AppCompatDelegate.getDefaultNightMode();
// Set the theme mode for the restarted activity.
if (nightMode == AppCompatDelegate.MODE_NIGHT_YES) {
AppCompatDelegate.setDefaultNightMode
(AppCompatDelegate.MODE_NIGHT_NO);
} else {
AppCompatDelegate.setDefaultNightMode
(AppCompatDelegate.MODE_NIGHT_YES);
}
// Recreate the activity for the theme change to take effect.
recreate();
}
return true;
}
代码示例来源:origin: zulip/zulip-android
narrowListener = (NarrowListener) context;
this.startedFromFilter = startedFromFilter;
isCurrentThemeNight = (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES);
mDefaultStreamHeaderColor = ContextCompat.getColor(context, R.color.stream_header);
privateMessageBackground = ContextCompat.getColor(context, R.color.private_background);
代码示例来源:origin: freedom10086/Ruisi
public void switchTheme() {
int cur = AppCompatDelegate.getDefaultNightMode();
int to = cur;
boolean autoChange = false;
代码示例来源:origin: zulip/zulip-android
item.setChecked(!item.isChecked());
if (item.isChecked() &&
AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_NO) {
setNightMode(AppCompatDelegate.MODE_NIGHT_NO);
app.makeNightThemeDefault(false);
item.setChecked(!item.isChecked());
if (item.isChecked() &&
AppCompatDelegate.getDefaultNightMode() != AppCompatDelegate.MODE_NIGHT_YES) {
setNightMode(AppCompatDelegate.MODE_NIGHT_YES);
app.makeNightThemeDefault(true);
代码示例来源:origin: freedom10086/Ruisi
addToolbarMenu(R.drawable.ic_done_black_24dp).setOnClickListener(v -> {
boolean isChange = false;
int curr = AppCompatDelegate.getDefaultNightMode();
int to = curr;
代码示例来源:origin: zulip/zulip-android
boolean isCurrentThemeNight = (AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES);
内容来源于网络,如有侵权,请联系作者删除!