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

Nicolas Pomepuy git at videolan.org
Thu Dec 19 12:56:24 CET 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Dec 19 08:02:54 2019 +0100| [845b917b4d602ce30f508336e59d36f05db3418b] | committer: Nicolas Pomepuy

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

Fixes #1131

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

 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 4677bbdf8..655839844 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
@@ -342,7 +343,7 @@ class EqualizerFragment : VLCBottomSheetDialogFragment() {
             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
@@ -354,14 +355,13 @@ class EqualizerFragment : VLCBottomSheetDialogFragment() {
         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