Java Code Examples for android.support.v7.app.AppCompatDelegate.NightMode

The following are Jave code examples for showing how to use NightMode of the android.support.v7.app.AppCompatDelegate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: PNightMode   File: BaseAppCompatActivity.java   Source Code and License Vote up 5 votes
public void toggleNightModeForAllActivities(@AppCompatDelegate.NightMode int mode) {
    List<BaseAppCompatActivity> list = NightModeActivityManager.getInstance().getActivityList();
    if (list != null && list.size() > 0) {
        for (BaseAppCompatActivity activity : list) {
            activity.toggleGlobalNightMode(mode);
        }
    }
}
 
Example 2
Project: PNightMode   File: SharedPrefUtil.java   Source Code and License Vote up 4 votes
public void setNightMode(@AppCompatDelegate.NightMode int mode) {
    mPreferences.edit().putInt(KEY_PREF_NIGHT_MODE, mode).apply();
}
 
Example 3
Project: PNightMode   File: SharedPrefUtil.java   Source Code and License Vote up 4 votes
public @AppCompatDelegate.NightMode int getNightMode() {
    return mPreferences.getInt(KEY_PREF_NIGHT_MODE, AppCompatDelegate.MODE_NIGHT_NO);
}
 
Example 4
Project: PNightMode   File: BaseAppCompatActivity.java   Source Code and License Vote up 4 votes
protected void toggleGlobalNightMode(@AppCompatDelegate.NightMode int mode) {
    SharedPrefUtil.getInstance().setNightMode(mode);
    AppCompatDelegate.setDefaultNightMode(mode);
    recreate();
}
 
Example 5
Project: PNightMode   File: BaseAppCompatActivity.java   Source Code and License Vote up 4 votes
protected void toggleLocalNightMode(@AppCompatDelegate.NightMode int mode) {
    getDelegate().setLocalNightMode(mode);
    recreate();
}