Skip to content

Commit 870eb51

Browse files
committed
add missing ShareeListAdapter for unShare
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 38f2955 commit 870eb51

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

app/src/main/java/com/owncloud/android/ui/adapter/ShareeListAdapter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,12 @@ public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
244244
return false;
245245
}
246246

247-
@SuppressLint("NotifyDataSetChanged")
248247
public void remove(OCShare share) {
249-
shares.remove(share);
250-
notifyDataSetChanged();
248+
int position = shares.indexOf(share);
249+
if (position != -1) {
250+
shares.remove(position);
251+
notifyItemRemoved(position);
252+
}
251253
}
252254

253255
/**

app/src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ private void refreshUiFromDB() {
468468
setupView();
469469
}
470470

471-
private void unshareWith(OCShare share) {
472-
fileOperationsHelper.unshareShare(file, share);
471+
private void unShareWith(OCShare share) {
472+
fileOperationsHelper.unShareShare(file, share);
473473
}
474474

475475
/**
@@ -665,13 +665,15 @@ public void sendNewEmail(OCShare share) {
665665

666666
@Override
667667
public void unShare(OCShare share) {
668-
unshareWith(share);
669-
ShareeListAdapter adapter = (ShareeListAdapter) binding.sharesListInternal.getAdapter();
670-
if (adapter == null) {
668+
unShareWith(share);
669+
670+
if (binding.sharesListInternal.getAdapter() instanceof ShareeListAdapter adapter) {
671+
adapter.remove(share);
672+
} else if (binding.sharesListExternal.getAdapter() instanceof ShareeListAdapter adapter) {
673+
adapter.remove(share);
674+
} else {
671675
DisplayUtils.showSnackMessage(getView(), getString(R.string.failed_update_ui));
672-
return;
673676
}
674-
adapter.remove(share);
675677
}
676678

677679
@Override

app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -602,16 +602,13 @@ public void restoreFileVersion(FileVersion fileVersion) {
602602
*
603603
* @param file The file to unshare.
604604
*/
605-
public void unshareShare(OCFile file, OCShare share) {
606-
607-
// Unshare the file: Create the intent
608-
Intent unshareService = new Intent(fileActivity, OperationsService.class);
609-
unshareService.setAction(OperationsService.ACTION_UNSHARE);
610-
unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
611-
unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
612-
unshareService.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
613-
614-
queueShareIntent(unshareService);
605+
public void unShareShare(OCFile file, OCShare share) {
606+
Intent intent = new Intent(fileActivity, OperationsService.class);
607+
intent.setAction(OperationsService.ACTION_UNSHARE);
608+
intent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
609+
intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
610+
intent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
611+
queueShareIntent(intent);
615612
}
616613

617614
private void queueShareIntent(Intent shareIntent) {

0 commit comments

Comments
 (0)