use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class ViewPagerTabFragmentRecyclerViewFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_recyclerview, container, false);
final ObservableRecyclerView recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setHasFixedSize(false);
setDummyData(recyclerView);
Fragment parentFragment = getParentFragment();
ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
if (viewGroup != null) {
recyclerView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
if (parentFragment instanceof ObservableScrollViewCallbacks) {
recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
}
}
return view;
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class ViewPagerTabRecyclerViewFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_recyclerview, container, false);
Activity parentActivity = getActivity();
final ObservableRecyclerView recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
recyclerView.setLayoutManager(new LinearLayoutManager(parentActivity));
recyclerView.setHasFixedSize(false);
View headerView = LayoutInflater.from(parentActivity).inflate(R.layout.padding, null);
setDummyDataWithHeader(recyclerView, headerView);
if (parentActivity instanceof ObservableScrollViewCallbacks) {
// Scroll to the specified offset after layout
Bundle args = getArguments();
if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
ScrollUtils.addOnGlobalLayoutListener(recyclerView, new Runnable() {
@Override
public void run() {
recyclerView.scrollVerticallyToPosition(initialPosition);
}
});
}
// TouchInterceptionViewGroup should be a parent view other than ViewPager.
// This is a workaround for the issue #117:
// https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
recyclerView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));
recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
}
return view;
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class FlexibleSpaceWithImageRecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_flexiblespacewithimagerecyclerview);
mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
mActionBarSize = getActionBarSize();
ObservableRecyclerView recyclerView = (ObservableRecyclerView) findViewById(R.id.recycler);
recyclerView.setScrollViewCallbacks(this);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(false);
final View headerView = LayoutInflater.from(this).inflate(R.layout.recycler_header, null);
headerView.post(new Runnable() {
@Override
public void run() {
headerView.getLayoutParams().height = mFlexibleSpaceImageHeight;
}
});
setDummyDataWithHeader(recyclerView, headerView);
mImageView = findViewById(R.id.image);
mOverlayView = findViewById(R.id.overlay);
mTitleView = (TextView) findViewById(R.id.title);
mTitleView.setText(getTitle());
setTitle(null);
// mRecyclerViewBackground makes RecyclerView's background except header view.
mRecyclerViewBackground = findViewById(R.id.list_background);
// since you cannot programmatically add a header view to a RecyclerView we added an empty view as the header
// in the adapter and then are shifting the views OnCreateView to compensate
final float scale = 1 + MAX_TEXT_SCALE_DELTA;
mRecyclerViewBackground.post(new Runnable() {
@Override
public void run() {
ViewHelper.setTranslationY(mRecyclerViewBackground, mFlexibleSpaceImageHeight);
}
});
ViewHelper.setTranslationY(mOverlayView, mFlexibleSpaceImageHeight);
mTitleView.post(new Runnable() {
@Override
public void run() {
ViewHelper.setTranslationY(mTitleView, (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale));
ViewHelper.setPivotX(mTitleView, 0);
ViewHelper.setPivotY(mTitleView, 0);
ViewHelper.setScaleX(mTitleView, scale);
ViewHelper.setScaleY(mTitleView, scale);
}
});
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class StickyHeaderRecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_stickyheaderrecyclerview);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
mHeaderView = findViewById(R.id.header);
ViewCompat.setElevation(mHeaderView, getResources().getDimension(R.dimen.toolbar_elevation));
mToolbarView = findViewById(R.id.toolbar);
mRecyclerView = (ObservableRecyclerView) findViewById(R.id.recycler);
mRecyclerView.setScrollViewCallbacks(this);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(false);
View headerView = LayoutInflater.from(this).inflate(R.layout.recycler_header, null);
setDummyDataWithHeader(mRecyclerView, headerView);
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class ViewPagerTab2RecyclerViewFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_recyclerview, container, false);
Activity parentActivity = getActivity();
final ObservableRecyclerView recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
recyclerView.setLayoutManager(new LinearLayoutManager(parentActivity));
recyclerView.setHasFixedSize(false);
setDummyData(recyclerView);
recyclerView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));
if (parentActivity instanceof ObservableScrollViewCallbacks) {
recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
}
return view;
}
Aggregations