use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.
the class ElevationDateBottomSheet method createReliefFactorButtons.
private void createReliefFactorButtons(Context context) {
for (int i = 0; i < parameters.size(); i++) {
RoutingParameter parameter = parameters.get(i);
final BottomSheetItemWithCompoundButton[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
preferenceItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setChecked(i == selectedEntryIndex).setButtonTintList(createColorStateList(context, nightMode)).setTitle(getRoutingParameterTitle(app, parameter)).setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left).setTag(i).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedEntryIndex = (int) preferenceItem[0].getTag();
if (selectedEntryIndex >= 0) {
RoutingParameter parameter = parameters.get(selectedEntryIndex);
updateSelectedParameters(app, appMode, parameters, parameter.getId());
}
Fragment target = getTargetFragment();
if (target instanceof BaseSettingsFragment) {
((BaseSettingsFragment) target).updateSetting(useHeightPref.getId());
}
if (target instanceof RouteOptionsBottomSheet) {
((RouteOptionsBottomSheet) target).updateMenuItems();
}
updateReliefButtons();
app.runInUIThread(new Runnable() {
@Override
public void run() {
dismiss();
}
}, 500);
}
}).create();
items.add(preferenceItem[0]);
reliefFactorButtons.add(preferenceItem[0]);
}
}
use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.
the class ElevationDateBottomSheet method createUseHeightButton.
private void createUseHeightButton(Context context) {
boolean checked = useHeightPref.getModeValue(appMode);
useHeightButton = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder().setCompoundButtonColor(appModeColor).setChecked(checked).setTitle(checked ? on : off).setTitleColorId(checked ? activeColor : disabledColor).setCustomView(getCustomButtonView(app, appMode, checked, nightMode)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean newValue = !useHeightPref.getModeValue(appMode);
Fragment target = getTargetFragment();
if (target instanceof OnConfirmPreferenceChange) {
OnConfirmPreferenceChange confirmInterface = (OnConfirmPreferenceChange) target;
if (confirmInterface.onConfirmPreferenceChange(useHeightPref.getId(), newValue, ApplyQueryType.NONE)) {
updateUseHeightButton(useHeightButton, newValue);
if (target instanceof BaseSettingsFragment) {
((BaseSettingsFragment) target).updateSetting(useHeightPref.getId());
}
}
} else {
useHeightPref.setModeValue(appMode, newValue);
updateUseHeightButton(useHeightButton, newValue);
}
}
}).create();
items.add(useHeightButton);
}
use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.
the class SelectFolderBottomSheet method onRightBottomButtonClick.
@Override
protected void onRightBottomButtonClick() {
Fragment fragment = getTargetFragment();
if (fragment instanceof BaseSettingsFragment) {
String newPath = editText.getText().toString().trim();
if (!newPath.isEmpty()) {
boolean pathChanged = !newPath.equals(currentPath);
Bundle bundle = new Bundle();
bundle.putBoolean(TAG, true);
bundle.putString(NEW_PATH, newPath);
bundle.putBoolean(PATH_CHANGED, pathChanged);
((BaseSettingsFragment) fragment).onPreferenceChange(getPreference(), bundle);
}
}
dismiss();
}
use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.
the class MapActivity method onPreferenceStartFragment.
@Override
public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
try {
FragmentManager manager = getSupportFragmentManager();
String fragmentName = pref.getFragment();
Fragment fragment = manager.getFragmentFactory().instantiate(this.getClassLoader(), fragmentName);
if (caller instanceof BaseSettingsFragment) {
fragment.setArguments(((BaseSettingsFragment) caller).buildArguments());
}
String tag = fragment.getClass().getName();
if (AndroidUtils.isFragmentCanBeAdded(manager, tag)) {
manager.beginTransaction().replace(R.id.fragmentContainer, fragment, tag).addToBackStack(DRAWER_SETTINGS_ID).commitAllowingStateLoss();
return true;
}
} catch (Exception e) {
LOG.error(e);
}
return false;
}
use of net.osmand.plus.settings.fragments.BaseSettingsFragment in project Osmand by osmandapp.
the class AllocatedRoutingMemoryBottomSheet method onRightBottomButtonClick.
@Override
protected void onRightBottomButtonClick() {
if (isChanged()) {
Fragment target = getTargetFragment();
if (target instanceof BaseSettingsFragment) {
BaseSettingsFragment fragment = (BaseSettingsFragment) target;
fragment.onApplyPreferenceChange(preference.getId(), false, currentValue);
}
}
dismiss();
}
Aggregations