Search in sources :

Example 1 with EasyRecyclerView

use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.

the class HistoryScene method onCreateView3.

@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();
    Assert.assertNotNull(context);
    Resources resources = context.getResources();
    Drawable drawable = DrawableManager.getDrawable(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, false));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.hasFixedSize();
    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(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);
    updateLazyList();
    updateView(false);
    return view;
}
Also used : Context(android.content.Context) RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) ViewTransition(com.hippo.view.ViewTransition) HandlerDrawable(com.hippo.easyrecyclerview.HandlerDrawable) Drawable(android.graphics.drawable.Drawable) FastScroller(com.hippo.easyrecyclerview.FastScroller) MarginItemDecoration(com.hippo.easyrecyclerview.MarginItemDecoration) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) View(android.view.View) SimpleRatingView(com.hippo.ehviewer.widget.SimpleRatingView) LoadImageView(com.hippo.widget.LoadImageView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) AutoStaggeredGridLayoutManager(com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) TextView(android.widget.TextView) Resources(android.content.res.Resources) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) HandlerDrawable(com.hippo.easyrecyclerview.HandlerDrawable) Nullable(android.support.annotation.Nullable)

Example 2 with EasyRecyclerView

use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.

the class QuickSearchScene method onCreateView3.

@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_label_list, container, false);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(mRecyclerView, tip);
    Context context = getContext2();
    Assert.assertNotNull(context);
    Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_search);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);
    tip.setText(R.string.no_quick_search);
    // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss animation is running)
    RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
    guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    guardManager.setEnabled(true);
    // drag & drop manager
    RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager();
    dragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_8dp));
    // swipe manager
    RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
    RecyclerView.Adapter adapter = new QuickSearchAdapter();
    adapter.setHasStableIds(true);
    // wrap for dragging
    adapter = dragDropManager.createWrappedAdapter(adapter);
    // wrap for swiping
    adapter = swipeManager.createWrappedAdapter(adapter);
    mAdapter = adapter;
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    animator.setSupportsChangeAnimations(false);
    mRecyclerView.hasFixedSize();
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setItemAnimator(animator);
    guardManager.attachRecyclerView(mRecyclerView);
    swipeManager.attachRecyclerView(mRecyclerView);
    dragDropManager.attachRecyclerView(mRecyclerView);
    updateView();
    return view;
}
Also used : Context(android.content.Context) RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) ViewTransition(com.hippo.view.ViewTransition) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) TextView(android.widget.TextView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) Nullable(android.support.annotation.Nullable)

Example 3 with EasyRecyclerView

use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.

the class DownloadsScene method onCreateView3.

@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();
    Assert.assertNotNull(content);
    Resources resources = context.getResources();
    Drawable drawable = DrawableManager.getDrawable(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, false));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.hasFixedSize();
    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(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
    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;
}
Also used : Context(android.content.Context) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) ViewTransition(com.hippo.view.ViewTransition) HandlerDrawable(com.hippo.easyrecyclerview.HandlerDrawable) Drawable(android.graphics.drawable.Drawable) FastScroller(com.hippo.easyrecyclerview.FastScroller) MarginItemDecoration(com.hippo.easyrecyclerview.MarginItemDecoration) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) SimpleRatingView(com.hippo.ehviewer.widget.SimpleRatingView) LoadImageView(com.hippo.widget.LoadImageView) TextView(android.widget.TextView) ListView(android.widget.ListView) RecyclerView(android.support.v7.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) AutoStaggeredGridLayoutManager(com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager) TextView(android.widget.TextView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) Resources(android.content.res.Resources) HandlerDrawable(com.hippo.easyrecyclerview.HandlerDrawable) Nullable(android.support.annotation.Nullable)

Example 4 with EasyRecyclerView

use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.

the class FavoritesScene method showFavoritesInfoDialog.

@SuppressLint("InflateParams")
private void showFavoritesInfoDialog() {
    Context context = getContext2();
    if (null == context || null == mFavCatArray || null == mFavCountArray) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    context = builder.getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null);
    rv.setAdapter(new InfoAdapter(inflater));
    rv.setLayoutManager(new LinearLayoutManager(context));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
    rv.addItemDecoration(decoration);
    rv.setSelector(Ripple.generateRippleDrawable(context, false));
    rv.setClipToPadding(false);
    builder.setView(rv).show();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) SpannableStringBuilder(android.text.SpannableStringBuilder) FavListUrlBuilder(com.hippo.ehviewer.client.data.FavListUrlBuilder) LayoutInflater(android.view.LayoutInflater) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration) SuppressLint(android.annotation.SuppressLint)

Example 5 with EasyRecyclerView

use of com.hippo.easyrecyclerview.EasyRecyclerView in project EhViewer by seven332.

the class GalleryCommentsScene method showVoteStatusDialog.

@SuppressLint("InflateParams")
public void showVoteStatusDialog(Context context, String voteStatus) {
    String[] temp = StringUtils.split(voteStatus, ',');
    final int length = temp.length;
    final String[] userArray = new String[length];
    final String[] voteArray = new String[length];
    for (int i = 0; i < length; i++) {
        String str = StringUtils.trim(temp[i]);
        int index = str.lastIndexOf(' ');
        if (index < 0) {
            Log.d(TAG, "Something wrong happened about vote state");
            userArray[i] = str;
            voteArray[i] = "";
        } else {
            userArray[i] = StringUtils.trim(str.substring(0, index));
            voteArray[i] = StringUtils.trim(str.substring(index + 1));
        }
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    context = builder.getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    EasyRecyclerView rv = (EasyRecyclerView) inflater.inflate(R.layout.dialog_recycler_view, null);
    rv.setAdapter(new RecyclerView.Adapter<InfoHolder>() {

        @Override
        public InfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new InfoHolder(inflater.inflate(R.layout.item_favorite_info_data, parent, false));
        }

        @Override
        public void onBindViewHolder(InfoHolder holder, int position) {
            holder.key.setText(userArray[position]);
            holder.value.setText(voteArray[position]);
        }

        @Override
        public int getItemCount() {
            return length;
        }
    });
    rv.setLayoutManager(new LinearLayoutManager(context));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
    rv.addItemDecoration(decoration);
    rv.setSelector(Ripple.generateRippleDrawable(context, false));
    rv.setClipToPadding(false);
    builder.setView(rv).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ViewGroup(android.view.ViewGroup) SpannableStringBuilder(android.text.SpannableStringBuilder) SpannableString(android.text.SpannableString) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration) SuppressLint(android.annotation.SuppressLint) LayoutInflater(android.view.LayoutInflater) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint)

Aggregations

EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)14 RecyclerView (android.support.v7.widget.RecyclerView)10 Context (android.content.Context)8 View (android.view.View)8 TextView (android.widget.TextView)8 Nullable (android.support.annotation.Nullable)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 SuppressLint (android.annotation.SuppressLint)5 Drawable (android.graphics.drawable.Drawable)5 ViewTransition (com.hippo.view.ViewTransition)5 LinearDividerItemDecoration (com.hippo.easyrecyclerview.LinearDividerItemDecoration)4 Activity (android.app.Activity)3 Resources (android.content.res.Resources)3 GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)3 SwipeDismissItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator)3 RecyclerViewSwipeManager (com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager)3 RecyclerViewTouchActionGuardManager (com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager)3 MainActivity (com.hippo.ehviewer.ui.MainActivity)3 SimpleRatingView (com.hippo.ehviewer.widget.SimpleRatingView)3 LoadImageView (com.hippo.widget.LoadImageView)3