[Android] Equalizer: use the dialog context so the save button always works

Nicolas Pomepuy git at videolan.org
Thu Dec 19 13:02:16 CET 2019


vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Dec 19 07:02:54 2019 +0000| [a3e6694d62031180cd0eb871bea9123fded81790] | committer: Geoffrey Métais

Equalizer: use the dialog context so the save button always works

Fixes #1131


(cherry picked from commit 845b917b4d602ce30f508336e59d36f05db3418b)

> https://code.videolan.org/videolan/vlc-android/commit/a3e6694d62031180cd0eb871bea9123fded81790
---

 vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.kt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.kt b/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.kt
index ab544ba2f..31e9726b6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/EqualizerFragment.kt
@@ -21,6 +21,7 @@
 package org.videolan.vlc.gui.audio
 
 import android.annotation.SuppressLint
+import android.content.Context
 import android.content.DialogInterface
 import android.os.Bundle
 import android.text.TextUtils
@@ -341,7 +342,7 @@ class EqualizerFragment : VLCBottomSheetDialogFragment(), CoroutineScope by Main
             if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP) {
                 //Perform Code
                 if (BuildConfig.DEBUG) Log.d(this::class.java.simpleName, "Enter pressed")
-                save(input, oldName, temporarySet, onPause, displayedByUser, positionToSave, saveEqualizer)
+                save(saveEqualizer.context, input, oldName, temporarySet, onPause, displayedByUser, positionToSave, saveEqualizer)
                 return at OnKeyListener true
             }
             false
@@ -353,14 +354,13 @@ class EqualizerFragment : VLCBottomSheetDialogFragment(), CoroutineScope by Main
         saveEqualizer.setOnShowListener { dialog ->
             val positiveButton = (dialog as AlertDialog).getButton(AlertDialog.BUTTON_POSITIVE)
             positiveButton.setOnClickListener {
-                save(input, oldName, temporarySet, onPause, displayedByUser, positionToSave, saveEqualizer)
+                save(saveEqualizer.context, input, oldName, temporarySet, onPause, displayedByUser, positionToSave, saveEqualizer)
             }
         }
         saveEqualizer.show()
     }
 
-    private fun save(input: EditText, oldName: String, temporarySet: MediaPlayer.Equalizer, onPause: Boolean, displayedByUser: Boolean, positionToSave: Int, saveEqualizer: AlertDialog) {
-        val ctx = activity ?: return
+    private fun save(ctx: Context, input: EditText, oldName: String, temporarySet: MediaPlayer.Equalizer, onPause: Boolean, displayedByUser: Boolean, positionToSave: Int, saveEqualizer: AlertDialog) {
         val newName = input.text.toString()
         if (newName.contains("_") || TextUtils.equals(newName, newPresetName)) {
             Toast.makeText(ctx, VLCApplication.appContext.resources.getString(R.string.custom_set_wrong_input), Toast.LENGTH_SHORT).show()



More information about the Android mailing list