I made a good Adapter for My RecycleView using Place.java provide by google. I setup a drang and drop and swipe to dismiss. Using Adapter for recycleview, when user swipe some row this happends:
@Override
public void onItemDismiss(int position) {
Place place = mList.get(position);
Realm r = Realm.getDefaultInstance();
r.beginTransaction();
mList.remove(position);
r.commitTransaction();
notifyItemRemoved(position);
//mListener.onPlaceDeleted(place,position);
}
This cose cause Exception if remove comment in last line. Last line help me to notify activity a delete-action, so I can show simple Snackbar which advise user for "xxx place deleted", and it provide simple action inside snackbar to previus state, and store again Realm object. I was thinking that mList.remove (this is an ArrayList) will not cause real delete from realm.
I use same adapter, same listener, same architecture for my custom object which is not a Realm object and all works fine.