我正在尝试使用Parse创建一种最喜欢的机制。问题是,当我按addToFavIcon时,我收到一个ConcurrentModificationException,但我不知道它从哪里来。这是在关系中添加和删除的功能:
public void removeFavInParse(final Product model, final FavoriteViewHolder holder) {
if (MainApplication.getInstance().isDeviceConnectedToInternet()) {
if (ParseUser.getCurrentUser() != null) {
ParseQuery<ParseObject> tiles = ParseQuery.getQuery(Config.PRODUCT_TABLE);
tiles.getInBackground(model.getId(), new GetCallback<ParseObject>() {
@Override
public void done(final ParseObject object, ParseException e) {
ParseRelation<ParseUser> user = object.getRelation(Config.PRODUCT_WISH_USERS);
user.remove(ParseUser.getCurrentUser());
object.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
final ParseUser user = ParseUser.getCurrentUser();
final ParseRelation<ParseObject> tile = user.getRelation(Config.WISHED_POSTS);
tile.remove(object);
user.saveInBackground();
}
});
}
});
}
}
}
这是错误代码:
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:787)
at java.util.HashMap$KeyIterator.next(HashMap.java:814)
at com.parse.ParseRelationOperation.removeParseObjectFromSet(ParseRelationOperation.java:124)
at com.parse.ParseRelationOperation.removeAllParseObjectsFromSet(ParseRelationOperation.java:136)
at com.parse.ParseRelationOperation.mergeWithPrevious(ParseRelationOperation.java:244)
at com.parse.ParseObject.performOperation(ParseObject.java:2966)
at com.parse.ParseRelation.remove(ParseRelation.java:145)
at com.peppersoft.dragonulex.adapters.FavoritesAdapter$4$1.done(FavoritesAdapter.java:169)
at com.peppersoft.dragonulex.adapters.FavoritesAdapter$4$1.done(FavoritesAdapter.java:164)
at com.parse.ParseTaskUtils$1.done(ParseTaskUtils.java:75)
at com.parse.ParseTaskUtils$1.done(ParseTaskUtils.java:72)
at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:116)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
任何人都可以减轻我的思想吗?