Fixed all Blacklist related crashes
This commit is contained in:
parent
d65feb30b4
commit
077089c94c
1 changed files with 11 additions and 16 deletions
|
@ -61,7 +61,9 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
val chooserDialog =
|
val chooserDialog =
|
||||||
childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog?
|
childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog?
|
||||||
chooserDialog?.setCallback(this)
|
chooserDialog?.setCallback(this)
|
||||||
refreshBlacklistData()
|
val context = requireActivity()
|
||||||
|
|
||||||
|
refreshBlacklistData(context)
|
||||||
return materialDialog(R.string.blacklist)
|
return materialDialog(R.string.blacklist)
|
||||||
.setPositiveButton(R.string.done) { _, _ ->
|
.setPositiveButton(R.string.done) { _, _ ->
|
||||||
dismiss()
|
dismiss()
|
||||||
|
@ -69,7 +71,9 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
.setNeutralButton(R.string.clear_action) { _, _ ->
|
.setNeutralButton(R.string.clear_action) { _, _ ->
|
||||||
materialDialog(R.string.clear_blacklist)
|
materialDialog(R.string.clear_blacklist)
|
||||||
.setMessage(R.string.do_you_want_to_clear_the_blacklist)
|
.setMessage(R.string.do_you_want_to_clear_the_blacklist)
|
||||||
.setPositiveButton(R.string.clear_action, null)
|
.setPositiveButton(R.string.clear_action) { _, _ ->
|
||||||
|
BlacklistStore.getInstance(context).clear()
|
||||||
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.create()
|
.create()
|
||||||
.colorButtons()
|
.colorButtons()
|
||||||
|
@ -89,9 +93,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
).parseAsHtml()
|
).parseAsHtml()
|
||||||
)
|
)
|
||||||
.setPositiveButton(R.string.remove_action) { _, _ ->
|
.setPositiveButton(R.string.remove_action) { _, _ ->
|
||||||
BlacklistStore.getInstance(requireContext())
|
BlacklistStore.getInstance(context).removePath(File(paths[which]))
|
||||||
.removePath(File(paths[which]))
|
|
||||||
refreshBlacklistData()
|
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.create()
|
.create()
|
||||||
|
@ -102,23 +104,16 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
||||||
setOnShowListener {
|
setOnShowListener {
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).accentTextColor()
|
getButton(AlertDialog.BUTTON_POSITIVE).accentTextColor()
|
||||||
getButton(AlertDialog.BUTTON_NEGATIVE).accentTextColor()
|
getButton(AlertDialog.BUTTON_NEGATIVE).accentTextColor()
|
||||||
getButton(AlertDialog.BUTTON_NEUTRAL).apply {
|
getButton(AlertDialog.BUTTON_NEUTRAL).accentTextColor()
|
||||||
accentTextColor()
|
|
||||||
setOnClickListener {
|
|
||||||
BlacklistStore.getInstance(
|
|
||||||
requireContext()
|
|
||||||
).clear()
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var paths: ArrayList<String>
|
private lateinit var paths: ArrayList<String>
|
||||||
|
|
||||||
private fun refreshBlacklistData() {
|
private fun refreshBlacklistData(context: Context?) {
|
||||||
this.paths = BlacklistStore.getInstance(requireContext()).paths
|
if (context == null) return
|
||||||
|
this.paths = BlacklistStore.getInstance(context).paths
|
||||||
val dialog = dialog as MaterialAlertDialogBuilder?
|
val dialog = dialog as MaterialAlertDialogBuilder?
|
||||||
dialog?.setItems(paths.toTypedArray(), null)
|
dialog?.setItems(paths.toTypedArray(), null)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue