Search in sources :

Example 1 with ObservableRecyclerView

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();
        }
    }
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) ArtistInfoFragment(com.wm.remusic.fragmentnet.ArtistInfoFragment) ArtistInfoMusicFragment(com.wm.remusic.fragmentnet.ArtistInfoMusicFragment) Fragment(android.support.v4.app.Fragment) ImageView(android.widget.ImageView) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) TextView(android.widget.TextView)

Example 2 with ObservableRecyclerView

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);
            }
        }
    }
}
Also used : ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) ArtistInfoFragment(com.wm.remusic.fragmentnet.ArtistInfoFragment) ArtistInfoMusicFragment(com.wm.remusic.fragmentnet.ArtistInfoMusicFragment) Fragment(android.support.v4.app.Fragment) ImageView(android.widget.ImageView) ObservableRecyclerView(com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) TextView(android.widget.TextView)

Example 3 with ObservableRecyclerView

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

Example 4 with ObservableRecyclerView

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

Example 5 with ObservableRecyclerView

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));
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) 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