本文整理汇总了Java中android.support.v7.app.AppCompatDelegate.MODE_NIGHT_NO属性的典型用法代码示例。如果您正苦于以下问题:Java AppCompatDelegate.MODE_NIGHT_NO属性的具体用法?Java AppCompatDelegate.MODE_NIGHT_NO怎么用?Java AppCompatDelegate.MODE_NIGHT_NO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.support.v7.app.AppCompatDelegate
的用法示例。
在下文中一共展示了AppCompatDelegate.MODE_NIGHT_NO属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPrepareOptionsMenu
@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;
}
示例2: onClick
@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;
}
}
示例3: onClick
@Override
public void onClick(View view) {
int mode = getDelegate().getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES
? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES;
switch (view.getId()) {
case R.id.btn_toggle_global_night_mode:
toggleNightModeForAllActivities(mode);
break;
case R.id.btn_toggle_local_night_mode:
toggleLocalNightMode(mode);
break;
}
}
示例4: applyDayNight
private void applyDayNight( boolean isNightMode )
{
int mode = isNightMode ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO;
AppCompatDelegate.setDefaultNightMode( mode );
}
示例5: updateValues
private void updateValues() {
int dayNightPreference = settings.getInt("prefDayNight", AppCompatDelegate.MODE_NIGHT_AUTO);
switch(dayNightPreference) {
case AppCompatDelegate.MODE_NIGHT_NO:
dayNight.setIcon(R.drawable.ic_brightness_day);
dayNight.setValue(R.string.settings_general_daynight_day);
break;
case AppCompatDelegate.MODE_NIGHT_YES:
dayNight.setIcon(R.drawable.ic_brightness_night);
dayNight.setValue(R.string.settings_general_daynight_night);
break;
case AppCompatDelegate.MODE_NIGHT_AUTO:
default:
dayNight.setIcon(R.drawable.ic_brightness_auto);
dayNight.setValue(R.string.settings_general_daynight_auto);
break;
}
dayNightLocation.setVisibility((dayNightPreference == AppCompatDelegate.MODE_NIGHT_AUTO && getContext() != null
&& ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
? View.VISIBLE : View.GONE);
String locationPreference = settings.getString("prefDefaultCinema", "");
String locationPrefText = "";
if(locationPreference.equals("")) {
locationPrefText = getString(R.string.settings_general_location_default);
} else {
locationPrefText = locationPreference;
if(cinemas != null) {
for(Cinema cinema : cinemas) {
if(cinema.getID().equals(locationPreference)) {
locationPrefText = cinema.getName();
}
}
}
}
location.setValue(locationPrefText);
if(settings.getLong("cinemasUpdated", -1) != -1) {
DateFormat format = SimpleDateFormat.getDateInstance(DateFormat.LONG);
service.setValue(getString(R.string.settings_general_location_service_lastupdate, format.format(new Date(settings.getLong("cinemasUpdated", -1)))));
} else {
service.setValue(getString(R.string.settings_general_location_service_lastupdate, getString(R.string.settings_general_location_service_never)));
}
boolean granted = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
if(settings.getInt("prefAutocompleteLocation", -1) == 1 && !granted) {
settings.edit().putInt("prefAutocompleteLocation", 0).apply(); // Turn off, we won't get the location anyway
}
if(settings.getInt("prefAutomagicLocation", -1) == 1 && !granted) {
settings.edit().putInt("prefAutomagicLocation", 0).apply(); // Turn off, we won't get the location anyway
}
autocomplete.setChecked(settings.getInt("prefAutocompleteLocation", -1) == 1 && granted);
automagic.setChecked(settings.getInt("prefAutomagicLocation", -1) == 1 && granted);
int accounts = users.size();
if(accounts == 0) {
accountsRecycler.setVisibility(View.GONE);
} else {
accountsRecycler.setVisibility(View.VISIBLE);
users = DBHelper.getInstance(getContext()).getUsers();
adapter.swapItems(users);
}
}