Search in sources :

Example 26 with ObservableScrollViewCallbacks

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks in project remusic by aa112901.

the class ArtistInfoMusicFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_recyclerview, container, false);
    if (getArguments() != null) {
        mList = getArguments().getParcelableArrayList("list");
    }
    Activity parentActivity = getActivity();
    recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
    recyclerView.setHasFixedSize(true);
    mAdapter = new PlaylistDetailAdapter(getActivity(), mList);
    recyclerView.setAdapter(mAdapter);
    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(0);
                }
            });
        }
        // 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 : Bundle(android.os.Bundle) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) TintImageView(com.bilibili.magicasakura.widgets.TintImageView) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Aggregations

View (android.view.View)26 ObservableScrollViewCallbacks (com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks)26 Activity (android.app.Activity)21 Bundle (android.os.Bundle)11 ObservableScrollView (com.github.ksoichiro.android.observablescrollview.ObservableScrollView)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 ObservableListView (com.github.ksoichiro.android.observablescrollview.ObservableListView)6 ObservableRecyclerView (com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView)6 Fragment (android.support.v4.app.Fragment)5 ViewGroup (android.view.ViewGroup)5 ObservableGridView (com.github.ksoichiro.android.observablescrollview.ObservableGridView)4 ObservableWebView (com.github.ksoichiro.android.observablescrollview.ObservableWebView)3 ViewTreeObserver (android.view.ViewTreeObserver)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 RecyclerView (android.support.v7.widget.RecyclerView)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 TintImageView (com.bilibili.magicasakura.widgets.TintImageView)1 ArrayList (java.util.ArrayList)1