本文整理匯總了Java中android.support.v7.app.AppCompatDelegate.MODE_NIGHT_YES屬性的典型用法代碼示例。如果您正苦於以下問題:Java AppCompatDelegate.MODE_NIGHT_YES屬性的具體用法?Java AppCompatDelegate.MODE_NIGHT_YES怎麽用?Java AppCompatDelegate.MODE_NIGHT_YES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.support.v7.app.AppCompatDelegate
的用法示例。
在下文中一共展示了AppCompatDelegate.MODE_NIGHT_YES屬性的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);
}
}