/*
- * Copyright © 2016-2018 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import java.io.ByteArrayOutputStream;
public class MoveToFolderDialog extends AppCompatDialogFragment {
- // Instantiate class variables.
+ // Instantiate the class variables.
+ private MoveToFolderListener moveToFolderListener;
private BookmarksDatabaseHelper bookmarksDatabaseHelper;
private StringBuilder exceptFolders;
void onMoveToFolder(AppCompatDialogFragment dialogFragment);
}
- // `moveToFolderListener` is used in `onAttach()` and `onCreateDialog`.
- private MoveToFolderListener moveToFolderListener;
-
public void onAttach(Context context) {
+ // Run the default commands.
super.onAttach(context);
- // Get a handle for `MoveToFolderListener` from `parentActivity`.
- try {
- moveToFolderListener = (MoveToFolderListener) context;
- } catch(ClassCastException exception) {
- throw new ClassCastException(context.toString() + " must implement EditBookmarkFolderListener.");
- }
+ // Get a handle for `MoveToFolderListener` from the launching context.
+ moveToFolderListener = (MoveToFolderListener) context;
}
// `@SuppressLing("InflateParams")` removes the warning about using `null` as the parent view group when inflating the `AlertDialog`.
}
// Get a `Cursor` containing the folders to display.
- foldersCursor = bookmarksDatabaseHelper.getFoldersCursorExcept(exceptFolders.toString());
+ foldersCursor = bookmarksDatabaseHelper.getFoldersExcept(exceptFolders.toString());
// Setup `foldersCursorAdaptor` with `this` context. `false` disables autoRequery.
foldersCursorAdapter = new CursorAdapter(alertDialog.getContext(), foldersCursor, false) {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
+ // Remove the incorrect lint warning that `.getLayoutInflator()` might be false.
+ assert getActivity() != null;
+
// Inflate the individual item layout. `false` does not attach it to the root.
return getActivity().getLayoutInflater().inflate(R.layout.move_to_folder_item_linearlayout, parent, false);
}
}
// Get a `Cursor` containing the folders to display.
- foldersCursor = bookmarksDatabaseHelper.getFoldersCursorExcept(exceptFolders.toString());
+ foldersCursor = bookmarksDatabaseHelper.getFoldersExcept(exceptFolders.toString());
// Combine `homeFolderMatrixCursor` and `foldersCursor`.
MergeCursor foldersMergeCursor = new MergeCursor(new Cursor[]{homeFolderMatrixCursor, foldersCursor});
foldersCursorAdapter = new CursorAdapter(alertDialog.getContext(), foldersMergeCursor, false) {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
+ // Remove the incorrect lint warning that `.getLayoutInflator()` might be false.
+ assert getActivity() != null;
+
// Inflate the individual item layout. `false` does not attach it to the root.
return getActivity().getLayoutInflater().inflate(R.layout.move_to_folder_item_linearlayout, parent, false);
}
private void addSubfoldersToExceptFolders(String folderName) {
// Get a `Cursor` will all the immediate subfolders.
- Cursor subfoldersCursor = bookmarksDatabaseHelper.getSubfoldersCursor(folderName);
+ Cursor subfoldersCursor = bookmarksDatabaseHelper.getSubfolders(folderName);
for (int i = 0; i < subfoldersCursor.getCount(); i++) {
// Move `subfolderCursor` to the current item.