微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

项目:SuperToast    文件MainActivity.java   
private void initView() {
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
    bt1 = findViewById(R.id.main_button1);
    bt2 = findViewById(R.id.main_button2);
    bt3 = findViewById(R.id.main_button3);

    bt4 = findViewById(R.id.main_button4);
    bt5 = findViewById(R.id.main_button5);
    bt6 = findViewById(R.id.main_button6);

    bt7 = findViewById(R.id.main_button7);
    bt8 = findViewById(R.id.main_button8);
    bt9 = findViewById(R.id.main_button9);

    bt1.setonClickListener(this);
    bt2.setonClickListener(this);
    bt3.setonClickListener(this);

    bt4.setonClickListener(this);
    bt5.setonClickListener(this);
    bt6.setonClickListener(this);

    bt7.setonClickListener(this);
    bt8.setonClickListener(this);
    bt9.setonClickListener(this);
}
项目:GitHub    文件ReadActivity.java   
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,drawable.getMinimumWidth(),drawable.getMinimumHeight());
    mTvBookReadMode.setCompoundDrawables(null,drawable,null,null);

    ThemeManager.setReaderTheme(curTheme,mRlBookReadRoot);
}
项目:AURdroid    文件MainActivity.java   
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    /*
      app share and rate group
      hide on AurPackageDetailsFragment
     */
    MenuItem menuItem = menu.findItem(R.id.menu_main_app_group);
    Fragment fragmentByTag = fragmentManager.findFragmentByTag(AUR_PACKAGE_DETAILS_FRAGMENT_TAG);
    menuItem.setVisible(fragmentByTag == null);
    // night mode
    switch (AppCompatDelegate.getDefaultNightMode()) {
        case AppCompatDelegate.MODE_NIGHT_AUTO:
            menu.findItem(R.id.menu_main_action_night_mode_auto).setChecked(true);
            break;
        case AppCompatDelegate.MODE_NIGHT_YES:
            menu.findItem(R.id.menu_main_action_night_mode_night).setChecked(true);
            break;
        case AppCompatDelegate.MODE_NIGHT_NO:
            menu.findItem(R.id.menu_main_action_night_mode_day).setChecked(true);
            break;
    }
    return true;
}
项目:AURdroid    文件MainActivity.java   
@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();
    }
}
项目:ConnectU    文件ProfesoresActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
    setContentView(R.layout.activity_profesores);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setdisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getwindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
        getwindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
    }
    app = (App) this.getApplication();
    year = app.getPublicPreferenceI(Common.GLOBAL_FILTER_YEAR);

    recyclerView = (RecyclerView) findViewById(R.id.profesoresRecycler);
    emptyView = (LinearLayout) findViewById(R.id.profesores_blank);
    recyclerView.setHasFixedSize(true);
    mLayoutManager = new linearlayoutmanager(getBaseContext());
    recyclerView.setLayoutManager(mLayoutManager);

    setYearadapters();
    setSubjectsAdapter();
    updateYear(year);
}
项目:PNightMode    文件BaseAppCompatActivity.java   
@Override
public boolean onoptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_day:
            toggleNightModeForAllActivities(AppCompatDelegate.MODE_NIGHT_NO);
            return true;
        case R.id.action_night:
            toggleNightModeForAllActivities(AppCompatDelegate.MODE_NIGHT_YES);
            return true;
        case R.id.action_auto:
            toggleNightModeForAllActivities(AppCompatDelegate.MODE_NIGHT_AUTO);
            return true;
        default:
            return super.onoptionsItemSelected(item);
    }
}
项目:MaterialLearning    文件PrefFragment.java   
public boolean onPreferenceChange(Preference preference,Object newValue) {
switch (preference.getKey()){
    case "pref_user_name":
        userInFo.setTitle("尊敬的"+"“"+nickname+"”");
        userInFo.setSummary("欢迎使用本应用");
        break;

    case"pref_theme_dark":
        if((boolean)newValue) {
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        } else  {
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
        ActivityCollector.activities.get(0).recreate();//返回栈的首节点应该是主活动,让它重启
        getActivity().recreate();

        //Toast.makeText(getActivity(),"都说了功能还在开发中"+newValue,Toast.LENGTH_SHORT).show();
        break;
}

    return true;
}
项目:techstar-org    文件AboutUsActivity.java   
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);
    }
}
项目:Android-skin-support    文件App.java   
@Override
    public void onCreate() {
        super.onCreate();
//        SkinCircleImageViewManager.init(this);
//        SkinMaterialManager.init(this);
//        SkinConstraintManager.init(this);
//        SkinCardViewManager.init(this);
//        SkinFlycoTabLayoutManager.init(this);
//        SkinCompatManager.init(this).loadSkin();
//        SkinCompatManager.init(this)
        SkinCompatManager.withoutActivity(this)
                .addStrategy(new CustomSDCardLoader())          // 自定义加载策略,指定SDCard路径
                .addInflater(new SkinMaterialViewInflater())    // material design
                .addInflater(new SkinConstraintViewInflater())  // ConstraintLayout
                .addInflater(new SkinCardViewInflater())        // CardView v7
                .addInflater(new SkinCircleImageViewInflater()) // hdodenhof/CircleImageView
                .addInflater(new SkinFlycoTabLayoutInflater())  // H07000223/FlycoTabLayout
//                .setSkinStatusBarColorEnable(false)             // 关闭状态栏换肤
//                .setSkinWindowBackgroundEnable(false)           // 关闭windowBackground换肤
//                .setSkinAllActivityEnable(false)                // true: 认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤
                .loadSkin();
        AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
    }
项目:youth-health    文件AboutUsActivity.java   
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);
    }
}
项目:KernelAdiutor-Mod    文件BaseActivity.java   
@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",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());
    }
}
项目:Movie-Notifier-Android    文件MovieNotifierApp.java   
@Override
public void onCreate() {
    super.onCreate();
    StethoUtil.install(this);

    AppCompatDelegate.setDefaultNightMode(getSharedPreferences("settings",MODE_PRIVATE).getInt("prefDayNight",AppCompatDelegate.MODE_NIGHT_AUTO));

    FontRequest fontRequest = new FontRequest(
            "com.google.android.gms.fonts","com.google.android.gms","Noto Color Emoji Compat",R.array.com_google_android_gms_fonts_certs);
    EmojiCompat.Config config = new FontRequestemojiCompatConfig(this,fontRequest);
    EmojiCompat.init(config);

    setupCinemaListUpdates();
}
项目:MTweaks-KernelAdiutorMOD    文件BaseActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
    Utils.DARK_THEME = Prefs.getBoolean("darktheme",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());
    }
}
项目:techstar-shop    文件ActivitySplashScreen.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_screen);

    prefManager = new PrefManager(this);

    AppCompatimageView en = (AppCompatimageView)findViewById(R.id.langEn);
    AppCompatimageView mn = (AppCompatimageView)findViewById(R.id.langMn);
    AppCompatimageView cn = (AppCompatimageView)findViewById(R.id.langCn);
    AppCompatimageView ru = (AppCompatimageView)findViewById(R.id.langru);

    mn.setonClickListener(this);
    en.setonClickListener(this);
    cn.setonClickListener(this);
    ru.setonClickListener(this);
}
项目:Movie-Notifier-Android    文件MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);

    dayNightPreference = getSharedPreferences("settings",AppCompatDelegate.MODE_NIGHT_AUTO);

    if(savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.frame,new WatchersFragment(),"watchersFragment").commit();
    }

    settings = getSharedPreferences("settings",MODE_PRIVATE);
}
项目:javaide    文件JavaApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    systemOut = new InterceptorOutputStream(System.out,out);
    systemErr = new InterceptorOutputStream(System.err,err);
    System.setout(systemOut);
    System.setErr(systemErr);

    //for log cat
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
}
项目:Android-skin-support    文件SkinCompatResources.java   
private Drawable getSkinDrawableCompat(Context context,int resId) {
    if (AppCompatDelegate.isCompatVectorFromresourcesEnabled()) {
        if (!isDefaultSkin) {
            try {
                return SkinCompatDrawableManager.get().getDrawable(context,resId);
            } catch (Exception e) {
                e.printstacktrace();
            }
        }
        return AppCompatResources.getDrawable(context,resId);
    } else {
        return getSkinDrawable(context,resId);
    }
}
项目:ZhidaoDaily-android    文件MainActivity.java   
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
    super.onActivityResult(requestCode,resultCode,data);
    if (requestCode == REQUEST_CODE_SETTING
            && resultCode == SettingActivity.CODE_CHANGE_SKIN) {
        getDelegate().setLocalNightMode(AppUtils.getInstance().getThemeConfig(this)
                ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
        recreate();
    }
}
项目:Movie-Notifier-Android    文件MainActivity.java   
@Override
protected void onResume() {
    super.onResume();
    if(settings.getInt("prefDayNight",AppCompatDelegate.MODE_NIGHT_AUTO) != dayNightPreference) {
        recreate();
    }
}
项目:GitHub    文件BaseActivity.java   
@Override
public void useNightMode(boolean isNight) {
    if (isNight) {
        AppCompatDelegate.setDefaultNightMode(
                AppCompatDelegate.MODE_NIGHT_YES);
    } else {
        AppCompatDelegate.setDefaultNightMode(
                AppCompatDelegate.MODE_NIGHT_NO);
    }
    recreate();
}
项目:GitHub    文件App.java   
@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);
    }
}
项目:GitHub    文件BaseActivity.java   
@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();
    }
}
项目:AC2RD    文件Filters.java   
@Override
     public void onCreate(Bundle savedInstanceState)
     {
        localizerManager.setPreferencesLocale(getApplicationContext());
themeManager.setPreferencesTheme(getApplicationContext(),this);

delegate = AppCompatDelegate.create(this,this);
delegate.installViewFactory();

        super.onCreate(savedInstanceState);

        delegate.onCreate(savedInstanceState);

      delegate.setContentView(R.layout.filters);

      Toolbar toolbar = (Toolbar)findViewById(R.id.filters_toolbar);
      delegate.setSupportActionBar(toolbar);
      delegate.getSupportActionBar().setlogo(R.drawable.ic_menu_friendslist);
      delegate.setTitle(getApplicationContext().getString(R.string.filters_toolbar));
      delegate.getSupportActionBar().setdisplayHomeAsUpEnabled(true);
      delegate.getSupportActionBar().setdisplayShowHomeEnabled(true);

      orderBy = CONTACT_FILTER.DEFAULT_SORT_ORDER;
      cursor = databaseManager.queryAllFilter(getApplicationContext(),cursor,orderBy);

      setCursorAdapter();

      listView.setonItemClickListener(this);
listView.setonItemLongClickListener(this);
      listView.setEmptyView(findViewById(R.id.filters_empty));

      Button addRecordableContact = (Button) findViewById (R.id.filters_add_recordable_contact);
      Button addNotRecordableContact = (Button) findViewById (R.id.filters_add_not_recordable_contact);

      addRecordableContact.setonClickListener(this);
      addNotRecordableContact.setonClickListener(this);

      recordableContact = 0;
      displayContacts = 2;
     }
项目:Kids-Portal-Android    文件Activity_settings_app.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

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

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

    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,R.xml.user_settings_app,R.xml.user_settings_close,R.xml.user_settings_start,R.xml.user_settings_search_main,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();
}
项目:ConnectU    文件ExpedienteActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
    setContentView(R.layout.activity_expediente);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setdisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getwindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
        getwindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
    }
}
项目:ConnectU    文件ProfilePreference.java   
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
    App app = (App) getContext().getApplicationContext();
    TextView user = (TextView) holder.findViewById(R.id.user_Name);
    ImageView picture = (ImageView) holder.findViewById(R.id.user_Profile);
    String name = app.account.getName();
    if (name == null) {
        name = "User";
    }
    user.setText(name);
    Picasso.with(getContext()).load(app.account.getPictureURL()).placeholder(R.drawable.ic_placeholder).into(picture);
}
项目:Kids-Portal-Android    文件Activity_settings_close.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    helper_main.setTheme(this);

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

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

    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);

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

    PreferenceManager.setDefaultValues(this,new SettingsFragment()).commit();
}
项目:android-customtabs    文件Application.java   
@Override
public void onCreate() {
    super.onCreate();

    // Support vector drawable support for pre-Lollipop devices
    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);

    // Preload custom tabs service for improved performance
    // This is optional but recommended
    registeractivityLifecycleCallbacks(new CustomTabsActivityLifecycleCallbacks());
}
项目:MaterialLearning    文件MyApplication.java   
@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);
}
项目:FriendBook    文件BaseActivity.java   
private void initTheme() {
    //设置该app的主题根据时间不同显示
    if (AppConfig.isNightMode()) {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
    } else {
        AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
    }

}
项目:TextReader    文件BaseActivity.java   
@Override
protected void onResume() {
    super.onResume();
    if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT,false)) {
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        } else {
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
        recreate();
    }
}
项目:stynico    文件SplashActivity.java   
@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);
}
项目:Kids-Portal-Android    文件Activity_settings.java   
@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,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();

}
项目:DuckDuckDefine-Android    文件DuckDuckDefineApplication.java   
@Override
public void onCreate() {
    super.onCreate();

    initialiseDependencyInjection();

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

    AppCompatDelegate.setCompatVectorFromresourcesEnabled(true);
}
项目:Kids-Portal-Android    文件Activity_settings_searchMain.java   
@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,new SettingsFragment()).commit();
}
项目:PNightMode    文件MainAppCompatActivity.java   
@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;
    }
}
项目:PNightMode    文件BaseAppCompatActivity.java   
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);
        }
    }
}
项目:Kids-Portal-Android    文件Activity_settings_data.java   
@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,new SettingsFragment()).commit();
}
项目:BilibiliClient    文件MainActivity.java   
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();
}
项目:AnotherRSS    文件MainActivity.java   
@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();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。