Skip to content

Commit

Permalink
#155: Gallery refresh query after detail-change or delete
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Jan 3, 2020
1 parent ca57d2d commit d0c011a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public void onResume() {
// workaround fragment lifecycle is newFragment.attach oldFragment.detach.
// this makes shure that the visible fragment has commands
MoveOrCopyDestDirPicker.sFileCommands = mFileCommands;

requeryIfDataHasChanged();
}

/**
Expand Down Expand Up @@ -835,7 +835,7 @@ public boolean onOptionsItemSelected(MenuItem menuItem) {
AndroidFileCommands fileCommands = mFileCommands;

final SelectedFiles selectedFiles = this.mAdapter.createSelectedFiles(getActivity(), this.mSelectedItems);
if ((mSelectedItems != null) && (fileCommands.onOptionsItemSelected(menuItem, selectedFiles))) {
if ((mSelectedItems != null) && (fileCommands.onOptionsItemSelected(menuItem, selectedFiles, this))) {
return true;
}
switch (menuItem.getItemId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public boolean onOptionsItemSelected(MenuItem menuItem) {
this.invalidateOptionsMenu();
return true;
}
if (mFileCommands.onOptionsItemSelected(menuItem, getCurrentFoto())) {
if (mFileCommands.onOptionsItemSelected(menuItem, getCurrentFoto(), this)) {
mModifyCount++;
} else {
// Handle presses on the action bar items
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/de/k3b/android/util/AndroidFileCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ private static int getResourceId(int opCode) {

}

public boolean onOptionsItemSelected(final MenuItem item, final SelectedFiles selectedFileNames) {
public boolean onOptionsItemSelected(final MenuItem item, final SelectedFiles selectedFileNames, DataChangeNotifyer.DataChangedListener dataChangedListener) {
if ((selectedFileNames != null) && (selectedFileNames.size() > 0)) {
// Handle item selection
switch (item.getItemId()) {
case R.id.cmd_delete:
return cmdDeleteFileWithQuestion(selectedFileNames);
return cmdDeleteFileWithQuestion(selectedFileNames, dataChangedListener);
default:break;
}
}
Expand Down Expand Up @@ -276,7 +276,8 @@ private void setLastCopyToPath(String copyToPath) {
edit.apply();
}

public boolean cmdDeleteFileWithQuestion(final SelectedFiles fotos) {
public boolean cmdDeleteFileWithQuestion(final SelectedFiles fotos,
final DataChangeNotifyer.DataChangedListener dataChangedListener) {
String[] pathNames = fotos.getFileNames();
String errorMessage = checkWriteProtected(R.string.delete_menu_title, SelectedFiles.getFiles(pathNames));

Expand Down Expand Up @@ -307,6 +308,9 @@ public void onClick(
final int id) {
mActiveAlert = null;
deleteFiles(fotos, null);
if (dataChangedListener != null) {
dataChangedListener.onNotifyDataChanged();
}
}
}
)
Expand Down

0 comments on commit d0c011a

Please sign in to comment.