Search in sources :

Example 11 with ObservableRecyclerView

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;
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) ViewGroup(android.view.ViewGroup) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) View(android.view.View) Fragment(android.support.v4.app.Fragment)

Example 12 with ObservableRecyclerView

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;
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) Bundle(android.os.Bundle) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) View(android.view.View)

Example 13 with ObservableRecyclerView

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);
        }
    });
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) TextView(android.widget.TextView) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) View(android.view.View)

Example 14 with ObservableRecyclerView

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);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) View(android.view.View)

Example 15 with ObservableRecyclerView

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;
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) View(android.view.View)

Aggregations

ObservableRecyclerView (com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView)27 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)23 View (android.view.View)16 ObservableScrollViewCallbacks (com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks)6 Activity (android.app.Activity)5 TextView (android.widget.TextView)5 Bundle (android.os.Bundle)4 RecyclerView (android.support.v7.widget.RecyclerView)4 Fragment (android.support.v4.app.Fragment)3 ImageView (android.widget.ImageView)3 ArrayList (java.util.ArrayList)3 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)2 ArtistInfoFragment (com.wm.remusic.fragmentnet.ArtistInfoFragment)2 ArtistInfoMusicFragment (com.wm.remusic.fragmentnet.ArtistInfoMusicFragment)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 ViewGroup (android.view.ViewGroup)1 ViewTreeObserver (android.view.ViewTreeObserver)1 LinearLayout (android.widget.LinearLayout)1 TintImageView (com.bilibili.magicasakura.widgets.TintImageView)1