List of usage examples for android.view Gravity RIGHT
int RIGHT
To view the source code for android.view Gravity RIGHT.
Click Source Link
From source file:com.huangj.huangjlibrary.widget.drawerlayout.DrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * * @param edgeGravity Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. *///from w w w. ja v a2 s .co m @LockMode public int getDrawerLockMode(@EdgeGravity int edgeGravity) { int layoutDirection = ViewCompat.getLayoutDirection(this); switch (edgeGravity) { case Gravity.LEFT: if (mLockModeLeft != LOCK_MODE_UNDEFINED) { return mLockModeLeft; } int leftLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeStart : mLockModeEnd; if (leftLockMode != LOCK_MODE_UNDEFINED) { return leftLockMode; } break; case Gravity.RIGHT: if (mLockModeRight != LOCK_MODE_UNDEFINED) { return mLockModeRight; } int rightLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeEnd : mLockModeStart; if (rightLockMode != LOCK_MODE_UNDEFINED) { return rightLockMode; } break; case GravityCompat.START: if (mLockModeStart != LOCK_MODE_UNDEFINED) { return mLockModeStart; } int startLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeLeft : mLockModeRight; if (startLockMode != LOCK_MODE_UNDEFINED) { return startLockMode; } break; case GravityCompat.END: if (mLockModeEnd != LOCK_MODE_UNDEFINED) { return mLockModeEnd; } int endLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeRight : mLockModeLeft; if (endLockMode != LOCK_MODE_UNDEFINED) { return endLockMode; } break; } return LOCK_MODE_UNLOCKED; }
From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java
@Override @Implemented(EasyRecyclerView.CustomChoiceListener.class) public void onOutOfCustomChoice(EasyRecyclerView view) { if (mFabLayout != null) { mFabLayout.setExpanded(false);//from w w w.j ava2 s. co m } if (mHelper != null) { mHelper.setRefreshLayoutEnable(true); } // Unlock drawer setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT); setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); }
From source file:android.support.designox.widget.CoordinatorLayout.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { prepareChildren();/*from ww w . ja v a 2 s.c o m*/ ensurePreDrawListener(); final int paddingLeft = getPaddingLeft(); final int paddingTop = getPaddingTop(); final int paddingRight = getPaddingRight(); final int paddingBottom = getPaddingBottom(); final int layoutDirection = ViewCompat.getLayoutDirection(this); final boolean isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL; final int widthMode = MeasureSpec.getMode(widthMeasureSpec); final int widthSize = MeasureSpec.getSize(widthMeasureSpec); final int heightMode = MeasureSpec.getMode(heightMeasureSpec); final int heightSize = MeasureSpec.getSize(heightMeasureSpec); final int widthPadding = paddingLeft + paddingRight; final int heightPadding = paddingTop + paddingBottom; int widthUsed = getSuggestedMinimumWidth(); int heightUsed = getSuggestedMinimumHeight(); int childState = 0; final boolean applyInsets = mLastInsets != null && ViewCompat.getFitsSystemWindows(this); final int childCount = mDependencySortedChildren.size(); for (int i = 0; i < childCount; i++) { final View child = mDependencySortedChildren.get(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); int keylineWidthUsed = 0; if (lp.keyline >= 0 && widthMode != MeasureSpec.UNSPECIFIED) { final int keylinePos = getKeyline(lp.keyline); final int keylineGravity = GravityCompat.getAbsoluteGravity(resolveKeylineGravity(lp.gravity), layoutDirection) & Gravity.HORIZONTAL_GRAVITY_MASK; if ((keylineGravity == Gravity.LEFT && !isRtl) || (keylineGravity == Gravity.RIGHT && isRtl)) { keylineWidthUsed = Math.max(0, widthSize - paddingRight - keylinePos); } else if ((keylineGravity == Gravity.RIGHT && !isRtl) || (keylineGravity == Gravity.LEFT && isRtl)) { keylineWidthUsed = Math.max(0, keylinePos - paddingLeft); } } int childWidthMeasureSpec = widthMeasureSpec; int childHeightMeasureSpec = heightMeasureSpec; if (applyInsets && !ViewCompat.getFitsSystemWindows(child)) { // We're set to handle insets but this child isn't, so we will measure the // child as if there are no insets final int horizInsets = mLastInsets.getSystemWindowInsetLeft() + mLastInsets.getSystemWindowInsetRight(); final int vertInsets = mLastInsets.getSystemWindowInsetTop() + mLastInsets.getSystemWindowInsetBottom(); childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize - horizInsets, widthMode); childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize - vertInsets, heightMode); } final Behavior b = lp.getBehavior(); if (b == null || !b.onMeasureChild(this, child, childWidthMeasureSpec, keylineWidthUsed, childHeightMeasureSpec, 0)) { onMeasureChild(child, childWidthMeasureSpec, keylineWidthUsed, childHeightMeasureSpec, 0); } widthUsed = Math.max(widthUsed, widthPadding + child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin); heightUsed = Math.max(heightUsed, heightPadding + child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin); childState = ViewCompat.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child)); } final int width = ViewCompat.resolveSizeAndState(widthUsed, widthMeasureSpec, childState & ViewCompat.MEASURED_STATE_MASK); final int height = ViewCompat.resolveSizeAndState(heightUsed, heightMeasureSpec, childState << ViewCompat.MEASURED_HEIGHT_STATE_SHIFT); setMeasuredDimension(width, height); }
From source file:com.hippo.ehviewer.ui.scene.FavoritesScene.java
@Override @Implemented(AdapterView.OnItemClickListener.class) public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Skip if in search mode if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) { return;//w ww . j a va2s .co m } if (mUrlBuilder == null || mHelper == null) { return; } // Local favorite position is 0, All favorite position is 1, so position - 2 is OK int newFavCat = position - 2; // Check is the same if (mUrlBuilder.getFavCat() == newFavCat) { return; } // Ensure outOfCustomChoiceMode to avoid error if (mRecyclerView != null) { mRecyclerView.isInCustomChoice(); } exitSearchMode(true); mUrlBuilder.setKeyword(null); mUrlBuilder.setFavCat(newFavCat); updateSearchBar(); mHelper.refresh(); closeDrawer(Gravity.RIGHT); }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java
protected boolean setValueFromTheme(TypedArray remoteTypedArray, final int[] padding, final int localAttrId, final int remoteTypedArrayIndex) { try {/*from w w w . jav a 2 s . c om*/ switch (localAttrId) { case android.R.attr.background: Drawable keyboardBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); if (keyboardBackground == null) return false; CompatUtils.setViewBackgroundDrawable(this, keyboardBackground); break; case android.R.attr.paddingLeft: padding[0] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[0] == -1) return false; break; case android.R.attr.paddingTop: padding[1] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[1] == -1) return false; break; case android.R.attr.paddingRight: padding[2] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[2] == -1) return false; break; case android.R.attr.paddingBottom: padding[3] = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (padding[3] == -1) return false; break; case R.attr.keyBackground: mKeyBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); if (mKeyBackground == null) return false; break; case R.attr.keyHysteresisDistance: mKeyHysteresisDistance = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (mKeyHysteresisDistance == -1) return false; break; case R.attr.verticalCorrection: mOriginalVerticalCorrection = mVerticalCorrection = remoteTypedArray .getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (mOriginalVerticalCorrection == -1) return false; break; case R.attr.keyTextSize: mKeyTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mKeyTextSize == -1) return false; // you might ask yourself "why did Menny sqrt root the factor?" // I'll tell you; the factor is mostly for the height, not the // font size, // but I also factorize the font size because I want the text to // be a little like // the key size. // the whole factor maybe too much, so I ease that a bit. if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mKeyTextSize = (float) (mKeyTextSize * Math.sqrt(AnyApplication.getConfig().getKeysHeightFactorInLandscape())); else mKeyTextSize = (float) (mKeyTextSize * Math.sqrt(AnyApplication.getConfig().getKeysHeightFactorInPortrait())); Logger.d(TAG, "AnySoftKeyboardTheme_keyTextSize " + mKeyTextSize); break; case R.attr.keyTextColor: mKeyTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex); if (mKeyTextColor == null) { mKeyTextColor = new ColorStateList(new int[][] { { 0 } }, new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) }); } break; case R.attr.labelTextSize: mLabelTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mLabelTextSize == -1) return false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mLabelTextSize = mLabelTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); break; case R.attr.keyboardNameTextSize: mKeyboardNameTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mKeyboardNameTextSize == -1) return false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mKeyboardNameTextSize = mKeyboardNameTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mKeyboardNameTextSize = mKeyboardNameTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); break; case R.attr.keyboardNameTextColor: mKeyboardNameTextColor = remoteTypedArray.getColor(remoteTypedArrayIndex, Color.WHITE); break; case R.attr.shadowColor: mShadowColor = remoteTypedArray.getColor(remoteTypedArrayIndex, 0); break; case R.attr.shadowRadius: mShadowRadius = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); break; case R.attr.shadowOffsetX: mShadowOffsetX = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); break; case R.attr.shadowOffsetY: mShadowOffsetY = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0); break; case R.attr.backgroundDimAmount: mBackgroundDimAmount = remoteTypedArray.getFloat(remoteTypedArrayIndex, -1f); if (mBackgroundDimAmount == -1f) return false; break; case R.attr.keyPreviewBackground: Drawable keyPreviewBackground = remoteTypedArray.getDrawable(remoteTypedArrayIndex); if (keyPreviewBackground == null) return false; mPreviewPopupTheme.setPreviewKeyBackground(keyPreviewBackground); break; case R.attr.keyPreviewTextColor: mPreviewPopupTheme.setPreviewKeyTextColor(remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFFF)); break; case R.attr.keyPreviewTextSize: mPreviewPopupTheme .setPreviewKeyTextSize(remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0)); break; case R.attr.keyPreviewLabelTextSize: mPreviewPopupTheme .setPreviewLabelTextSize(remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, 0)); break; case R.attr.keyPreviewOffset: mPreviewPopupTheme .setVerticalOffset(remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, 0)); break; case R.attr.previewAnimationType: int previewAnimationType = remoteTypedArray.getInteger(remoteTypedArrayIndex, -1); if (previewAnimationType == -1) return false; mPreviewPopupTheme.setPreviewAnimationType(previewAnimationType); break; case R.attr.keyTextStyle: int textStyle = remoteTypedArray.getInt(remoteTypedArrayIndex, 0); switch (textStyle) { case 0: mKeyTextStyle = Typeface.DEFAULT; break; case 1: mKeyTextStyle = Typeface.DEFAULT_BOLD; break; case 2: mKeyTextStyle = Typeface.defaultFromStyle(Typeface.ITALIC); break; default: mKeyTextStyle = Typeface.defaultFromStyle(textStyle); break; } mPreviewPopupTheme.setKeyStyle(mKeyTextStyle); break; case R.attr.keyHorizontalGap: float themeHorizontalKeyGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeHorizontalKeyGap == -1) return false; mKeyboardDimens.setHorizontalKeyGap(themeHorizontalKeyGap); break; case R.attr.keyVerticalGap: float themeVerticalRowGap = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeVerticalRowGap == -1) return false; mKeyboardDimens.setVerticalRowGap(themeVerticalRowGap); break; case R.attr.keyNormalHeight: int themeNormalKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeNormalKeyHeight == -1) return false; mKeyboardDimens.setNormalKeyHeight(themeNormalKeyHeight); break; case R.attr.keyLargeHeight: int themeLargeKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeLargeKeyHeight == -1) return false; mKeyboardDimens.setLargeKeyHeight(themeLargeKeyHeight); break; case R.attr.keySmallHeight: int themeSmallKeyHeight = remoteTypedArray.getDimensionPixelOffset(remoteTypedArrayIndex, -1); if (themeSmallKeyHeight == -1) return false; mKeyboardDimens.setSmallKeyHeight(themeSmallKeyHeight); break; case R.attr.hintTextSize: mHintTextSize = remoteTypedArray.getDimensionPixelSize(remoteTypedArrayIndex, -1); if (mHintTextSize == -1) return false; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInLandscape(); else mHintTextSize = mHintTextSize * AnyApplication.getConfig().getKeysHeightFactorInPortrait(); break; case R.attr.hintTextColor: mHintTextColor = remoteTypedArray.getColorStateList(remoteTypedArrayIndex); if (mHintTextColor == null) { mHintTextColor = new ColorStateList(new int[][] { { 0 } }, new int[] { remoteTypedArray.getColor(remoteTypedArrayIndex, 0xFF000000) }); } break; case R.attr.hintLabelVAlign: mHintLabelVAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.BOTTOM); break; case R.attr.hintLabelAlign: mHintLabelAlign = remoteTypedArray.getInt(remoteTypedArrayIndex, Gravity.RIGHT); break; case R.attr.hintOverflowLabel: mHintOverflowLabel = remoteTypedArray.getString(remoteTypedArrayIndex); break; } return true; } catch (Exception e) { // on API changes, so the incompatible themes wont crash me.. e.printStackTrace(); return false; } }
From source file:com.hippo.nimingban.ui.ListActivity.java
@Override public void onSelectForum(Forum forum) { if (mCurrentForum == null || (mCurrentForum.getNMBSite() != forum.getNMBSite() || !mCurrentForum.getNMBId().equals(forum.getNMBId()))) { mCurrentForum = forum;//from w w w .j a v a 2 s .co m updateTitleByForum(mCurrentForum); mSlidingDrawerLayout.closeDrawer(Gravity.RIGHT); mPostHelper.refresh(); } }
From source file:com.hippo.ehviewer.ui.scene.GalleryListScene.java
@Override public void onExpand(boolean expanded) { if (null == mActionFabDrawable) { return;// w w w . j av a2 s .c om } if (expanded) { setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT); setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT); mActionFabDrawable.setDelete(ANIMATE_TIME); } else { setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT); setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); mActionFabDrawable.setAdd(ANIMATE_TIME); } }
From source file:android.support.design.widget.CoordinatorLayout.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { prepareChildren();//from w w w . jav a2s . c o m ensurePreDrawListener(); final int paddingLeft = getPaddingLeft(); final int paddingTop = getPaddingTop(); final int paddingRight = getPaddingRight(); final int paddingBottom = getPaddingBottom(); final int layoutDirection = ViewCompat.getLayoutDirection(this); final boolean isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL; final int widthMode = MeasureSpec.getMode(widthMeasureSpec); final int widthSize = MeasureSpec.getSize(widthMeasureSpec); final int heightMode = MeasureSpec.getMode(heightMeasureSpec); final int heightSize = MeasureSpec.getSize(heightMeasureSpec); final int widthPadding = paddingLeft + paddingRight; final int heightPadding = paddingTop + paddingBottom; int widthUsed = getSuggestedMinimumWidth(); int heightUsed = getSuggestedMinimumHeight(); int childState = 0; final boolean applyInsets = mLastInsets != null && ViewCompat.getFitsSystemWindows(this); final int childCount = mDependencySortedChildren.size(); for (int i = 0; i < childCount; i++) { final View child = mDependencySortedChildren.get(i); if (child.getVisibility() == GONE) { // If the child is GONE, skip... continue; } final LayoutParams lp = (LayoutParams) child.getLayoutParams(); int keylineWidthUsed = 0; if (lp.keyline >= 0 && widthMode != MeasureSpec.UNSPECIFIED) { final int keylinePos = getKeyline(lp.keyline); final int keylineGravity = GravityCompat.getAbsoluteGravity(resolveKeylineGravity(lp.gravity), layoutDirection) & Gravity.HORIZONTAL_GRAVITY_MASK; if ((keylineGravity == Gravity.LEFT && !isRtl) || (keylineGravity == Gravity.RIGHT && isRtl)) { keylineWidthUsed = Math.max(0, widthSize - paddingRight - keylinePos); } else if ((keylineGravity == Gravity.RIGHT && !isRtl) || (keylineGravity == Gravity.LEFT && isRtl)) { keylineWidthUsed = Math.max(0, keylinePos - paddingLeft); } } int childWidthMeasureSpec = widthMeasureSpec; int childHeightMeasureSpec = heightMeasureSpec; if (applyInsets && !ViewCompat.getFitsSystemWindows(child)) { // We're set to handle insets but this child isn't, so we will measure the // child as if there are no insets final int horizInsets = mLastInsets.getSystemWindowInsetLeft() + mLastInsets.getSystemWindowInsetRight(); final int vertInsets = mLastInsets.getSystemWindowInsetTop() + mLastInsets.getSystemWindowInsetBottom(); childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(widthSize - horizInsets, widthMode); childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize - vertInsets, heightMode); } final Behavior b = lp.getBehavior(); if (b == null || !b.onMeasureChild(this, child, childWidthMeasureSpec, keylineWidthUsed, childHeightMeasureSpec, 0)) { onMeasureChild(child, childWidthMeasureSpec, keylineWidthUsed, childHeightMeasureSpec, 0); } widthUsed = Math.max(widthUsed, widthPadding + child.getMeasuredWidth() + lp.leftMargin + lp.rightMargin); heightUsed = Math.max(heightUsed, heightPadding + child.getMeasuredHeight() + lp.topMargin + lp.bottomMargin); childState = ViewCompat.combineMeasuredStates(childState, ViewCompat.getMeasuredState(child)); } final int width = ViewCompat.resolveSizeAndState(widthUsed, widthMeasureSpec, childState & ViewCompat.MEASURED_STATE_MASK); final int height = ViewCompat.resolveSizeAndState(heightUsed, heightMeasureSpec, childState << ViewCompat.MEASURED_HEIGHT_STATE_SHIFT); setMeasuredDimension(width, height); }
From source file:com.zyk.drawerlayout.widget.DrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * * @param edgeGravity Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. *///from ww w .j a va2 s.c o m @LockMode public int getDrawerLockMode(@EdgeGravity int edgeGravity) { int layoutDirection = ViewCompat.getLayoutDirection(this); switch (edgeGravity) { case Gravity.LEFT: if (mLockModeLeft != LOCK_MODE_UNDEFINED) { return mLockModeLeft; } int leftLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeStart : mLockModeEnd; if (leftLockMode != LOCK_MODE_UNDEFINED) { return leftLockMode; } break; case Gravity.TOP: if (mLockModeTop != LOCK_MODE_UNDEFINED) { return mLockModeTop; } int topLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeStart : mLockModeEnd; if (topLockMode != LOCK_MODE_UNDEFINED) { return topLockMode; } break; case Gravity.RIGHT: if (mLockModeRight != LOCK_MODE_UNDEFINED) { return mLockModeRight; } int rightLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeEnd : mLockModeStart; if (rightLockMode != LOCK_MODE_UNDEFINED) { return rightLockMode; } break; case Gravity.BOTTOM: if (mLockModeBottom != LOCK_MODE_UNDEFINED) { return mLockModeBottom; } int bottomLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeEnd : mLockModeStart; if (bottomLockMode != LOCK_MODE_UNDEFINED) { return bottomLockMode; } break; case GravityCompat.START: if (mLockModeStart != LOCK_MODE_UNDEFINED) { return mLockModeStart; } int startLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeLeft : mLockModeRight; if (startLockMode != LOCK_MODE_UNDEFINED) { return startLockMode; } break; case GravityCompat.END: if (mLockModeEnd != LOCK_MODE_UNDEFINED) { return mLockModeEnd; } int endLockMode = (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) ? mLockModeRight : mLockModeLeft; if (endLockMode != LOCK_MODE_UNDEFINED) { return endLockMode; } break; } return LOCK_MODE_UNLOCKED; }
From source file:com.lansun.qmyo.view.DrawerLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final int height = getHeight(); final boolean drawingContent = isContentView(child); int clipLeft = 0, clipRight = getWidth(); final int restoreCount = canvas.save(); if (drawingContent) { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View v = getChildAt(i); if (v == child || v.getVisibility() != VISIBLE || !hasOpaqueBackground(v) || !isDrawerView(v) || v.getHeight() < height) { continue; }// w w w. j a v a2 s. co m if (checkDrawerViewGravity(v, Gravity.LEFT)) { final int vright = v.getRight(); if (vright > clipLeft) clipLeft = vright; } else { final int vleft = v.getLeft(); if (vleft < clipRight) clipRight = vleft; } } canvas.clipRect(clipLeft, 0, clipRight, getHeight()); } final boolean result = super.drawChild(canvas, child, drawingTime); canvas.restoreToCount(restoreCount); if (mScrimOpacity > 0 && drawingContent) { // final int baseAlpha = (mScrimColor & 0xff000000) >>> 24; // final int imag = (int) (baseAlpha * mScrimOpacity); // final int color = imag << 24 | (mScrimColor & 0xffffff); // mScrimPaint.setColor(color); // // canvas.drawRect(clipLeft, 0, clipRight, getHeight(), mScrimPaint); } else if (mShadowLeft != null && checkDrawerViewGravity(child, Gravity.LEFT)) { final int shadowWidth = mShadowLeft.getIntrinsicWidth(); final int childRight = child.getRight(); final int drawerPeekDistance = mLeftDragger.getEdgeSize(); final float alpha = Math.max(0, Math.min((float) childRight / drawerPeekDistance, 1.f)); mShadowLeft.setBounds(childRight, child.getTop(), childRight + shadowWidth, child.getBottom()); mShadowLeft.setAlpha((int) (0xff * alpha)); mShadowLeft.draw(canvas); } else if (mShadowRight != null && checkDrawerViewGravity(child, Gravity.RIGHT)) { final int shadowWidth = mShadowRight.getIntrinsicWidth(); final int childLeft = child.getLeft(); final int showing = getWidth() - childLeft; final int drawerPeekDistance = mRightDragger.getEdgeSize(); final float alpha = Math.max(0, Math.min((float) showing / drawerPeekDistance, 1.f)); mShadowRight.setBounds(childLeft - shadowWidth, child.getTop(), childLeft, child.getBottom()); mShadowRight.setAlpha((int) (0xff * alpha)); mShadowRight.draw(canvas); } return result; }