當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。