use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project remusic by aa112901.
the class ArtistDetailActivity method onUpOrCancelMotionEvent.
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
mBaseTranslationY = 0;
Fragment fragment = getCurrentFragment();
if (fragment == null) {
return;
}
View view = fragment.getView();
if (view == null) {
return;
}
int toolbarHeight = mHeaderView.getHeight() - mActionBarSize - mStatusSize - tabLayout.getHeight();
final ObservableRecyclerView listView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
if (listView == null) {
return;
}
int scrollY = listView.getCurrentScrollY();
if (scrollState == ScrollState.DOWN) {
showToolbar();
} else if (scrollState == ScrollState.UP) {
if (toolbarHeight <= scrollY) {
hideToolbar();
} else {
showToolbar();
}
} else {
// Even if onScrollChanged occurs without scrollY changing, toolbar should be adjusted
if (toolbarIsShown() || toolbarIsHidden()) {
// Toolbar is completely moved, so just keep its state
// and propagate it to other pages
propagateToolbarState(toolbarIsShown());
} else {
// Toolbar is moving but doesn't know which to move:
// you can change this to hideToolbar()
showToolbar();
}
}
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project remusic by aa112901.
the class ArtistDetailActivity method propagateToolbarState.
private void propagateToolbarState(boolean isShown) {
int toolbarHeight = mHeaderView.getHeight() - mActionBarSize - mStatusSize - tabLayout.getHeight();
// Set scrollY for the fragments that are not created yet
mPagerAdapter.setScrollY(isShown ? 0 : toolbarHeight);
// Set scrollY for the active fragments
for (int i = 0; i < mPagerAdapter.getCount(); i++) {
// Skip current item
if (i == mPager.getCurrentItem()) {
continue;
}
// Skip destroyed or not created item
Fragment f = mPagerAdapter.getItemAt(i);
if (f == null) {
continue;
}
View view = f.getView();
if (view == null) {
continue;
}
ObservableRecyclerView listView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
if (listView == null) {
continue;
}
if (isShown) {
// Scroll up
if (0 < listView.getCurrentScrollY()) {
listView.scrollVerticallyToPosition(0);
}
} else {
// Scroll down (to hide padding)
if (listView.getCurrentScrollY() < toolbarHeight) {
listView.scrollVerticallyToPosition(1);
}
}
}
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class RecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recyclerview);
ObservableRecyclerView recyclerView = (ObservableRecyclerView) findViewById(R.id.scrollable);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
recyclerView.setScrollViewCallbacks(this);
UiTestUtils.setDummyData(this, recyclerView);
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class FillGapRecyclerViewActivity method createScrollable.
@Override
protected ObservableRecyclerView createScrollable() {
ObservableRecyclerView recyclerView = (ObservableRecyclerView) findViewById(R.id.scroll);
recyclerView.setScrollViewCallbacks(this);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(false);
setDummyDataWithHeader(recyclerView, mFlexibleSpaceImageHeight);
return recyclerView;
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class FlexibleSpaceWithImageRecyclerViewFragment method updateFlexibleSpace.
@Override
protected void updateFlexibleSpace(int scrollY, View view) {
int flexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
View recyclerViewBackground = view.findViewById(R.id.list_background);
// Translate list background
ViewHelper.setTranslationY(recyclerViewBackground, Math.max(0, -scrollY + flexibleSpaceImageHeight));
// Also pass this event to parent Activity
FlexibleSpaceWithImageWithViewPagerTabActivity parentActivity = (FlexibleSpaceWithImageWithViewPagerTabActivity) getActivity();
if (parentActivity != null) {
parentActivity.onScrollChanged(scrollY, (ObservableRecyclerView) view.findViewById(R.id.scroll));
}
}
Aggregations