This commit is contained in:
Stefan Schüller 2019-01-09 18:05:56 +01:00
parent f3f65eb7d9
commit 63664c5f52

View File

@ -42,19 +42,21 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment {
private static ArrayList<File> mFiles; private static ArrayList<File> mFiles;
public static final String TAG = "VideoMenuQuality"; public static final String TAG = "VideoMenuQuality";
private static File autoQualityFile;
public static VideoMenuQualityFragment newInstance(ArrayList<File> files) { public static VideoMenuQualityFragment newInstance(ArrayList<File> files) {
mFiles = files; mFiles = files;
// Auto quality // Auto quality
File autoQualityFile = new File(); if (autoQualityFile == null) {
Resolution autoQualityResolution = new Resolution(); autoQualityFile = new File();
autoQualityResolution.setId(0); Resolution autoQualityResolution = new Resolution();
autoQualityResolution.setLabel("Auto"); autoQualityResolution.setId(0);
autoQualityFile.setId(0); autoQualityResolution.setLabel("Auto");
autoQualityFile.setResolution(autoQualityResolution); autoQualityFile.setId(0);
autoQualityFile.setResolution(autoQualityResolution);
}
if (!mFiles.contains(autoQualityFile)) { if (!mFiles.contains(autoQualityFile)) {
mFiles.add(0, autoQualityFile); mFiles.add(0, autoQualityFile);
} }
@ -74,11 +76,12 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext());
Integer videoQuality = sharedPref.getInt("pref_quality", 0); Integer videoQuality = sharedPref.getInt("pref_quality", 0);
for (File file :mFiles) { for (File file : mFiles) {
LinearLayout menuRow = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null); LinearLayout menuRow = (LinearLayout) inflater.inflate(R.layout.row_popup_menu, null);
TextView iconView = menuRow.findViewById(R.id.video_quality_icon); TextView iconView = menuRow.findViewById(R.id.video_quality_icon);
iconView.setId(file.getId());
TextView textView = menuRow.findViewById(R.id.video_quality_text); TextView textView = menuRow.findViewById(R.id.video_quality_text);
Log.v(TAG, file.getResolution().getLabel()); Log.v(TAG, file.getResolution().getLabel());
@ -89,6 +92,9 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment {
SharedPreferences.Editor editor = sharedPref.edit(); SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("pref_quality", file.getResolution().getId()); editor.putInt("pref_quality", file.getResolution().getId());
editor.apply(); editor.apply();
// TODO: unset icon on non selected items
iconView.setText(R.string.video_quality_active_icon); iconView.setText(R.string.video_quality_active_icon);
new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build(); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build();
}); });