Search in sources :

Example 26 with ObservableRecyclerView

use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.

the class ScrollFromBottomRecyclerViewActivity 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);
    ScrollUtils.addOnGlobalLayoutListener(mRecyclerView, new Runnable() {

        @Override
        public void run() {
            int count = mRecyclerView.getAdapter().getItemCount() - 1;
            int position = count == 0 ? 1 : count > 0 ? count : 0;
            mRecyclerView.scrollToPosition(position);
        }
    });
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) View(android.view.View)

Example 27 with ObservableRecyclerView

use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.

the class SlidingUpRecyclerViewActivity method createScrollable.

@Override
protected ObservableRecyclerView createScrollable() {
    ObservableRecyclerView recyclerView = (ObservableRecyclerView) findViewById(R.id.scroll);
    recyclerView.setScrollViewCallbacks(this);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(new CustomAdapter(this, getDummyData()));
    return recyclerView;
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

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