@@ -3501,6 +3501,9 @@ public void removeRange(@IntRange(from = 0) int positionStart,
3501
3501
}
3502
3502
// Remove item from internal list
3503
3503
mItems .remove (positionStart );
3504
+ if (permanentDelete && mOriginalList != null ) {
3505
+ mOriginalList .remove (item );
3506
+ }
3504
3507
removeSelection (position );
3505
3508
}
3506
3509
@@ -3680,10 +3683,24 @@ public void restoreDeletedItems() {
3680
3683
emptyBin ();
3681
3684
}
3682
3685
3686
+ /**
3687
+ * Performs removal confirmation and cleans memory by synchronizing the internal list from deletion.
3688
+ * <p><b>Note:</b> This method is automatically called after timer is over in UndoHelper.</p>
3689
+ *
3690
+ * @since 5.0.1
3691
+ */
3692
+ public void confirmDeletion () {
3693
+ log .d ("confirmDeletion!" );
3694
+ if (mOriginalList != null ) {
3695
+ mOriginalList .removeAll (getDeletedItems ());
3696
+ }
3697
+ emptyBin ();
3698
+ }
3699
+
3683
3700
/**
3684
3701
* Cleans memory from items just removed.
3685
- * <p><b>Note:</b> This method is automatically called after timer is over and after a
3686
- * restoration.</p>
3702
+ * <p><b>Note:</b> This method is automatically called after timer is over in UndoHelper
3703
+ * and after a restoration.</p>
3687
3704
*
3688
3705
* @since 3.0.0
3689
3706
*/
@@ -3697,7 +3714,7 @@ public synchronized void emptyBin() {
3697
3714
* @return true if the restore list is not empty, false otherwise
3698
3715
* @since 4.0.0
3699
3716
*/
3700
- public final boolean isRestoreInTime () {
3717
+ public synchronized final boolean isRestoreInTime () {
3701
3718
return mRestoreList != null && !mRestoreList .isEmpty ();
3702
3719
}
3703
3720
@@ -5386,13 +5403,14 @@ protected void onPreExecute() {
5386
5403
log .w ("Cannot filter while endlessLoading" );
5387
5404
this .cancel (true );
5388
5405
}
5389
- // Note: In case some items are in pending deletion (Undo started),
5390
- // we commit the deletion before starting or resetting the filter.
5391
- if (isRestoreInTime () && mDeleteCompleteListener != null ) {
5406
+ // Note: In case of some deleted items, we commit the deletion in the original list
5407
+ // and in the current list before starting or resetting the filter.
5408
+ if (isRestoreInTime ()) {
5392
5409
log .d ("Removing all deleted items before filtering/updating" );
5393
5410
newItems .removeAll (getDeletedItems ());
5394
- if (mOriginalList != null ) mOriginalList .removeAll (getDeletedItems ());
5395
- mDeleteCompleteListener .onDeleteConfirmed (3 ); // Snackbar.Callback.DISMISS_EVENT_MANUAL = 3
5411
+ if (mDeleteCompleteListener != null ) {
5412
+ mDeleteCompleteListener .onDeleteConfirmed (3 ); // Snackbar.Callback.DISMISS_EVENT_MANUAL = 3
5413
+ }
5396
5414
}
5397
5415
}
5398
5416
@@ -5487,8 +5505,9 @@ private void prepareItemsForUpdate(List<T> newItems) {
5487
5505
@ CallSuper
5488
5506
protected void onPostUpdate () {
5489
5507
// Call listener to update EmptyView, assuming the update always made a change
5490
- if (mUpdateListener != null )
5508
+ if (mUpdateListener != null ) {
5491
5509
mUpdateListener .onUpdateEmptyView (getMainItemCount ());
5510
+ }
5492
5511
}
5493
5512
5494
5513
/**
@@ -5500,8 +5519,9 @@ protected void onPostUpdate() {
5500
5519
@ CallSuper
5501
5520
protected void onPostFilter () {
5502
5521
// Call listener to update FilterView, assuming the filter always made a change
5503
- if (mFilterListener != null )
5522
+ if (mFilterListener != null ) {
5504
5523
mFilterListener .onUpdateFilterView (getMainItemCount ());
5524
+ }
5505
5525
}
5506
5526
5507
5527
/**
0 commit comments