com.hippo.easyrecyclerview.FastScroller Java Examples

The following examples show how to use com.hippo.easyrecyclerview.FastScroller. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentLayout.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    LayoutInflater.from(context).inflate(R.layout.widget_content_layout, this);

    mProgressView = (ProgressView) findViewById(R.id.progress);
    mTipView = (TextView) findViewById(R.id.tip);
    mContentView = (ViewGroup) findViewById(R.id.content_view);

    mRefreshLayout = (RefreshLayout) mContentView.findViewById(R.id.refresh_layout);
    mFastScroller = (FastScroller) mContentView.findViewById(R.id.fast_scroller);
    mRecyclerView = (EasyRecyclerView) mRefreshLayout.findViewById(R.id.recycler_view);

    mFastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable drawable = new HandlerDrawable();
    drawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    mFastScroller.setHandlerDrawable(drawable);

    mRefreshLayout.setHeaderColorSchemeResources(
            R.color.loading_indicator_red,
            R.color.loading_indicator_purple,
            R.color.loading_indicator_blue,
            R.color.loading_indicator_cyan,
            R.color.loading_indicator_green,
            R.color.loading_indicator_yellow);
    mRefreshLayout.setFooterColorSchemeResources(
            R.color.loading_indicator_red,
            R.color.loading_indicator_blue,
            R.color.loading_indicator_green,
            R.color.loading_indicator_orange);

    mRecyclerViewOriginTop = mRecyclerView.getPaddingTop();
    mRecyclerViewOriginBottom = mRecyclerView.getPaddingBottom();
}
 
Example #2
Source File: FavoritesScene.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
@Override
@Implemented(FastScroller.OnDragHandlerListener.class)
public void onEndDragHandler() {
    // Restore right drawer
    if (null != mRecyclerView && !mRecyclerView.isInCustomChoice()) {
        setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
    }

    if (mSearchBarMover != null) {
        mSearchBarMover.returnSearchBarPosition();
    }
}
 
Example #3
Source File: ContentLayout.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    LayoutInflater.from(context).inflate(R.layout.widget_content_layout, this);

    mProgressView = (ProgressView) findViewById(R.id.progress);
    mTipView = (TextView) findViewById(R.id.tip);
    mContentView = (ViewGroup) findViewById(R.id.content_view);

    mRefreshLayout = (RefreshLayout) mContentView.findViewById(R.id.refresh_layout);
    mFastScroller = (FastScroller) mContentView.findViewById(R.id.fast_scroller);
    mRecyclerView = (EasyRecyclerView) mRefreshLayout.findViewById(R.id.recycler_view);

    mFastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable drawable = new HandlerDrawable();
    drawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    mFastScroller.setHandlerDrawable(drawable);

    mRefreshLayout.setHeaderColorSchemeResources(
            R.color.loading_indicator_red,
            R.color.loading_indicator_purple,
            R.color.loading_indicator_blue,
            R.color.loading_indicator_cyan,
            R.color.loading_indicator_green,
            R.color.loading_indicator_yellow);
    mRefreshLayout.setFooterColorSchemeResources(
            R.color.loading_indicator_red,
            R.color.loading_indicator_blue,
            R.color.loading_indicator_green,
            R.color.loading_indicator_orange);

    mRecyclerViewOriginTop = mRecyclerView.getPaddingTop();
    mRecyclerViewOriginBottom = mRecyclerView.getPaddingBottom();
}
 
Example #4
Source File: FavoritesScene.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@Override
@Implemented(FastScroller.OnDragHandlerListener.class)
public void onEndDragHandler() {
    // Restore right drawer
    if (null != mRecyclerView && !mRecyclerView.isInCustomChoice()) {
        setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
    }

    if (mSearchBarMover != null) {
        mSearchBarMover.returnSearchBarPosition();
    }
}
 
Example #5
Source File: ContentLayout.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    LayoutInflater.from(context).inflate(R.layout.widget_content_layout, this);

    mProgressView = (ProgressView) findViewById(R.id.progress);
    mTipView = (ViewGroup) findViewById(R.id.tip);
    mContentView = (ViewGroup) findViewById(R.id.content_view);

    mRefreshLayout = (RefreshLayout) mContentView.findViewById(R.id.refresh_layout);
    mFastScroller = (FastScroller) mContentView.findViewById(R.id.fast_scroller);
    mRecyclerView = (EasyRecyclerView) mRefreshLayout.findViewById(R.id.recycler_view);
    mImageView = mTipView.getChildAt(0);
    mTextView = (TextView) mTipView.getChildAt(1);

    mFastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable drawable = new HandlerDrawable();
    drawable.setColor(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
    mFastScroller.setHandlerDrawable(drawable);

    mRefreshLayout.setHeaderColorSchemeResources(
            R.color.loading_indicator_red,
            R.color.loading_indicator_purple,
            R.color.loading_indicator_blue,
            R.color.loading_indicator_cyan,
            R.color.loading_indicator_green,
            R.color.loading_indicator_yellow);
    mRefreshLayout.setFooterColorSchemeResources(
            R.color.loading_indicator_red,
            R.color.loading_indicator_blue,
            R.color.loading_indicator_green,
            R.color.loading_indicator_orange);
    mRefreshLayout.setHeaderProgressBackgroundColorSchemeColor(ResourcesUtils.getAttrColor(context, R.attr.colorPure));

    mRecyclerViewOriginTop = mRecyclerView.getPaddingTop();
    mRecyclerViewOriginBottom = mRecyclerView.getPaddingBottom();
}
 
Example #6
Source File: ContentLayout.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
public FastScroller getFastScroller() {
    return mFastScroller;
}
 
Example #7
Source File: GalleryListScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container,
                          @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_list, container, false);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();

    mHideActionFabSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mShowActionFab = true;

    View mainLayout = ViewUtils.$$(view, R.id.main_layout);
    ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mainLayout, R.id.content_layout);
    mRecyclerView = contentLayout.getRecyclerView();
    FastScroller fastScroller = contentLayout.getFastScroller();
    RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
    mSearchLayout = (SearchLayout) ViewUtils.$$(mainLayout, R.id.search_layout);
    mSearchBar = (SearchBar) ViewUtils.$$(mainLayout, R.id.search_bar);
    mFabLayout = (FabLayout) ViewUtils.$$(mainLayout, R.id.fab_layout);
    mSearchFab = ViewUtils.$$(mainLayout, R.id.search_fab);

    int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);

    mViewTransition = new ViewTransition(contentLayout, mSearchLayout);

    mHelper = new GalleryListHelper();
    contentLayout.setHelper(mHelper);
    contentLayout.getFastScroller().setOnDragHandlerListener(this);

    mAdapter = new GalleryListAdapter(inflater, resources,
            mRecyclerView, Settings.getListMode());
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.addOnScrollListener(mOnScrollListener);

    fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
            fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());

    refreshLayout.setHeaderTranslationY(paddingTopSB);

    mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mRightDrawable = new AddDeleteDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary), null);
    mSearchBar.setLeftDrawable(mLeftDrawable);
    mSearchBar.setRightDrawable(mRightDrawable);
    mSearchBar.setHelper(this);
    mSearchBar.setOnStateChangeListener(this);
    setSearchBarHint(context, mSearchBar);
    setSearchBarSuggestionProvider(mSearchBar);

    mSearchLayout.setHelper(this);
    mSearchLayout.setPadding(mSearchLayout.getPaddingLeft(), mSearchLayout.getPaddingTop() + paddingTopSB,
            mSearchLayout.getPaddingRight(), mSearchLayout.getPaddingBottom() + paddingBottomFab);

    mSourceBar = (RadioGroup) ViewUtils.$$(mainLayout, R.id.source_bar);
    bindSource(mSourceBar);
    mFabLayout.setAutoCancel(true);
    mFabLayout.setExpanded(false);
    mFabLayout.setHidePrimaryFab(false);
    mFabLayout.setOnClickFabListener(this);
    mFabLayout.setOnExpandListener(this);
    addAboveSnackView(mFabLayout);

    mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark), currentSource);
    mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);

    mSearchFab.setOnClickListener(this);

    mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView, mSearchLayout);

    // Update list url builder
    onUpdateUrlBuilder();

    // Restore state
    int newState = mState;
    mState = STATE_NORMAL;
    setState(newState, false);

    // Only refresh for the first time
    if (!mHasFirstRefresh) {
        mHasFirstRefresh = true;
        mHelper.firstRefresh();
    }

    guideQuickSearch();
    return view;
}
 
Example #8
Source File: DownloadsScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_download, container, false);

    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);

    Context context = getContext2();
    AssertUtils.assertNotNull(content);
    Resources resources = context.getResources();

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_download);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    mAdapter = new DownloadAdapter();
    mAdapter.setHasStableIds(true);
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
    mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(new DownloadChoiceListener());
    // Cancel change animation
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    if (mInitPosition >= 0) {
        mRecyclerView.scrollToPosition(mInitPosition);
        mInitPosition = -1;
    }

    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);
    fastScroller.setOnDragHandlerListener(this);

    mFabLayout.setExpanded(false, false);
    mFabLayout.setHidePrimaryFab(true);
    mFabLayout.setAutoCancel(false);
    mFabLayout.setOnClickFabListener(this);
    addAboveSnackView(mFabLayout);

    updateView();

    guide();

    return view;
}
 
Example #9
Source File: HistoryScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_history, container, false);
    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_history);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
    guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    guardManager.setEnabled(true);
    RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
    mAdapter = new HistoryAdapter();
    mAdapter.setHasStableIds(true);
    mAdapter = swipeManager.createWrappedAdapter(mAdapter);
    mRecyclerView.setAdapter(mAdapter);
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    animator.setSupportsChangeAnimations(false);
    mRecyclerView.setItemAnimator(animator);
    AutoStaggeredGridLayoutManager layoutManager = new AutoStaggeredGridLayoutManager(
            0, StaggeredGridLayoutManager.VERTICAL);
    layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    guardManager.attachRecyclerView(mRecyclerView);
    swipeManager.attachRecyclerView(mRecyclerView);

    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);

    updateLazyList();
    updateView(false);

    return view;
}
 
Example #10
Source File: FavoritesScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Override
@Implemented(FastScroller.OnDragHandlerListener.class)
public void onStartDragHandler() {
    // Lock right drawer
    setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
}
 
Example #11
Source File: FavoritesScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_favorites, container, false);
    ContentLayout contentLayout = (ContentLayout) view.findViewById(R.id.content_layout);
    MainActivity activity = getActivity2();
    AssertUtils.assertNotNull(activity);
    mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(activity, R.id.draw_view);
    mRecyclerView = contentLayout.getRecyclerView();
    FastScroller fastScroller = contentLayout.getFastScroller();
    RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
    mSearchBar = (SearchBar) ViewUtils.$$(view, R.id.search_bar);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);

    mHelper = new FavoritesHelper();
    mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit));
    contentLayout.setHelper(mHelper);
    contentLayout.getFastScroller().setOnDragHandlerListener(this);

    mAdapter = new FavoritesAdapter(inflater, resources, mRecyclerView, Settings.getListMode());
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(this);

    fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
            fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());

    refreshLayout.setHeaderTranslationY(paddingTopSB);

    mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mSearchBar.setLeftDrawable(mLeftDrawable);
    mSearchBar.setRightDrawable(DrawableManager.getVectorDrawable(context, R.drawable.v_magnify_x24));
    mSearchBar.setHelper(this);
    mSearchBar.setAllowEmptySearch(false);
    updateSearchBar();
    mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView);

    mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark));
    mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
    mFabLayout.setExpanded(false, false);
    mFabLayout.setAutoCancel(true);
    mFabLayout.setHidePrimaryFab(false);
    mFabLayout.setOnClickFabListener(this);
    mFabLayout.setOnExpandListener(this);
    addAboveSnackView(mFabLayout);

    // Restore search mode
    if (mSearchMode) {
        mSearchMode = false;
        enterSearchMode(false);
    }

    // Only refresh for the first time
    if (!mHasFirstRefresh) {
        mHasFirstRefresh = true;
        mHelper.firstRefresh();
    }

    guideCollections();

    return view;
}
 
Example #12
Source File: GalleryListScene.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_list, container, false);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();

    mHideActionFabSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mShowActionFab = true;

    View mainLayout = ViewUtils.$$(view, R.id.main_layout);
    ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mainLayout, R.id.content_layout);
    mRecyclerView = contentLayout.getRecyclerView();
    FastScroller fastScroller = contentLayout.getFastScroller();
    RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
    mSearchLayout = (SearchLayout) ViewUtils.$$(mainLayout, R.id.search_layout);
    mSearchBar = (SearchBar) ViewUtils.$$(mainLayout, R.id.search_bar);
    mFabLayout = (FabLayout) ViewUtils.$$(mainLayout, R.id.fab_layout);
    mSearchFab = ViewUtils.$$(mainLayout, R.id.search_fab);

    int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);

    mViewTransition = new ViewTransition(contentLayout, mSearchLayout);

    mHelper = new GalleryListHelper();
    contentLayout.setHelper(mHelper);
    contentLayout.getFastScroller().setOnDragHandlerListener(this);

    mAdapter = new GalleryListAdapter(inflater, resources,
            mRecyclerView, Settings.getListMode());
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.addOnScrollListener(mOnScrollListener);

    fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
            fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());

    refreshLayout.setHeaderTranslationY(paddingTopSB);

    mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mRightDrawable = new AddDeleteDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mSearchBar.setLeftDrawable(mLeftDrawable);
    mSearchBar.setRightDrawable(mRightDrawable);
    mSearchBar.setHelper(this);
    mSearchBar.setOnStateChangeListener(this);
    setSearchBarHint(context, mSearchBar);
    setSearchBarSuggestionProvider(mSearchBar);

    mSearchLayout.setHelper(this);
    mSearchLayout.setPadding(mSearchLayout.getPaddingLeft(), mSearchLayout.getPaddingTop() + paddingTopSB,
            mSearchLayout.getPaddingRight(), mSearchLayout.getPaddingBottom() + paddingBottomFab);

    mFabLayout.setAutoCancel(true);
    mFabLayout.setExpanded(false);
    mFabLayout.setHidePrimaryFab(false);
    mFabLayout.setOnClickFabListener(this);
    mFabLayout.setOnExpandListener(this);
    addAboveSnackView(mFabLayout);

    mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark));
    mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);

    mSearchFab.setOnClickListener(this);

    mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView, mSearchLayout);

    // Update list url builder
    onUpdateUrlBuilder();

    // Restore state
    int newState = mState;
    mState = STATE_NORMAL;
    setState(newState, false);

    // Only refresh for the first time
    if (!mHasFirstRefresh) {
        mHasFirstRefresh = true;
        mHelper.firstRefresh();
    }

    guideQuickSearch();

    return view;
}
 
Example #13
Source File: ContentLayout.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
public FastScroller getFastScroller() {
    return mFastScroller;
}
 
Example #14
Source File: DownloadsScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_download, container, false);

    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);

    Context context = getContext2();
    AssertUtils.assertNotNull(content);
    Resources resources = context.getResources();

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_download);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    mAdapter = new DownloadAdapter();
    mAdapter.setHasStableIds(true);
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
    mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(new DownloadChoiceListener());
    // Cancel change animation
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    if (mInitPosition >= 0) {
        mRecyclerView.scrollToPosition(mInitPosition);
        mInitPosition = -1;
    }

    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);
    fastScroller.setOnDragHandlerListener(this);

    mFabLayout.setExpanded(false, false);
    mFabLayout.setHidePrimaryFab(true);
    mFabLayout.setAutoCancel(false);
    mFabLayout.setOnClickFabListener(this);
    addAboveSnackView(mFabLayout);

    updateView();

    guide();

    return view;
}
 
Example #15
Source File: HistoryScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
                          @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_history, container, false);
    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();

    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_history);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);

    RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
    guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    guardManager.setEnabled(true);
    RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
    mAdapter = new HistoryAdapter();
    mAdapter.setHasStableIds(true);
    mAdapter = swipeManager.createWrappedAdapter(mAdapter);
    mRecyclerView.setAdapter(mAdapter);
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    animator.setSupportsChangeAnimations(false);
    mRecyclerView.setItemAnimator(animator);
    AutoStaggeredGridLayoutManager layoutManager = new AutoStaggeredGridLayoutManager(
            0, StaggeredGridLayoutManager.VERTICAL);
    layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    guardManager.attachRecyclerView(mRecyclerView);
    swipeManager.attachRecyclerView(mRecyclerView);

    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(AttrResources.getAttrColor(context, R.attr.widgetColorThemeAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);

    updateLazyList();
    updateView(false);

    return view;
}
 
Example #16
Source File: FavoritesScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Override
@Implemented(FastScroller.OnDragHandlerListener.class)
public void onStartDragHandler() {
    // Lock right drawer
    setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
}
 
Example #17
Source File: FavoritesScene.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView2(LayoutInflater inflater,
                          @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_favorites, container, false);
    ContentLayout contentLayout = (ContentLayout) view.findViewById(R.id.content_layout);
    MainActivity activity = getActivity2();
    AssertUtils.assertNotNull(activity);
    mDrawerLayout = (EhDrawerLayout) ViewUtils.$$(activity, R.id.draw_view);
    mRecyclerView = contentLayout.getRecyclerView();
    FastScroller fastScroller = contentLayout.getFastScroller();
    RefreshLayout refreshLayout = contentLayout.getRefreshLayout();
    mSearchBar = (SearchBar) ViewUtils.$$(view, R.id.search_bar);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);

    mHelper = new FavoritesHelper();
    mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit));
    contentLayout.setHelper(mHelper);
    contentLayout.getFastScroller().setOnDragHandlerListener(this);

    mAdapter = new FavoritesAdapter(inflater, resources, mRecyclerView, Settings.getListMode());
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(this);

    fastScroller.setPadding(fastScroller.getPaddingLeft(), fastScroller.getPaddingTop() + paddingTopSB,
            fastScroller.getPaddingRight(), fastScroller.getPaddingBottom());

    refreshLayout.setHeaderTranslationY(paddingTopSB);
    refreshLayout.setOnRefreshListener(this);
    mLeftDrawable = new DrawerArrowDrawable(context, AttrResources.getAttrColor(context, R.attr.drawableColorPrimary));
    mSearchBar.setLeftDrawable(mLeftDrawable);
    mSearchBar.setRightDrawable(DrawableManager.getVectorDrawable(context, R.drawable.v_magnify_x24));
    mSearchBar.setHelper(this);
    mSearchBar.setAllowEmptySearch(false);
    updateSearchBar();
    mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView);
    mSourceBar = (RadioGroup) ViewUtils.$$(view, R.id.source_bar);
    bindSource(mSourceBar);
    mFabLayout.setAutoCancel(true);
    mFabLayout.setExpanded(false);
    mFabLayout.setHidePrimaryFab(false);
    mFabLayout.setOnClickFabListener(this);
    mFabLayout.setOnExpandListener(this);
    mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark), currentSource);
    mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
    mHideActionFabSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mRecyclerView.addOnScrollListener(mOnScrollListener);
    addAboveSnackView(mFabLayout);

    // Restore search mode
    if (mSearchMode) {
        mSearchMode = false;
        enterSearchMode(false);
    }

    // Only refresh for the first time
    if (!mHasFirstRefresh) {
        mHasFirstRefresh = true;
        mHelper.firstRefresh();
    }

    guideCollections();

    Intent service = new Intent(context, CheckUpdateService.class);
    context.bindService(service, mConnection, Context.BIND_AUTO_CREATE);
    return view;
}