Search in sources :

Example 1 with DrawerLayout

use of com.hippo.drawerlayout.DrawerLayout 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();
        AssertUtils.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();
    AssertUtils.assertNotNull(context);
    View actionsScrollView = ViewUtils.$$(view, R.id.actions_scroll_view);
    setDrawerGestureBlocker(new DrawerLayout.GestureBlocker() {

        private void transformPointToViewLocal(int[] point, View child) {
            ViewParent viewParent = child.getParent();
            while (viewParent instanceof View) {
                View view = (View) viewParent;
                point[0] += view.getScrollX() - child.getLeft();
                point[1] += view.getScrollY() - child.getTop();
                if (view instanceof DrawerLayout) {
                    break;
                }
                child = view;
                viewParent = child.getParent();
            }
        }

        @Override
        public boolean shouldBlockGesture(MotionEvent ev) {
            int[] point = new int[] { (int) ev.getX(), (int) ev.getY() };
            transformPointToViewLocal(point, actionsScrollView);
            return !isDrawersVisible() && point[0] > 0 && point[0] < actionsScrollView.getWidth() && point[1] > 0 && point[1] < actionsScrollView.getHeight();
        }
    });
    Drawable drawable = DrawableManager.getVectorDrawable(context, R.drawable.big_sad_pandroid);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    mTip.setCompoundDrawables(null, drawable, null, null);
    mTip.setOnClickListener(this);
    boolean isDarkTheme = !AttrResources.getAttrBoolean(context, R.attr.isLightTheme);
    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, isDarkTheme);
    Ripple.addRipple(mDownload, isDarkTheme);
    Ripple.addRipple(mRead, isDarkTheme);
    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, isDarkTheme);
    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, isDarkTheme);
    Ripple.addRipple(mTorrent, isDarkTheme);
    Ripple.addRipple(mArchive, isDarkTheme);
    Ripple.addRipple(mShare, isDarkTheme);
    Ripple.addRipple(mRate, isDarkTheme);
    Ripple.addRipple(mSimilar, isDarkTheme);
    Ripple.addRipple(mSearchCover, isDarkTheme);
    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, isDarkTheme);
    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, isDarkTheme);
    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) ViewParent(android.view.ViewParent) 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) MotionEvent(android.view.MotionEvent) DrawerLayout(com.hippo.drawerlayout.DrawerLayout) Nullable(androidx.annotation.Nullable)

Aggregations

Context (android.content.Context)1 Drawable (android.graphics.drawable.Drawable)1 MotionEvent (android.view.MotionEvent)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ViewParent (android.view.ViewParent)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 RoundSideRectDrawable (com.hippo.drawable.RoundSideRectDrawable)1 DrawerLayout (com.hippo.drawerlayout.DrawerLayout)1 ViewTransition (com.hippo.view.ViewTransition)1 LoadImageView (com.hippo.widget.LoadImageView)1 ObservedTextView (com.hippo.widget.ObservedTextView)1 ProgressView (com.hippo.widget.ProgressView)1