use of com.amaze.filemanager.adapters.ColorAdapter in project AmazeFileManager by TeamAmaze.
the class ColorPref method onPreferenceClick.
@Override
public boolean onPreferenceClick(final Preference preference) {
switch(preference.getKey()) {
case KEY_COLOREDNAV:
activity.invalidateNavBar();
break;
case PreferencesConstants.PREFERENCE_SKIN:
case PreferencesConstants.PREFERENCE_SKIN_TWO:
case PreferencesConstants.PREFERENCE_ACCENT:
case PreferencesConstants.PREFERENCE_ICON_SKIN:
final ColorUsage usage = ColorUsage.fromString(preference.getKey());
if (usage != null) {
ColorAdapter adapter = new ColorAdapter(getActivity(), ColorPreference.getUniqueAvailableColors(getActivity()), usage, activity.getColorPreference().getColor(usage), (selectedColorRes) -> {
activity.getColorPreference().setRes(usage, selectedColorRes).saveToPreferences(sharedPref);
if (dialog != null)
dialog.dismiss();
invalidateEverything();
});
GridView v = (GridView) getActivity().getLayoutInflater().inflate(R.layout.dialog_grid, null);
v.setAdapter(adapter);
v.setOnItemClickListener(adapter);
int fab_skin = activity.getColorPreference().getColor(ColorUsage.ACCENT);
dialog = new MaterialDialog.Builder(getActivity()).positiveText(R.string.cancel).title(R.string.choose_color).theme(activity.getAppTheme().getMaterialDialogTheme()).autoDismiss(true).positiveColor(fab_skin).neutralColor(fab_skin).neutralText(R.string.defualt).callback(new MaterialDialog.ButtonCallback() {
@Override
public void onNeutral(MaterialDialog dialog) {
super.onNeutral(dialog);
if (activity != null)
activity.setRestartActivity();
activity.getColorPreference().setRes(usage, usage.getDefaultColor()).saveToPreferences(sharedPref);
invalidateEverything();
}
}).customView(v, false).show();
}
return false;
case "selectcolorconfig":
switchSections();
return true;
}
return false;
}
Aggregations