From 63664c5f52b4eade280e2b674eb63f18c1ff6cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Schu=CC=88ller?= Date: Wed, 9 Jan 2019 18:05:56 +0100 Subject: [PATCH] Wip --- .../fragment/VideoMenuQualityFragment.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java index 8f361a7..06cc612 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoMenuQualityFragment.java @@ -42,19 +42,21 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment { private static ArrayList mFiles; public static final String TAG = "VideoMenuQuality"; + private static File autoQualityFile; public static VideoMenuQualityFragment newInstance(ArrayList files) { mFiles = files; // Auto quality - File autoQualityFile = new File(); - Resolution autoQualityResolution = new Resolution(); - autoQualityResolution.setId(0); - autoQualityResolution.setLabel("Auto"); - autoQualityFile.setId(0); - autoQualityFile.setResolution(autoQualityResolution); - + if (autoQualityFile == null) { + autoQualityFile = new File(); + Resolution autoQualityResolution = new Resolution(); + autoQualityResolution.setId(0); + autoQualityResolution.setLabel("Auto"); + autoQualityFile.setId(0); + autoQualityFile.setResolution(autoQualityResolution); + } if (!mFiles.contains(autoQualityFile)) { mFiles.add(0, autoQualityFile); } @@ -74,11 +76,12 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getContext()); 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); TextView iconView = menuRow.findViewById(R.id.video_quality_icon); + iconView.setId(file.getId()); TextView textView = menuRow.findViewById(R.id.video_quality_text); Log.v(TAG, file.getResolution().getLabel()); @@ -89,6 +92,9 @@ public class VideoMenuQualityFragment extends BottomSheetDialogFragment { SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("pref_quality", file.getResolution().getId()); editor.apply(); + + // TODO: unset icon on non selected items + iconView.setText(R.string.video_quality_active_icon); new Iconics.IconicsBuilder().ctx(getContext()).on(iconView).build(); });