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;
}
Aggregations