Fix crashing on blacklist items clear
This commit is contained in:
commit
eec008ef4d
9 changed files with 126 additions and 26 deletions
|
@ -59,7 +59,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
val blacklistFolderChooserDialog = childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog?
|
||||
blacklistFolderChooserDialog?.setCallback(this)
|
||||
refreshBlacklistData()
|
||||
return MaterialDialog(context!!, BottomSheet()).sstathow {
|
||||
return MaterialDialog(context!!, BottomSheet()).show {
|
||||
title(code.name.monkey.retromusic.R.string.blacklist)
|
||||
positiveButton(android.R.string.ok) {
|
||||
dismiss()
|
||||
|
@ -69,8 +69,8 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
title(code.name.monkey.retromusic.R.string.clear_blacklist)
|
||||
message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist)
|
||||
positiveButton(code.name.monkey.retromusic.R.string.clear_action) {
|
||||
BlacklistStore.getInstance(context).clear();
|
||||
refreshBlacklistData();
|
||||
BlacklistStore.getInstance(context).clear()
|
||||
refreshBlacklistData()
|
||||
}
|
||||
negativeButton(android.R.string.cancel)
|
||||
}
|
||||
|
@ -80,13 +80,13 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
dialog.setCallback(this@BlacklistPreferenceDialog)
|
||||
dialog.show(childFragmentManager, "FOLDER_CHOOSER");
|
||||
}
|
||||
listItems(items = paths) { dialog, index, text ->
|
||||
listItems(items = paths, waitForPositiveButton = false) { _, _, text ->
|
||||
MaterialDialog(context, BottomSheet()).show {
|
||||
title(code.name.monkey.retromusic.R.string.remove_from_blacklist)
|
||||
message(text = Html.fromHtml(getString(code.name.monkey.retromusic.R.string.do_you_want_to_remove_from_the_blacklist, text)))
|
||||
positiveButton(code.name.monkey.retromusic.R.string.remove_action) {
|
||||
BlacklistStore.getInstance(context).removePath(File(text));
|
||||
refreshBlacklistData();
|
||||
BlacklistStore.getInstance(context).removePath(File(text))
|
||||
refreshBlacklistData()
|
||||
}
|
||||
negativeButton(android.R.string.cancel)
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
|
||||
private fun refreshBlacklistData() {
|
||||
this.paths = BlacklistStore.getInstance(context!!).paths
|
||||
val dialog = dialog as MaterialDialog
|
||||
dialog.listItems(items = paths)
|
||||
val dialog = dialog as MaterialDialog?
|
||||
dialog?.listItems(items = paths)
|
||||
}
|
||||
|
||||
override fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File) {
|
||||
|
|
|
@ -21,16 +21,15 @@ import android.content.SharedPreferences.Editor;
|
|||
import android.content.res.TypedArray;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StyleRes;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import code.name.monkey.retromusic.App;
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.activities.MainActivity;
|
||||
|
@ -151,23 +150,24 @@ public final class PreferenceUtil {
|
|||
return R.style.Theme_RetroMusic_Black;
|
||||
case "black":
|
||||
return R.style.Theme_RetroMusic_Black;
|
||||
case "daynight":
|
||||
return R.style.Theme_RetroMusic_DayNight;
|
||||
case "dark":
|
||||
default:
|
||||
return R.style.Theme_RetroMusic;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSleepTimerFinishMusic() {
|
||||
return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false);
|
||||
}
|
||||
|
||||
public void setSleepTimerFinishMusic(final boolean value) {
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putBoolean(SLEEP_TIMER_FINISH_SONG, value);
|
||||
editor.apply();
|
||||
}
|
||||
|
||||
public boolean getSleepTimerFinishMusic() {
|
||||
return mPreferences.getBoolean(SLEEP_TIMER_FINISH_SONG, false);
|
||||
}
|
||||
|
||||
|
||||
public String getUserBio() {
|
||||
return mPreferences.getString(USER_BIO, "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue