-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java.util.ConcurrentModificationException with Undo after multiple rapid swipe removals #373
Comments
@gwailoTr0n5000, thanks for compliments and to notifying about this issue. Do you have the possibility to try the following fix inside the public SelectableAdapter() {
Log.i("FlexibleAdapter", "Running version " + BuildConfig.VERSION_NAME);
// We synchronize the Set
mSelectedPositions = Collections.synchronizedSet(new TreeSet<Integer>());
....
}
public void restoreDeletedItems() {
stopUndoTimer();
multiRange = true;
int initialCount = getItemCount();
// Selection coherence: start from a clear situation
// We avoid to clear selections if there aren't: swipe-to-delete hasn't (normally)
if (getSelectedItemCount() > 0) clearSelection();
...
} |
I'm looking at these two spots (that I believe are the methods you're thinking of.
|
The points are correct, but the current_snapshot branch has more commits than the published one because of a breaking change in If you check out this branch, you should reset the branch to this commit: d7c945a - 12/05/2017 at 00.01 - |
It seems that there may be a race condition or similar issue with multiple removals and then pressing "undo" on the snackbar if it coincides with the end of the timer before automated dismissal. I'm not able to easily replicate this but it has occurred about half a dozen times. It comes up most if I remove items quickly, then pause, then remove several more, then pause briefly, and click undo.
Error message:
05-25 12:52:41.784 21321-21321/com.SCME.GestureNotes E/SERVER_SYNC: outbound property change event: java.beans.PropertyChangeEvent[source=WebSocketManager{xxxxxxx #0 SERVER_DATA_SYNC}]
05-25 12:52:41.789 21321-21321/com.SCME.GestureNotes D/AndroidRuntime: Shutting down VM
05-25 12:52:41.789 21321-21321/com.SCME.GestureNotes E/AndroidRuntime: FATAL EXCEPTION:
main
Process: com.SCME.GestureNotes, PID: 21321
java.util.ConcurrentModificationException
at java.util.TreeMap$MapIterator.stepForward(TreeMap.java:883)
at java.util.TreeMap$KeySet$1.next(TreeMap.java:959)
at eu.davidea.flexibleadapter.SelectableAdapter.clearSelection(SelectableAdapter.java:426)
at eu.davidea.flexibleadapter.FlexibleAdapter.clearSelection(FlexibleAdapter.java:470)
at eu.davidea.flexibleadapter.FlexibleAdapter.restoreDeletedItems(FlexibleAdapter.java:3736)
at com.SCME.GestureNotes.Fragment.SingleExpandableRecyclerViewListFragment.onUndoConfirmed(SingleExpandableRecyclerViewListFragment.java:438)
at eu.davidea.flexibleadapter.helpers.UndoHelper$1.onClick(UndoHelper.java:165)
at android.support.design.widget.Snackbar$1.onClick(Snackbar.java:255)
at android.view.View.performClick(View.java:5721)
at android.widget.TextView.performClick(TextView.java:10930)
at android.view.View$PerformClick.run(View.java:22620)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Relevant code:
I can wrap in a try/catch at the very least but wanted to bring it to your attention in case there is a more robust approach you would like to include in the library or in case I've just missed something.
Thank you very much for your help! This is an AWESOME library! It has been a pleasure to build on top of this.
The text was updated successfully, but these errors were encountered: