Skip to content

Instantly share code, notes, and snippets.

final Activity activity = this.getActivity();
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
activity.finish();
activity.overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
});
}
@bouhady
bouhady / RecyclerViewCrashWorkAroundAction.java
Last active July 19, 2017 09:44
This action should be called before and after each RecycleView update (NotifyDataChanged/Remove..)
private Action1<Boolean> rxRecycleSync = new Action1<Boolean>() {
Parcelable parcelable = null;
@Override
public void call(Boolean saveState) {
if (saveState)
parcelable = recyclerView.getLayoutManager().onSaveInstanceState();
else
recyclerView.getLayoutManager().onRestoreInstanceState(parcelable);
}
};