Skip to content

Instantly share code, notes, and snippets.

@mzgreen
Created February 28, 2015 08:26
Show Gist options
  • Save mzgreen/29359ccda3b5e1c68093 to your computer and use it in GitHub Desktop.
Save mzgreen/29359ccda3b5e1c68093 to your computer and use it in GitHub Desktop.
PartTwoActivity class onShow and onHide implementation
private void initRecyclerView() {
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
RecyclerAdapter recyclerAdapter = new RecyclerAdapter(createItemList());
recyclerView.setAdapter(recyclerAdapter);
recyclerView.setOnScrollListener(new HidingScrollListener(this) {
@Override
public void onMoved(int distance) {
mToolbarContainer.setTranslationY(-distance);
}
@Override
public void onShow() {
mToolbarContainer.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
}
@Override
public void onHide() {
mToolbarContainer.animate().translationY(-mToolbarHeight).setInterpolator(new AccelerateInterpolator(2)).start();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment