本文整理汇总了Java中android.graphics.Rect.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Rect.isEmpty方法的具体用法?Java Rect.isEmpty怎么用?Java Rect.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Rect
的用法示例。
在下文中一共展示了Rect.isEmpty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyPressed
import android.graphics.Rect; //导入方法依赖的package包/类
protected void keyPressed() {
if (isEnabled() && isClickable()) {
Drawable selector = this.mSelector;
Rect selectorRect = this.mSelectorRect;
if (selector == null) {
return;
}
if ((isFocused() || touchModeDrawsInPressedState()) && !selectorRect.isEmpty()) {
View v = getChildAt(this.mSelectedPosition - this.mFirstPosition);
if (v != null) {
if (!v.hasFocusable()) {
v.setPressed(true);
} else {
return;
}
}
setPressed(true);
boolean longClickable = isLongClickable();
Drawable d = selector.getCurrent();
if (d != null && (d instanceof TransitionDrawable)) {
if (longClickable) {
((TransitionDrawable) d).startTransition(ViewConfiguration.getLongPressTimeout());
} else {
((TransitionDrawable) d).resetTransition();
}
}
if (longClickable && !this.mDataChanged) {
if (this.mPendingCheckForKeyLongPress == null) {
this.mPendingCheckForKeyLongPress = new CheckForKeyLongPress(this, null);
}
this.mPendingCheckForKeyLongPress.rememberWindowAttachCount();
postDelayed(this.mPendingCheckForKeyLongPress, (long) ViewConfiguration.getLongPressTimeout());
}
}
}
}
示例2: intersectVisibleToUser
import android.graphics.Rect; //导入方法依赖的package包/类
private boolean intersectVisibleToUser(Rect localRect) {
if (localRect == null || localRect.isEmpty() || this.mView.getWindowVisibility() != 0) {
return false;
}
ViewParent viewParent = this.mView.getParent();
while (viewParent instanceof View) {
View view = (View) viewParent;
if (ViewCompat.getAlpha(view) <= 0.0f || view.getVisibility() != 0) {
return false;
}
viewParent = view.getParent();
}
if (viewParent == null || !this.mView.getLocalVisibleRect(this.mTempVisibleRect)) {
return false;
}
return localRect.intersect(this.mTempVisibleRect);
}
示例3: keyPressed
import android.graphics.Rect; //导入方法依赖的package包/类
/**
* Sets the selector state to "pressed" and posts a CheckForKeyLongPress to
* see if this is a long press.
*/
protected void keyPressed() {
if (!isEnabled() || !isClickable()) {
return;
}
Drawable selector = mSelector;
Rect selectorRect = mSelectorRect;
if (selector != null && (isFocused() || touchModeDrawsInPressedState())
&& !selectorRect.isEmpty()) {
final View v = getChildAt(mSelectedPosition - mFirstPosition);
if (v != null) {
if (v.hasFocusable())
return;
v.setPressed(true);
}
setPressed(true);
final boolean longClickable = isLongClickable();
Drawable d = selector.getCurrent();
if (d != null && d instanceof TransitionDrawable) {
if (longClickable) {
((TransitionDrawable) d).startTransition(ViewConfiguration
.getLongPressTimeout());
} else {
((TransitionDrawable) d).resetTransition();
}
}
if (longClickable && !mDataChanged) {
if (mPendingCheckForKeyLongPress == null) {
mPendingCheckForKeyLongPress = new CheckForKeyLongPress();
}
mPendingCheckForKeyLongPress.rememberWindowAttachCount();
postDelayed(mPendingCheckForKeyLongPress,
ViewConfiguration.getLongPressTimeout());
}
}
}
示例4: AsyncDrawableSpan
import android.graphics.Rect; //导入方法依赖的package包/类
public AsyncDrawableSpan(
@NonNull SpannableTheme theme,
@NonNull AsyncDrawable drawable,
@Alignment int alignment,
boolean replacementTextIsLink) {
this.theme = theme;
this.drawable = drawable;
this.alignment = alignment;
this.replacementTextIsLink = replacementTextIsLink;
// additionally set intrinsic bounds if empty
final Rect rect = drawable.getBounds();
if (rect.isEmpty()) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
}
}
示例5: drawGestureTrails
import android.graphics.Rect; //导入方法依赖的package包/类
private boolean drawGestureTrails(final Canvas offscreenCanvas, final Paint paint,
final Rect dirtyRect) {
// Clear previous dirty rectangle.
if (!dirtyRect.isEmpty()) {
paint.setColor(Color.TRANSPARENT);
paint.setStyle(Paint.Style.FILL);
offscreenCanvas.drawRect(dirtyRect, paint);
}
dirtyRect.setEmpty();
boolean needsUpdatingGestureTrail = false;
// Draw gesture trails to offscreen buffer.
synchronized (mGestureTrails) {
// Trails count == fingers count that have ever been active.
final int trailsCount = mGestureTrails.size();
for (int index = 0; index < trailsCount; index++) {
final GestureTrailDrawingPoints trail = mGestureTrails.valueAt(index);
needsUpdatingGestureTrail |= trail.drawGestureTrail(offscreenCanvas, paint,
mGestureTrailBoundsRect, mDrawingParams);
// {@link #mGestureTrailBoundsRect} has bounding box of the trail.
dirtyRect.union(mGestureTrailBoundsRect);
}
}
return needsUpdatingGestureTrail;
}
示例6: adjustLayout
import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
if (requireLayoutView()) {
View refer = null;
Rect tempRect = new Rect();
final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
for (int i = 0; i < helper.getChildCount(); i++) {
refer = helper.getChildAt(i);
int anchorPos = helper.getPosition(refer);
if (getRange().contains(anchorPos)) {
if (refer.getVisibility() == View.GONE) {
tempRect.setEmpty();
} else {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
refer.getLayoutParams();
if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
orientationHelper.getDecoratedStart(refer),
helper.getDecoratedRight(refer) + params.rightMargin,
orientationHelper.getDecoratedEnd(refer));
} else {
tempRect.union(orientationHelper.getDecoratedStart(refer),
helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
helper.getDecoratedBottom(refer) + params.bottomMargin);
}
}
}
}
if (!tempRect.isEmpty()) {
mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
} else {
mLayoutRegion.setEmpty();
}
if (mLayoutView != null) {
mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
}
}
}
示例7: createVideoViewIfVisible
import android.graphics.Rect; //导入方法依赖的package包/类
public boolean createVideoViewIfVisible(){
Rect visibleRect = new Rect();
if (mVideoView != null) {
return true;
} else if (getGlobalVisibleRect(visibleRect) && !visibleRect.isEmpty()) {
createVideoView();
return true;
}
return false;
}
示例8: invalidate
import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public void invalidate(Rect r) {
if (r.isEmpty()) {
Log.w(TAG, "invalidating empty rect!");
}
super.invalidate(r);
}
示例9: draw
import android.graphics.Rect; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
if (null != mBitmap && !mBitmap.isRecycled()) {
final Rect bounds = getBounds();
if (!bounds.isEmpty()) {
canvas.drawBitmap(mBitmap, null, bounds, mPaint);
} else {
canvas.drawBitmap(mBitmap, 0f, 0f, mPaint);
}
}
}
示例10: ensureRect
import android.graphics.Rect; //导入方法依赖的package包/类
public static Rect ensureRect(Rect rect) {
if (rect == null || rect.isEmpty()) {
int dp = (int) (100 * ScreenUtil.density);
return new Rect(ScreenUtil.screenWidth / 2 - dp / 2, ScreenUtil.screenHeight / 2 - dp / 2,
ScreenUtil.screenWidth / 2 + dp / 2, ScreenUtil.screenHeight / 2 + dp / 2);
}
return rect;
}
示例11: adjustLayout
import android.graphics.Rect; //导入方法依赖的package包/类
public void adjustLayout(int startPosition, int endPosition, LayoutManagerHelper helper) {
if (!isChildrenEmpty()) {
for (int i = 0, size = mChildren.size(); i < size; i++) {
RangeStyle rangeStyle = mChildren.valueAt(i);
rangeStyle.adjustLayout(startPosition, endPosition, helper);
}
}
if (requireLayoutView()) {
View refer = null;
Rect tempRect = new Rect();
final OrientationHelperEx orientationHelper = helper.getMainOrientationHelper();
for (int i = 0; i < helper.getChildCount(); i++) {
refer = helper.getChildAt(i);
int anchorPos = helper.getPosition(refer);
if (getRange().contains(anchorPos)) {
if (refer.getVisibility() == View.GONE) {
tempRect.setEmpty();
} else {
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams)
refer.getLayoutParams();
if (helper.getOrientation() == VirtualLayoutManager.VERTICAL) {
tempRect.union(helper.getDecoratedLeft(refer) - params.leftMargin,
orientationHelper.getDecoratedStart(refer),
helper.getDecoratedRight(refer) + params.rightMargin,
orientationHelper.getDecoratedEnd(refer));
} else {
tempRect.union(orientationHelper.getDecoratedStart(refer),
helper.getDecoratedTop(refer) - params.topMargin, orientationHelper.getDecoratedEnd(refer),
helper.getDecoratedBottom(refer) + params.bottomMargin);
}
}
}
}
if (!tempRect.isEmpty()) {
mLayoutRegion.set(tempRect.left - mPaddingLeft, tempRect.top - mPaddingTop,
tempRect.right + mPaddingRight, tempRect.bottom + mPaddingBottom);
} else {
mLayoutRegion.setEmpty();
}
if (mLayoutView != null) {
mLayoutView.layout(mLayoutRegion.left, mLayoutRegion.top, mLayoutRegion.right, mLayoutRegion.bottom);
}
}
}
示例12: swapContentViewCore
import android.graphics.Rect; //导入方法依赖的package包/类
/**
* Called to swap out the current view with the one passed in.
*
* @param newContentViewCore The content view that should be swapped into the tab.
* @param deleteOldNativeWebContents Whether to delete the native web
* contents of old view.
* @param didStartLoad Whether
* WebContentsObserver::DidStartProvisionalLoadForFrame() has
* already been called.
* @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has
* already been called.
*/
public void swapContentViewCore(ContentViewCore newContentViewCore,
boolean deleteOldNativeWebContents, boolean didStartLoad, boolean didFinishLoad) {
int originalWidth = 0;
int originalHeight = 0;
if (mContentViewCore != null) {
originalWidth = mContentViewCore.getViewportWidthPix();
originalHeight = mContentViewCore.getViewportHeightPix();
mContentViewCore.onHide();
}
Rect bounds = new Rect();
if (originalWidth == 0 && originalHeight == 0) {
bounds = ExternalPrerenderHandler.estimateContentSize(
(Application) getApplicationContext(), false);
originalWidth = bounds.right - bounds.left;
originalHeight = bounds.bottom - bounds.top;
}
destroyContentViewCore(deleteOldNativeWebContents);
NativePage previousNativePage = mNativePage;
mNativePage = null;
// Size of the new ContentViewCore is zero at this point. If we don't call onSizeChanged(),
// next onShow() call would send a resize message with the current ContentViewCore size
// (zero) to the renderer process, although the new size will be set soon.
// However, this size fluttering may confuse Blink and rendered result can be broken
// (see http://crbug.com/340987).
newContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
if (!bounds.isEmpty()) {
newContentViewCore.onPhysicalBackingSizeChanged(bounds.right, bounds.bottom);
}
newContentViewCore.onShow();
setContentViewCore(newContentViewCore);
mContentViewCore.attachImeAdapter();
// If the URL has already committed (e.g. prerendering), tell process management logic that
// it can rely on the process visibility signal for binding management.
// TODO: Call ChildProcessLauncher#determinedVisibility() at a more intuitive time.
// See crbug.com/537671
if (!mContentViewCore.getWebContents().getLastCommittedUrl().equals("")) {
ChildProcessLauncher.determinedVisibility(mContentViewCore.getCurrentRenderProcessId());
}
destroyNativePageInternal(previousNativePage);
for (TabObserver observer : mObservers) {
observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
}
}
示例13: calculateVisibleFraction
import android.graphics.Rect; //导入方法依赖的package包/类
/**
* Get the visible fraction of the given {@link View} in the given {@link RecyclerView}
*
* @param recyclerView the given {@link RecyclerView}
* @param itemView the given {@link View}
* @param threshold the percentage of a view's area to be shown in order to consider it as being viewed
* @return the visible fraction of the given {@link View} in the given {@link RecyclerView}
*/
@FloatRange(from = 0.01f, to = 1f)
public static float calculateVisibleFraction(@NonNull RecyclerView recyclerView,
@NonNull View itemView,
float threshold) {
/*
* Special distributive measuring approach to handle the following issues:
*
* [ANDROID-1776]
* view just went off visible region will report visible width equals to
* the actual width of the width due to pre-caching
*
* [ANDROID-1786]
* Incorrect reporting of in/visible status on some OEMs
* issue caused by OEM custom implementation on how to define
* the left and right of a off visible region
*
* Stock OS define off visible region left as negative number,
* whereas some other OEM defines it as 0, so use #getLocationInWindow() instead
*/
Rect ivRect = new Rect();
itemView.getGlobalVisibleRect(ivRect);
if (ivRect.isEmpty()) {
return 0.01f;
}
Rect rvRect = new Rect();
recyclerView.getGlobalVisibleRect(rvRect);
int[] location = new int[2];
itemView.getLocationInWindow(location);
final boolean rtl = AbstractUIUtils.isRightToLeft(recyclerView.getContext());
final int width = itemView.getMeasuredWidth();
final int height = itemView.getMeasuredHeight();
// ratio for left bound
final float leftBoundRatio;
if (!rtl) {
// left to right languages
leftBoundRatio = 1f - threshold;
} else {
// right to left languages
leftBoundRatio = threshold;
}
final int left = (int) (rvRect.left - leftBoundRatio * width);
final int right = (int) (rvRect.right - (1f - leftBoundRatio) * width);
final int top = (int) (rvRect.top - (1f - threshold) * height);
final int bottom = (int) (rvRect.bottom - threshold * height);
// horizontally out of bound
final boolean hoob = location[0] < left || location[0] > right;
// vertically out of bound
final boolean voob = location[1] < top || location[1] > bottom;
if (hoob || voob) {
return 0.01f;
}
float wRatio = (float) ivRect.width() / width;
float hRatio = (float) ivRect.height() / height;
/*
* the non-moving direction will be always 1.0f,
* so the direction of interest is the smaller one of the two,
* and the final number is capped between 0.01f and 1.0f
*/
float percentage = Math.min(wRatio, hRatio);
percentage = Math.min(percentage, 1f);
percentage = Math.max(percentage, 0.01f);
return percentage;
}