Search in sources :

Example 1 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class GalleryDetailScene method onCreateView2.

@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    // Get download state
    long gid = getGid();
    if (gid != -1) {
        Context context = getContext2();
        Assert.assertNotNull(context);
        mDownloadState = EhApplication.getDownloadManager(context).getDownloadState(gid);
    } else {
        mDownloadState = DownloadInfo.STATE_INVALID;
    }
    View view = inflater.inflate(R.layout.scene_gallery_detail, container, false);
    ViewGroup main = (ViewGroup) ViewUtils.$$(view, R.id.main);
    View mainView = ViewUtils.$$(main, R.id.scroll_view);
    View progressView = ViewUtils.$$(main, R.id.progress_view);
    mTip = (TextView) ViewUtils.$$(main, R.id.tip);
    mViewTransition = new ViewTransition(mainView, progressView, mTip);
    Context context = getContext2();
    Assert.assertNotNull(context);
    Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_weird_face);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    mTip.setCompoundDrawables(null, drawable, null, null);
    mTip.setOnClickListener(this);
    mHeader = ViewUtils.$$(mainView, R.id.header);
    mColorBg = ViewUtils.$$(mHeader, R.id.color_bg);
    mThumb = (LoadImageView) ViewUtils.$$(mHeader, R.id.thumb);
    mTitle = (TextView) ViewUtils.$$(mHeader, R.id.title);
    mUploader = (TextView) ViewUtils.$$(mHeader, R.id.uploader);
    mCategory = (TextView) ViewUtils.$$(mHeader, R.id.category);
    mOtherActions = (ImageView) ViewUtils.$$(mHeader, R.id.other_actions);
    mActionGroup = (ViewGroup) ViewUtils.$$(mHeader, R.id.action_card);
    mDownload = (TextView) ViewUtils.$$(mActionGroup, R.id.download);
    mRead = ViewUtils.$$(mActionGroup, R.id.read);
    Ripple.addRipple(mOtherActions, false);
    Ripple.addRipple(mDownload, false);
    Ripple.addRipple(mRead, false);
    mUploader.setOnClickListener(this);
    mCategory.setOnClickListener(this);
    mOtherActions.setOnClickListener(this);
    mDownload.setOnClickListener(this);
    mDownload.setOnLongClickListener(this);
    mRead.setOnClickListener(this);
    mUploader.setOnLongClickListener(this);
    mBelowHeader = mainView.findViewById(R.id.below_header);
    View belowHeader = mBelowHeader;
    mInfo = ViewUtils.$$(belowHeader, R.id.info);
    mLanguage = (TextView) ViewUtils.$$(mInfo, R.id.language);
    mPages = (TextView) ViewUtils.$$(mInfo, R.id.pages);
    mSize = (TextView) ViewUtils.$$(mInfo, R.id.size);
    mPosted = (TextView) ViewUtils.$$(mInfo, R.id.posted);
    mFavoredTimes = (TextView) ViewUtils.$$(mInfo, R.id.favoredTimes);
    Ripple.addRipple(mInfo, false);
    mInfo.setOnClickListener(this);
    mActions = ViewUtils.$$(belowHeader, R.id.actions);
    mRatingText = (TextView) ViewUtils.$$(mActions, R.id.rating_text);
    mRating = (RatingBar) ViewUtils.$$(mActions, R.id.rating);
    mHeartGroup = ViewUtils.$$(mActions, R.id.heart_group);
    mHeart = (TextView) ViewUtils.$$(mHeartGroup, R.id.heart);
    mHeartOutline = (TextView) ViewUtils.$$(mHeartGroup, R.id.heart_outline);
    mTorrent = (TextView) ViewUtils.$$(mActions, R.id.torrent);
    mArchive = (TextView) ViewUtils.$$(mActions, R.id.archive);
    mShare = (TextView) ViewUtils.$$(mActions, R.id.share);
    mRate = (TextView) ViewUtils.$$(mActions, R.id.rate);
    mSimilar = (TextView) ViewUtils.$$(mActions, R.id.similar);
    mSearchCover = (TextView) ViewUtils.$$(mActions, R.id.search_cover);
    Ripple.addRipple(mHeartGroup, false);
    Ripple.addRipple(mTorrent, false);
    Ripple.addRipple(mArchive, false);
    Ripple.addRipple(mShare, false);
    Ripple.addRipple(mRate, false);
    Ripple.addRipple(mSimilar, false);
    Ripple.addRipple(mSearchCover, false);
    mHeartGroup.setOnClickListener(this);
    mTorrent.setOnClickListener(this);
    mArchive.setOnClickListener(this);
    mShare.setOnClickListener(this);
    mRate.setOnClickListener(this);
    mSimilar.setOnClickListener(this);
    mSearchCover.setOnClickListener(this);
    ensureActionDrawable(context);
    mTags = (LinearLayout) ViewUtils.$$(belowHeader, R.id.tags);
    mNoTags = (TextView) ViewUtils.$$(mTags, R.id.no_tags);
    mComments = (LinearLayout) ViewUtils.$$(belowHeader, R.id.comments);
    mCommentsText = (TextView) ViewUtils.$$(mComments, R.id.comments_text);
    Ripple.addRipple(mComments, false);
    mComments.setOnClickListener(this);
    mPreviews = ViewUtils.$$(belowHeader, R.id.previews);
    mGridLayout = (SimpleGridAutoSpanLayout) ViewUtils.$$(mPreviews, R.id.grid_layout);
    mPreviewText = (TextView) ViewUtils.$$(mPreviews, R.id.preview_text);
    Ripple.addRipple(mPreviews, false);
    mPreviews.setOnClickListener(this);
    mProgress = ViewUtils.$$(mainView, R.id.progress);
    mViewTransition2 = new ViewTransition(mBelowHeader, mProgress);
    if (prepareData()) {
        if (mGalleryDetail != null) {
            bindViewSecond();
            setTransitionName();
            adjustViewVisibility(STATE_NORMAL, false);
        } else if (mGalleryInfo != null) {
            bindViewFirst();
            setTransitionName();
            adjustViewVisibility(STATE_REFRESH_HEADER, false);
        } else {
            adjustViewVisibility(STATE_REFRESH, false);
        }
    } else {
        mTip.setText(R.string.error_cannot_find_gallery);
        adjustViewVisibility(STATE_FAILED, false);
    }
    EhApplication.getDownloadManager(context).addDownloadInfoListener(this);
    return view;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) ViewTransition(com.hippo.view.ViewTransition) Drawable(android.graphics.drawable.Drawable) RoundSideRectDrawable(com.hippo.drawable.RoundSideRectDrawable) ImageView(android.widget.ImageView) LoadImageView(com.hippo.widget.LoadImageView) ProgressView(com.hippo.widget.ProgressView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ObservedTextView(com.hippo.widget.ObservedTextView) Nullable(android.support.annotation.Nullable)

Example 2 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class GalleryListScene method onCreateView2.

@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();
    Assert.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();
    mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit));
    contentLayout.setHelper(mHelper);
    contentLayout.getFastScroller().setOnDragHandlerListener(this);
    mAdapter = new GalleryListAdapter(inflater, resources, mRecyclerView, Settings.getListMode());
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.hasFixedSize();
    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);
    mRightDrawable = new AddDeleteDrawable(context);
    mSearchBar.setLeftDrawable(mLeftDrawable);
    mSearchBar.setRightDrawable(mRightDrawable);
    mSearchBar.setHelper(this);
    mSearchBar.setOnStateChangeListener(this);
    setSearchBarHint(context, 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);
    mActionFabDrawable.setColor(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;
}
Also used : Context(android.content.Context) ViewTransition(com.hippo.view.ViewTransition) FastScroller(com.hippo.easyrecyclerview.FastScroller) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) RecyclerView(android.support.v7.widget.RecyclerView) Point(android.graphics.Point) SearchBarMover(com.hippo.widget.SearchBarMover) ContentLayout(com.hippo.widget.ContentLayout) RefreshLayout(com.hippo.refreshlayout.RefreshLayout) DrawerArrowDrawable(com.hippo.drawable.DrawerArrowDrawable) Resources(android.content.res.Resources) AddDeleteDrawable(com.hippo.drawable.AddDeleteDrawable) Nullable(android.support.annotation.Nullable)

Example 3 with ViewTransition

use of com.hippo.view.ViewTransition 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 4 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class ProgressScene method onCreateView2.

@Nullable
@Override
public View onCreateView2(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_progress, container, false);
    View progress = ViewUtils.$$(view, R.id.progress);
    mTip = (TextView) ViewUtils.$$(view, R.id.tip);
    Context context = getContext2();
    Assert.assertNotNull(context);
    Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_weird_face);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    mTip.setCompoundDrawables(null, drawable, null, null);
    mTip.setOnClickListener(this);
    mTip.setText(mError);
    mViewTransition = new ViewTransition(progress, mTip);
    if (mValid) {
        mViewTransition.showView(0, false);
    } else {
        mViewTransition.showView(1, false);
    }
    return view;
}
Also used : Context(android.content.Context) Drawable(android.graphics.drawable.Drawable) ViewTransition(com.hippo.view.ViewTransition) TextView(android.widget.TextView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 5 with ViewTransition

use of com.hippo.view.ViewTransition 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)

Aggregations

TextView (android.widget.TextView)10 ViewTransition (com.hippo.view.ViewTransition)10 View (android.view.View)9 Context (android.content.Context)8 Drawable (android.graphics.drawable.Drawable)8 Nullable (android.support.annotation.Nullable)8 RecyclerView (android.support.v7.widget.RecyclerView)6 EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)6 Resources (android.content.res.Resources)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 AdapterView (android.widget.AdapterView)4 ListView (android.widget.ListView)4 ImageView (android.widget.ImageView)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 FastScroller (com.hippo.easyrecyclerview.FastScroller)3 LoadImageView (com.hippo.widget.LoadImageView)3 SuppressLint (android.annotation.SuppressLint)2