Fix crashing on blacklist items clear
This commit is contained in:
parent
eec008ef4d
commit
4e26c62472
1 changed files with 0 additions and 105 deletions
|
@ -30,7 +30,6 @@ import com.afollestad.materialdialogs.list.listItems
|
|||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
|
||||
class BlacklistPreference : ATEDialogPreference {
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
|
@ -107,108 +106,4 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
BlacklistStore.getInstance(context!!).addPath(folder);
|
||||
refreshBlacklistData();
|
||||
}
|
||||
|
||||
/*public static final String TAG = BlacklistPreferenceDialog.class.getSimpleName();
|
||||
|
||||
private ArrayList<String> paths;
|
||||
|
||||
public static BlacklistPreferenceDialog newInstance() {
|
||||
return new BlacklistPreferenceDialog();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
BlacklistFolderChooserDialog blacklistFolderChooserDialog = (BlacklistFolderChooserDialog) getChildFragmentManager()
|
||||
.findFragmentByTag("FOLDER_CHOOSER");
|
||||
if (blacklistFolderChooserDialog != null) {
|
||||
blacklistFolderChooserDialog.setCallback(this);
|
||||
}
|
||||
|
||||
refreshBlacklistData();
|
||||
return new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.blacklist)
|
||||
.positiveText(android.R.string.ok)
|
||||
.neutralText(R.string.clear_action)
|
||||
.negativeText(R.string.add_action)
|
||||
.items(paths)
|
||||
.autoDismiss(false)
|
||||
.itemsCallback(new MaterialDialog.ListCallback() {
|
||||
@Override
|
||||
public void onSelection(MaterialDialog materialDialog, View view, int i,
|
||||
final CharSequence charSequence) {
|
||||
new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.remove_from_blacklist)
|
||||
.content(Html.fromHtml(
|
||||
getString(R.string.do_you_want_to_remove_from_the_blacklist, charSequence)))
|
||||
.positiveText(R.string.remove_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistStore.getInstance(getContext())
|
||||
.removePath(new File(charSequence.toString()));
|
||||
refreshBlacklistData();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
// clear
|
||||
.onNeutral(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
new MaterialDialog.Builder(getContext())
|
||||
.title(R.string.clear_blacklist)
|
||||
.content(R.string.do_you_want_to_clear_the_blacklist)
|
||||
.positiveText(R.string.clear_action)
|
||||
.negativeText(android.R.string.cancel)
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistStore.getInstance(getContext()).clear();
|
||||
refreshBlacklistData();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
// add
|
||||
.onNegative(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
BlacklistFolderChooserDialog dialog = BlacklistFolderChooserDialog.create();
|
||||
dialog.setCallback(BlacklistPreferenceDialog.this);
|
||||
dialog.show(getChildFragmentManager(), "FOLDER_CHOOSER");
|
||||
}
|
||||
})
|
||||
.onPositive(new MaterialDialog.SingleButtonCallback() {
|
||||
@Override
|
||||
public void onClick(@NonNull MaterialDialog materialDialog,
|
||||
@NonNull DialogAction dialogAction) {
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private void refreshBlacklistData() {
|
||||
paths = BlacklistStore.getInstance(getContext()).getPaths();
|
||||
|
||||
MaterialDialog dialog = (MaterialDialog) getDialog();
|
||||
if (dialog != null) {
|
||||
String[] pathArray = new String[paths.size()];
|
||||
pathArray = paths.toArray(pathArray);
|
||||
dialog.setItems((CharSequence[]) pathArray);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFolderSelection(@NonNull BlacklistFolderChooserDialog folderChooserDialog,
|
||||
@NonNull File file) {
|
||||
BlacklistStore.getInstance(getContext()).addPath(file);
|
||||
refreshBlacklistData();
|
||||
}*/
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue