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);
}
java类android.support.v7.app.AppCompatDelegate的实例源码
MainActivity.java 文件源码
项目:SuperToast
阅读 23
收藏 0
点赞 0
评论 0
ReadActivity.java 文件源码
项目:GitHub
阅读 30
收藏 0
点赞 0
评论 0
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);
}
MainActivity.java 文件源码
项目:AURdroid
阅读 22
收藏 0
点赞 0
评论 0
@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;
}
MainActivity.java 文件源码
项目:AURdroid
阅读 21
收藏 0
点赞 0
评论 0
@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();
}
}
ProfesoresActivity.java 文件源码
项目:ConnectU
阅读 25
收藏 0
点赞 0
评论 0
@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);
}
BaseAppCompatActivity.java 文件源码
项目:PNightMode
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
}
PrefFragment.java 文件源码
项目:MaterialLearning
阅读 35
收藏 0
点赞 0
评论 0
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;
}
AboutUsActivity.java 文件源码
项目:techstar-org
阅读 75
收藏 0
点赞 0
评论 0
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);
}
}
App.java 文件源码
项目:Android-skin-support
阅读 35
收藏 0
点赞 0
评论 0
@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);
}
AboutUsActivity.java 文件源码
项目:youth-health
阅读 36
收藏 0
点赞 0
评论 0
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);
}
}
BaseActivity.java 文件源码
项目:KernelAdiutor-Mod
阅读 37
收藏 0
点赞 0
评论 0
@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());
}
}
MovieNotifierApp.java 文件源码
项目:Movie-Notifier-Android
阅读 30
收藏 0
点赞 0
评论 0
@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();
}
BaseActivity.java 文件源码
项目:MTweaks-KernelAdiutorMOD
阅读 35
收藏 0
点赞 0
评论 0
@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());
}
}
ActivitySplashScreen.java 文件源码
项目:techstar-shop
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
MainActivity.java 文件源码
项目:Movie-Notifier-Android
阅读 26
收藏 0
点赞 0
评论 0
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
dayNightPreference = getSharedPreferences("settings", MODE_PRIVATE).getInt("prefDayNight", AppCompatDelegate.MODE_NIGHT_AUTO);
if(savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().add(R.id.frame, new WatchersFragment(), "watchersFragment").commit();
}
settings = getSharedPreferences("settings", MODE_PRIVATE);
}
JavaApplication.java 文件源码
项目:javaide
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
SkinCompatResources.java 文件源码
项目:Android-skin-support
阅读 33
收藏 0
点赞 0
评论 0
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);
}
}
MainActivity.java 文件源码
项目:ZhidaoDaily-android
阅读 18
收藏 0
点赞 0
评论 0
@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();
}
}
MainActivity.java 文件源码
项目:Movie-Notifier-Android
阅读 22
收藏 0
点赞 0
评论 0
@Override
protected void onResume() {
super.onResume();
if(settings.getInt("prefDayNight", AppCompatDelegate.MODE_NIGHT_AUTO) != dayNightPreference) {
recreate();
}
}
BaseActivity.java 文件源码
项目:GitHub
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void useNightMode(boolean isNight) {
if (isNight) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO);
}
recreate();
}
App.java 文件源码
项目:GitHub
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
}
BaseActivity.java 文件源码
项目:GitHub
阅读 26
收藏 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();
}
}
Filters.java 文件源码
项目:AC2RD
阅读 29
收藏 0
点赞 0
评论 0
@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;
}
Activity_settings_app.java 文件源码
项目:Kids-Portal-Android
阅读 21
收藏 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_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, 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();
}
ExpedienteActivity.java 文件源码
项目:ConnectU
阅读 21
收藏 0
点赞 0
评论 0
@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));
}
}
ProfilePreference.java 文件源码
项目:ConnectU
阅读 32
收藏 0
点赞 0
评论 0
@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);
}
Activity_settings_close.java 文件源码
项目:Kids-Portal-Android
阅读 25
收藏 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_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, 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();
}
Application.java 文件源码
项目:android-customtabs
阅读 28
收藏 0
点赞 0
评论 0
@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());
}
MyApplication.java 文件源码
项目:MaterialLearning
阅读 33
收藏 0
点赞 0
评论 0
@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);
}
BaseActivity.java 文件源码
项目:FriendBook
阅读 21
收藏 0
点赞 0
评论 0
private void initTheme() {
//设置该app的主题根据时间不同显示
if (AppConfig.isNightMode()) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}