當前位置: 首頁>>代碼示例>>Java>>正文


Java Rect.isEmpty方法代碼示例

本文整理匯總了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());
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:37,代碼來源:AbsHListView.java

示例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);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:18,代碼來源:ExploreByTouchHelper.java

示例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());
		}
	}
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:44,代碼來源:AbsHListView.java

示例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());
    }
}
 
開發者ID:noties,項目名稱:Markwon,代碼行數:17,代碼來源:AsyncDrawableSpan.java

示例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;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:25,代碼來源:GestureTrailsDrawingPreview.java

示例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);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:40,代碼來源:BaseLayoutHelper.java

示例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;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:11,代碼來源:WXVideoView.java

示例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);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:8,代碼來源:Slate.java

示例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);
        }
    }
}
 
開發者ID:StickyTolt,項目名稱:ForeverLibrary,代碼行數:12,代碼來源:FastBitmapDrawable.java

示例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;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:9,代碼來源:AnimUtil.java

示例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);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:45,代碼來源:RangeStyle.java

示例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);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:61,代碼來源:Tab.java

示例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;
}
 
開發者ID:Tenor-Inc,項目名稱:tenor-android-core,代碼行數:81,代碼來源:MeasurableViewHolderHelper.java


注:本文中的android.graphics.Rect.isEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。