java类android.support.v7.app.AppCompatDelegate的实例源码

BaseActivity.java 文件源码 项目:TextReader 阅读 21 收藏 0 点赞 0 评论 0
@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();
    }
}
SplashActivity.java 文件源码 项目:stynico 阅读 38 收藏 0 点赞 0 评论 0
@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);
}
Activity_settings.java 文件源码 项目:Kids-Portal-Android 阅读 15 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

    setContentView(R.layout.activity_settings);
    helper_main.onStart(Activity_settings.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.menu_settings);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_app, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_close, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_start, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search_main, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_data, false);
    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putString("started", "").apply();


    // Display the fragment as the activity_screen_main content
    getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();

}
DuckDuckDefineApplication.java 文件源码 项目:DuckDuckDefine-Android 阅读 17 收藏 0 点赞 0 评论 0
@Override
public void onCreate() {
    super.onCreate();

    initialiseDependencyInjection();

    if (BuildConfig.DEBUG) {
        initTimberDebugPlant();
    }

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
Activity_settings_searchMain.java 文件源码 项目:Kids-Portal-Android 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

    setContentView(R.layout.activity_settings);
    helper_main.onStart(Activity_settings_searchMain.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.pref_6);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_app, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_close, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_start, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search_main, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_data, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putString("started", "").apply();

    // Display the fragment as the activity_screen_main content
    getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
}
MainAppCompatActivity.java 文件源码 项目:PNightMode 阅读 18 收藏 0 点赞 0 评论 0
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.btn_second_activity:
            Intent intent = new Intent();
            intent.setClass(this, SecondAppCompatActivity.class);
            startActivity(intent);
            break;
        case R.id.btn_toggle_night_mode:
            int mode = AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES
                    ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES;
            toggleGlobalNightMode(mode);
            break;
    }
}
BaseAppCompatActivity.java 文件源码 项目:PNightMode 阅读 25 收藏 0 点赞 0 评论 0
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);
        }
    }
}
Activity_settings_data.java 文件源码 项目:Kids-Portal-Android 阅读 17 收藏 0 点赞 0 评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

    setContentView(R.layout.activity_settings);
    helper_main.onStart(Activity_settings_data.this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle(R.string.pref_4);

    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if(actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    PreferenceManager.setDefaultValues(this, R.xml.user_settings, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_app, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_close, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_start, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_search_main, false);
    PreferenceManager.setDefaultValues(this, R.xml.user_settings_data, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    sharedPref.edit().putString("started", "").apply();

    // Display the fragment as the activity_screen_main content
    getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
}
MainActivity.java 文件源码 项目:BilibiliClient 阅读 14 收藏 0 点赞 0 评论 0
private void switchNightMode() {
    boolean flag = PreferenceUtil.getBoolean(ConstantUtil.SWITCH_MODE_KEY, false);
    if (flag){
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        PreferenceUtil.putBoolean(ConstantUtil.SWITCH_MODE_KEY, false);
    } else {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        PreferenceUtil.putBoolean(ConstantUtil.SWITCH_MODE_KEY, true);
    }
    recreate();
}
MainActivity.java 文件源码 项目:AnotherRSS 阅读 15 收藏 0 点赞 0 评论 0
@Override
protected void onResume() {
    Log.d(AnotherRSS.TAG, "onResume");
    AnotherRSS.withGui = true;
    new DbExpunge().execute();

    SharedPreferences mPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    boolean night = mPreferences.getBoolean("nightmode_use", false);
    if (night) {
        int startH = mPreferences.getInt("nightmode_use_start", AnotherRSS.Config.DEFAULT_NIGHT_START);
        int stopH = mPreferences.getInt("nightmode_use_stop", AnotherRSS.Config.DEFAULT_NIGHT_STOP);
        if (AnotherRSS.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_YES) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_YES);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        }
        if (!AnotherRSS.inTimeSpan(startH, stopH) && umm.getNightMode() != UiModeManager.MODE_NIGHT_NO) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
    } else {
        if (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES) {
            umm.setNightMode(UiModeManager.MODE_NIGHT_NO);
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
    }
    super.onResume();
}


问题


面经


文章

微信
公众号

扫码关注公众号