use of com.skydoves.powerspinner.PowerSpinnerView in project Hentoid by avluis.
the class ViewerDeleteDialogFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState);
RadioButton pageBtn = rootView.findViewById(R.id.delete_mode_page);
RadioButton bookBtn = rootView.findViewById(R.id.delete_mode_book);
PowerSpinnerView spin = rootView.findViewById(R.id.book_prefs_delete_spin);
spin.setItems(R.array.page_delete_choices);
spin.selectItemByIndex(0);
if (!isDeletePageAllowed)
pageBtn.setEnabled(false);
View okBtn = rootView.findViewById(R.id.book_delete_ok_btn);
okBtn.setOnClickListener(v -> {
if (!pageBtn.isChecked() && !bookBtn.isChecked())
return;
Preferences.setViewerDeleteAskMode(spin.getSelectedIndex());
Preferences.setViewerDeleteTarget(pageBtn.isChecked() ? Preferences.Constant.VIEWER_DELETE_TARGET_PAGE : Preferences.Constant.VIEWER_DELETE_TARGET_BOOK);
parent.onDeleteElement(pageBtn.isChecked());
dismiss();
});
}
use of com.skydoves.powerspinner.PowerSpinnerView in project Hentoid by avluis.
the class ViewerPrefsDialogFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View rootView, @Nullable Bundle savedInstanceState) {
super.onViewCreated(rootView, savedInstanceState);
Resources res = rootView.getContext().getResources();
// == Dropdown lists
String[] browseModes = getResources().getStringArray(R.array.pref_viewer_browse_mode_entries);
List<String> browseItems = new ArrayList<>();
// App pref
browseItems.add(res.getString(R.string.use_app_prefs, browseModes[Preferences.getViewerBrowseMode()]));
// Available prefs
browseItems.addAll(Arrays.asList(browseModes));
PowerSpinnerView browseSpin = rootView.findViewById(R.id.book_prefs_browse_spin);
browseSpin.setItems(browseItems);
browseSpin.selectItemByIndex(browseMode + 1);
String[] renderingModes = getResources().getStringArray(R.array.pref_viewer_rendering_entries);
List<String> renderingItems = new ArrayList<>();
// App pref
renderingItems.add(res.getString(R.string.use_app_prefs, renderingModes[Preferences.isViewerSmoothRendering() ? 1 : 0].replace(" (" + getString(R.string._default) + ")", "")));
// Available prefs
for (int i = 0; i < renderingModes.length; i++) {
// No smooth mode for Android 5
if (1 == i && Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
continue;
renderingItems.add(renderingModes[i].replace(" (" + getString(R.string._default) + ")", ""));
}
PowerSpinnerView renderSpin = rootView.findViewById(R.id.book_prefs_rendering_spin);
renderSpin.setItems(renderingItems);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
renderSpin.selectItemByIndex(0);
renderSpin.setEnabled(false);
} else
renderSpin.selectItemByIndex(renderingMode + 1);
// == Bottom buttons
View appSettingsBtn = rootView.findViewById(R.id.book_prefs_app_prefs_btn);
appSettingsBtn.setOnClickListener(v -> {
Intent intent = new Intent(requireActivity(), PrefsActivity.class);
PrefsBundle prefsBundle = new PrefsBundle();
prefsBundle.setViewerPrefs(true);
intent.putExtras(prefsBundle.toBundle());
requireContext().startActivity(intent);
});
View okBtn = rootView.findViewById(R.id.book_prefs_ok_btn);
okBtn.setOnClickListener(v -> {
Map<String, String> newPrefs = new HashMap<>();
if (renderSpin.getSelectedIndex() > 0)
newPrefs.put(VIEWER_RENDERING, (renderSpin.getSelectedIndex() - 1) + "");
if (browseSpin.getSelectedIndex() > 0)
newPrefs.put(VIEWER_BROWSE_MODE, (browseSpin.getSelectedIndex() - 1) + "");
parent.onBookPreferenceChanged(newPrefs);
dismiss();
});
}
Aggregations