Skip to content

Commit

Permalink
Reverted change meant for another PR
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Nov 11, 2023
1 parent 9797350 commit b0cdbfc
Showing 1 changed file with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,6 @@ private static void insertItem(
}
};

// Pull dialog elements
final EditText nameEdit, pathEdit;
if (dialog != null) {
nameEdit = dialog.findViewById(R.id.ui__select_path_dialog__name);
pathEdit = dialog.findViewById(R.id.ui__select_path_dialog__url);
} else {
nameEdit = pathEdit = null;
}

final GsCallback.a1<File> insertFileLink = (file) -> {
// If path is not under notebook, copy it to the res folder
if (!GsFileUtils.isChild(_appSettings.getNotebookDirectory(), file)) {
Expand All @@ -276,20 +267,13 @@ private static void insertItem(
GsFileUtils.copyFile(file, local);
file = local;
}

final String title;
if (nameEdit != null) {
title = nameEdit.getText().toString();
} else {
title = GsFileUtils.getFilenameWithoutExtension(file);
}

final String title = GsFileUtils.getFilenameWithoutExtension(file);
final String path = GsFileUtils.relativePath(currentFile, file);
insertLink.callback(title, path);
};

final MarkorContextUtils shu = new MarkorContextUtils(activity);
final BroadcastReceiver receiver = shu.receiveResultFromLocalBroadcast(
final BroadcastReceiver br = shu.receiveResultFromLocalBroadcast(
activity,
(intent, _br) -> insertFileLink.callback(new File(intent.getStringExtra(MarkorContextUtils.EXTRA_FILEPATH))),
true,
Expand All @@ -298,8 +282,13 @@ private static void insertItem(
"" + MarkorContextUtils.REQUEST_RECORD_AUDIO
);

final EditText nameEdit, pathEdit;
if (dialog != null) {
dialog.setOnDismissListener(d -> LocalBroadcastManager.getInstance(activity).unregisterReceiver(receiver));
nameEdit = dialog.findViewById(R.id.ui__select_path_dialog__name);
pathEdit = dialog.findViewById(R.id.ui__select_path_dialog__url);
dialog.setOnDismissListener(d -> LocalBroadcastManager.getInstance(activity).unregisterReceiver(br));
} else {
nameEdit = pathEdit = null;
}

// Do each thing as necessary
Expand Down

0 comments on commit b0cdbfc

Please sign in to comment.