Java Code Examples for android.support.v7.app.AppCompatDelegate.setLocalNightMode()

The following are Jave code examples for showing how to use setLocalNightMode() 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: FriendBook   File: ReadActivity.java   Source Code and License Vote up 4 votes
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.read_tv_pre_chapter:
            getPresenter().prevSection();
            break;
        case R.id.read_tv_next_chapter:
            getPresenter().nextSection();
            break;
        case R.id.read_tv_category:
            readDrawer.openDrawer(readSide);
            break;
        case R.id.read_tv_night_mode:
            boolean nightModeSelected = !readTvNightMode.isSelected();
            toggleNightMode(nightModeSelected);
            ReaderSettingManager.getInstance().setNightMode(nightModeSelected);
            AppConfig.setNightMode(nightModeSelected);

            Object[] activityArray = AppManager.getInstance().getActivityArray();
            for (Object appCompatActivity : activityArray) {
                if (appCompatActivity != this) {
                    AppCompatDelegate delegate = ((AppCompatActivity) appCompatActivity).getDelegate();
                    if (nightModeSelected) {
                        delegate.setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);
                        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);

                    } else {
                        delegate.setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
                        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
                    }
                }
            }

            break;
        case R.id.read_tv_setting:
            toggleMenu(true);
            openReadSetting(this);
            break;

    }
}
 
Example 2
Project: easyfilemanager   File: Utils.java   Source Code and License Vote up 4 votes
public static void changeThemeStyle(AppCompatDelegate delegate) {
    int nightMode = Integer.valueOf(SettingsActivity.getThemeStyle());
    AppCompatDelegate.setDefaultNightMode(nightMode);
    delegate.setLocalNightMode(nightMode);
}
 
Example 3
Project: FireFiles   File: Utils.java   Source Code and License Vote up 4 votes
public static void changeThemeStyle(AppCompatDelegate delegate) {
    int nightMode = Integer.valueOf(SettingsActivity.getThemeStyle());
    AppCompatDelegate.setDefaultNightMode(nightMode);
    delegate.setLocalNightMode(nightMode);
}
 
Example 4
Project: simple-share-android   File: Utils.java   Source Code and License Vote up 4 votes
public static void changeThemeStyle(AppCompatDelegate delegate) {
    int nightMode = Integer.valueOf(SettingsActivity.getThemeStyle());
    AppCompatDelegate.setDefaultNightMode(nightMode);
    delegate.setLocalNightMode(nightMode);
}