Skip to content
This repository has been archived by the owner on Sep 8, 2019. It is now read-only.

Commit

Permalink
- deleting an image in the ItemActivity no longer takes the user back…
Browse files Browse the repository at this point in the history
… to AlbumActivity (#132)
  • Loading branch information
kollerlukas committed Mar 21, 2018
1 parent 9ca847e commit 55d693f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static boolean isAlbumPinned(String albumPath, ArrayList<String> pinnedPa
return true;
} else {
for (int i = 0; i < pinnedPaths.size(); i++) {
if (albumPath.contains(pinnedPaths.get(i))) {
if (albumPath.equals(pinnedPaths.get(i))) {
return true;
}
}
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/us/koller/cameraroll/ui/AlbumActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ public void onAlbumLoaded(Album album) {
}

private void removeAlbumItem(String path) {
Log.d("AlbumActivity", "removeAlbumItem() called with: path = [" + path + "]");
int index = -1;
for (int i = 0; i < album.getAlbumItems().size(); i++) {
AlbumItem albumItem = album.getAlbumItems().get(i);
Expand All @@ -1169,9 +1170,14 @@ private void removeAlbumItem(String path) {
break;
}
}
Log.d("AlbumActivity", "removeAlbumItem: " + index);
if (index > -1) {
album.getAlbumItems().remove(index);
recyclerViewAdapter.notifyDataSetChanged();
}
recyclerViewAdapter.notifyDataSetChanged();

if (album.getAlbumItems().size() == 0) {
finish();
}
}
}
18 changes: 16 additions & 2 deletions app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,22 @@ public void onReceive(Context context, Intent intent) {
.putExtra(ALBUM_ITEM_PATH, path);
//notify AlbumActivity
LocalBroadcastManager.getInstance(ItemActivity.this).sendBroadcast(i);
ItemActivity.this.setResult(RESULT_OK);
finish();
/*ItemActivity.this.setResult(RESULT_OK);
finish();*/

album.getAlbumItems().remove(albumItem);
viewPager.getAdapter().notifyDataSetChanged();

if (album.getAlbumItems().size() == 0) {
ItemActivity.this.setResult(RESULT_OK);
finish();
return;
}

albumItem = album.getAlbumItems().get(viewPager.getCurrentItem());
ItemAdapter adapter = (ItemAdapter) viewPager.getAdapter();
ViewHolder viewHolder = adapter.findViewHolderByTag(albumItem.getPath());
onShowViewHolder(viewHolder);
break;
case FileOperation.FAILED:
//onBackPressed();
Expand Down

0 comments on commit 55d693f

Please sign in to comment.