当前位置: 首页>>代码示例>>Java>>正文


Java AppCompatDelegate.setDefaultNightMode方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:prshntpnwr,项目名称:Monolith,代码行数:19,代码来源:AboutActivity.java

示例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);
}
 
开发者ID:ynztlxdeai,项目名称:TextReader,代码行数:26,代码来源:ReadActivity.java

示例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();
    }
}
 
开发者ID:rascarlo,项目名称:AURdroid,代码行数:23,代码来源:MainActivity.java

示例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());
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:27,代码来源:BaseActivity.java

示例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();
}
 
开发者ID:lijunyandev,项目名称:MeetMusic,代码行数:11,代码来源:MyMusicUtil.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:App.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:BaseActivity.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:App.java

示例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);
    }
}
 
开发者ID:lueans,项目名称:LueansRead,代码行数:11,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:MoonRiser,项目名称:MaterialLearning,代码行数:13,代码来源:MyApplication.java

示例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);
    }
}
 
开发者ID:lijunyandev,项目名称:MeetMusic,代码行数:9,代码来源:MyApplication.java

示例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();
    }
}
 
开发者ID:zwmlibs,项目名称:BookReader-master,代码行数:13,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:37,代码来源:SplashActivity.java

示例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();
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:12,代码来源:BaseActivity.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:DataBindingActivity.java


注:本文中的android.support.v7.app.AppCompatDelegate.setDefaultNightMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。