本文整理汇总了Java中android.support.v7.app.AppCompatDelegate.setDefaultNightMode方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatDelegate.setDefaultNightMode方法的具体用法?Java AppCompatDelegate.setDefaultNightMode怎么用?Java AppCompatDelegate.setDefaultNightMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.AppCompatDelegate
的用法示例。
在下文中一共展示了AppCompatDelegate.setDefaultNightMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simulateDayNight
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
void simulateDayNight(int currentSetting) {
final int DAY = 0;
final int NIGHT = 1;
final int FOLLOW_SYSTEM = 3;
int currentNightMode = getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK;
if (currentSetting == DAY && currentNightMode != Configuration.UI_MODE_NIGHT_NO) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
} else if (currentSetting == NIGHT && currentNightMode != Configuration.UI_MODE_NIGHT_YES) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
} else if (currentSetting == FOLLOW_SYSTEM) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
}
示例2: changedMode
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
private void changedMode(boolean isNight, int position) {
SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, isNight);
AppCompatDelegate.setDefaultNightMode(isNight ? AppCompatDelegate.MODE_NIGHT_YES
: AppCompatDelegate.MODE_NIGHT_NO);
if (position >= 0) {
curTheme = position;
} else {
curTheme = SettingManager.getInstance().getReadTheme();
}
gvAdapter.select(curTheme);
mPageWidget.setTheme(isNight ? ThemeManager.NIGHT : curTheme);
mPageWidget.setTextColor(ContextCompat.getColor(mContext, isNight ? R.color.chapter_content_night : R.color.chapter_content_day),
ContextCompat.getColor(mContext, isNight ? R.color.chapter_title_night : R.color.chapter_title_day));
mTvBookReadMode.setText(getString(isNight ? R.string.book_read_mode_day_manual_setting
: R.string.book_read_mode_night_manual_setting));
Drawable drawable = ContextCompat.getDrawable(this, isNight ? R.drawable.ic_menu_mode_day_manual
: R.drawable.ic_menu_mode_night_manual);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
mTvBookReadMode.setCompoundDrawables(null, drawable, null, null);
ThemeManager.setReaderTheme(curTheme, mRlBookReadRoot);
}
示例3: onCreate
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
fragmentManager = getSupportFragmentManager();
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
int nightMode = sharedPreferences.getInt(getResources().getString(R.string.key_night_mode),
AppCompatDelegate.MODE_NIGHT_YES);
AppCompatDelegate.setDefaultNightMode(nightMode);
setTheme(R.style.AppTheme_NoActionBar);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (findViewById(R.id.main_fragment_container) != null) {
if (savedInstanceState != null) {
return;
}
SearchFragment searchFragment = new SearchFragment();
fragmentManager.beginTransaction()
.add(R.id.main_fragment_container, searchFragment)
.commit();
}
}
示例4: onCreate
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Utils.DARK_THEME = Prefs.getBoolean("darktheme", false, this);
int theme;
String accent = Prefs.getString("accent_color", "pink_accent", this);
if (Utils.DARK_THEME) {
theme = sAccentDarkColors.get(accent);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
theme = sAccentColors.get(accent);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
setTheme(theme);
super.onCreate(savedInstanceState);
if (Prefs.getBoolean("forceenglish", false, this)) {
Utils.setLocale("en_US", this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) {
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(statusBarColor());
}
}
示例5: setNightMode
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
public static void setNightMode(Context context, boolean mode) {
if (mode) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
SharedPreferences sharedPreferences = context.getSharedPreferences(Constant.THEME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("night", mode).commit();
}
示例6: onCreate
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@TimeLog
public void onCreate() {
super.onCreate();
mApp = this;
Realm.init(this);
SpUtil.init(this);
AppCompatDelegate.setDefaultNightMode(SpUtil.isNight() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
store = new Stack<>();
registerActivityLifecycleCallbacks(new SwitchBackgroundCallbacks());
}
示例7: useNightMode
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
public void useNightMode(boolean isNight) {
if (isNight) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
}
recreate();
}
示例8: onCreate
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// the 'theme' has two values, 0 and 1
// 0 --> day theme, 1 --> night theme
if (getSharedPreferences("user_settings",MODE_PRIVATE).getInt("theme", 0) == 0) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}
}
示例9: initTheme
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
private void initTheme(){
ThemeUtils.Theme theme = ThemeUtils.getCurrentTheme(this);
isNightTheme = PreferenceUtils.getPreferenceBoolean(this,PreferenceUtils.NIGHT_KEY,false);
ThemeUtils.changTheme(this, theme);
if (isNightTheme){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}else{
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}
示例10: onCreate
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
preferences = PreferenceManager.getDefaultSharedPreferences(context);
boolean isNightMode=preferences.getBoolean("pref_theme_dark",false);
if(isNightMode){
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
}
LitePal.initialize(context);
}
示例11: initNightMode
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
protected void initNightMode() {
boolean isNight = MyMusicUtil.getNightMode(context);
if (isNight) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}
示例12: onResume
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
protected void onResume() {
super.onResume();
if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false) != mNowMode) {
if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
recreate();
}
}
示例13: onCreate
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.s_splash);
boolean isFirstRun = (boolean) nico.SPUtils.get(this, "if_c_1", false);
if (isFirstRun) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
SharedPreferences setting = SplashActivity.this.getSharedPreferences("play_", 0);
Boolean user_first = setting.getBoolean("FIRST", true);
if (user_first) {
//MediaPlayer mPlayer = MediaPlayer.create(SplashActivity.this, R.raw.bio);
//mPlayer.start();
//Toast.makeText(SplashActivity.this, "夜间模式", Toast.LENGTH_SHORT).show();
setting.edit().putBoolean("FIRST", false).commit();
} else {
boolean sFirstRun = (boolean) nico.SPUtils.get(this, "if_styTool", false);
if (sFirstRun) {
MediaPlayer mPlayer = MediaPlayer.create(SplashActivity.this, R.raw.bio);
mPlayer.start();
} else {
}
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashActivity.this, nico.SimpleActivity.class);
startActivity(intent);
finish();
}
}, 1000L);
}
示例14: openNightMode
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
@Override
public void openNightMode(boolean isNight) {
if (isNight) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
}
recreate();
}
示例15: reload
import android.support.v7.app.AppCompatDelegate; //导入方法依赖的package包/类
public void reload() {
AppCompatDelegate.setDefaultNightMode(SpUtil.isNight() ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
recreate();
}