Skip to content

Commit

Permalink
Auto Refresh Posts when User Makes a New Post
Browse files Browse the repository at this point in the history
Summary:
FbBroadcastManager.ReceiverBuilder will receive the corresponding broadcast from composer when user publishes a new post.
onReceive(Context context, Intent intent, BroadcastReceiverLike receiver) will be called after the post mutation is done, then we are safe to call mRecyclerCollectionEventsController.requestRefresh( to refresh the page. Later, mRecyclerCollectionEventsController.requestScrollToTop(true) when the load succeeded inside of LoadEventsHandler.

Differential Revision: D6517905

fbshipit-source-id: 2a8da0a8c60392e7d1b7f3bed72de7fe1fd2e5e8
  • Loading branch information
Chloe Shen authored and facebook-github-bot committed Jan 12, 2018
1 parent 4c67a38 commit 2dc2ec1
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,30 @@ public void requestScrollToTop(boolean animated) {

/**
* Send the Recycler a request to scroll the content to a specific item in the binder.
*
* @param animated if animated is set to true the scroll will happen with an animation.
*/
public void requestScrollToPosition(int position, boolean animated) {
if (mRecyclerViewWrapper != null) {
if (animated) {
mRecyclerViewWrapper.getRecyclerView().smoothScrollToPosition(position);
} else {
mRecyclerViewWrapper.getRecyclerView().scrollToPosition(position);
}
public void requestScrollToPosition(final int position, final boolean animated) {
if (mRecyclerViewWrapper == null) {
return;
}

mRecyclerViewWrapper.post(
new Runnable() {
@Override
public void run() {
if (mRecyclerViewWrapper == null) {
return;
}

if (animated) {
mRecyclerViewWrapper.getRecyclerView().smoothScrollToPosition(position);
return;
}

mRecyclerViewWrapper.getRecyclerView().scrollToPosition(position);
}
});
}

public void clearRefreshing() {
Expand Down

0 comments on commit 2dc2ec1

Please sign in to comment.