Prevent multiple registrations to eventHub on same TimelineFragment (#879)

This commit is contained in:
kyori19 2018-10-16 02:47:50 +09:00 committed by Konrad Pozniak
parent 25c3defd33
commit 1556a88d05

View file

@ -119,6 +119,7 @@ public class TimelineFragment extends SFragment implements
public TimelineCases timelineCases; public TimelineCases timelineCases;
@Inject @Inject
public EventHub eventHub; public EventHub eventHub;
private boolean eventRegistered = false;
private SwipeRefreshLayout swipeRefreshLayout; private SwipeRefreshLayout swipeRefreshLayout;
private RecyclerView recyclerView; private RecyclerView recyclerView;
@ -378,6 +379,7 @@ public class TimelineFragment extends SFragment implements
} }
recyclerView.addOnScrollListener(scrollListener); recyclerView.addOnScrollListener(scrollListener);
if (!eventRegistered) {
eventHub.getEvents() eventHub.getEvents()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY))) .as(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY)))
@ -413,6 +415,8 @@ public class TimelineFragment extends SFragment implements
handleStatusComposeEvent(status); handleStatusComposeEvent(status);
} }
}); });
eventRegistered = true;
}
} }
@Override @Override