Java Code Examples for android.graphics.Point#equals()

The following examples show how to use android.graphics.Point#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CaptureVideoActivity.java    From NIM_Android_UIKit with MIT License 6 votes vote down vote up
private void resizeSurfaceView() {
    Point point;
    if (cameraId == 0) {
        point = backCameraSize.getFirst();
    } else {
        point = frontCameraSize.getFirst();
    }
    if (currentUsePoint != null && point.equals(currentUsePoint)) {
        return;
    } else {
        currentUsePoint = point;
        int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
        int surfaceHeight = screenWidth * point.x / point.y;
        if (surfaceview != null) {
            RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) surfaceview.getLayoutParams();
            lp.width = screenWidth;
            lp.height = surfaceHeight;
            lp.addRule(13);
            surfaceview.setLayoutParams(lp);
        }
    }
}
 
Example 2
Source File: CacheHelper.java    From AndroidLibs with GNU General Public License v3.0 6 votes vote down vote up
public void setItem(int index, Point newSize) {
	if (!valid()) {
		return;
	}
	if (sizeMap.get(index, null) != null) {
		Point cachedPoint = sizeMap.get(index);
		if (!cachedPoint.equals(newSize)) {
			invalidateLineMapAfter(index);
			sizeMap.put(index, newSize);
			refreshLineMap();
		}
	} else {
		invalidateLineMapAfter(index);
		sizeMap.put(index, newSize);
		refreshLineMap();
	}
}
 
Example 3
Source File: GridSizeMigrationTask.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
boolean migrate(Point sourceSize, Point targetSize) throws Exception {
    boolean dbChanged = false;
    if (!targetSize.equals(sourceSize)) {
        if (sourceSize.x < targetSize.x) {
            // Source is smaller that target, just expand the grid without actual migration.
            sourceSize.x = targetSize.x;
        }
        if (sourceSize.y < targetSize.y) {
            // Source is smaller that target, just expand the grid without actual migration.
            sourceSize.y = targetSize.y;
        }

        // Migrate the workspace grid, such that the points differ by max 1 in x and y
        // each on every step.
        while (!targetSize.equals(sourceSize)) {
            // Get the next size, such that the points differ by max 1 in x and y each
            Point nextSize = new Point(sourceSize);
            if (targetSize.x < nextSize.x) {
                nextSize.x--;
            }
            if (targetSize.y < nextSize.y) {
                nextSize.y--;
            }
            if (runStepTask(sourceSize, nextSize)) {
                dbChanged = true;
            }
            sourceSize.set(nextSize.x, nextSize.y);
        }
    }
    return dbChanged;
}
 
Example 4
Source File: DocumentsApplication.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public static ThumbnailCache getThumbnailsCache(Context context, Point size) {
    final DocumentsApplication app = (DocumentsApplication) context.getApplicationContext();
    final ThumbnailCache thumbnails = app.mThumbnails;
    if (!size.equals(app.mThumbnailsSize)) {
        thumbnails.evictAll();
        app.mThumbnailsSize = size;
    }
    return thumbnails;
}
 
Example 5
Source File: DocumentsApplication.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public static ThumbnailCache getThumbnailsCache(Context context, Point size) {
    final DocumentsApplication app = (DocumentsApplication) context.getApplicationContext();
    final ThumbnailCache thumbnails = app.mThumbnails;
    if (!size.equals(app.mThumbnailsSize)) {
        thumbnails.evictAll();
        app.mThumbnailsSize = size;
    }
    return thumbnails;
}
 
Example 6
Source File: DocumentsApplication.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public static ThumbnailCache getThumbnailsCache(Context context, Point size) {
    final DocumentsApplication app = (DocumentsApplication) context.getApplicationContext();
    final ThumbnailCache thumbnails = app.mThumbnails;
    if (!size.equals(app.mThumbnailsSize)) {
        thumbnails.evictAll();
        app.mThumbnailsSize = size;
    }
    return thumbnails;
}
 
Example 7
Source File: ZoomPanLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void constrainScroll() { // TODO:
	Point currentScroll = new Point( getScrollX(), getScrollY() );
	Point limitScroll = new Point( currentScroll );
	constrainPoint( limitScroll );
	if ( !currentScroll.equals( limitScroll ) ) {
		scrollToPoint( limitScroll );
	}
}
 
Example 8
Source File: PDFPageView.java    From Reader with Apache License 2.0 4 votes vote down vote up
@Override
public void updateHq(boolean update) {
    Rect viewArea = new Rect(getLeft(), getTop(), getRight(), getBottom());
    if (viewArea.width() == mSize.x || viewArea.height() == mSize.y) {
        // If the viewArea's size matches the unzoomed size, there is no need for an hq patch
        if (mPatch != null) {
            mPatch.setImageBitmap(null);
            mPatch.invalidate();
        }
    } else {
        //当前Pageview的实际大小
        final Point patchViewSize = new Point(viewArea.width(), viewArea.height());
        //表示实际要显示pdf的区域,也就是pdf与屏幕的重叠处
        final Rect patchArea = new Rect(0, 0, mParentSize.x, mParentSize.y);

        // Intersect and test that there is an intersection
        if (!patchArea.intersect(viewArea)) {
            return;
        }

        //重新计算重叠处的坐标,这个坐标是相对于当前PDF实际大小
        // Offset patch area to be relative to the view top left
        patchArea.offset(-viewArea.left, -viewArea.top);
        boolean area_unchanged = patchArea.equals(mPatchArea) && patchViewSize.equals(mPatchViewSize);

        // If being asked for the same area as last time and not because of an update then nothing to do
        if (area_unchanged && !update)
            return;
        boolean completeRedraw = !(area_unchanged && update);
        // Stop the drawing of previous patch if still going
        if (mDrawPatch != null) {
            mDrawPatch.cancelAndWait();
            mDrawPatch = null;
        }

        // Create and add the image view if not already done
        if (mPatch == null) {
            mPatch = new OpaqueImageView(mContext);
            mPatch.setScaleType(ImageView.ScaleType.MATRIX);
            addView(mPatch);
            mSearchView.bringToFront();
        }

        CancellableTaskDefinition<Void, Void> task;

        if (completeRedraw) {
            task = getDrawPageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
                    patchArea.left, patchArea.top,
                    patchArea.width(), patchArea.height());
        } else {
            task = getUpdatePageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
                    patchArea.left, patchArea.top,
                    patchArea.width(), patchArea.height());
        }

        mDrawPatch = new CancellableAsyncTask<Void, Void>(task) {

            public void onPostExecute(Void result) {
                mPatchViewSize = patchViewSize;
                mPatchArea = patchArea;
                mPatch.setImageBitmap(mPatchBm);
                mPatch.invalidate();
                //requestLayout();
                // Calling requestLayout here doesn't lead to a later call to layout. No idea
                // why, but apparently others have run into the problem.
                mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom);
            }
        };

        mDrawPatch.execute();
    }
}
 
Example 9
Source File: PageView.java    From PowerFileExplorer with GNU General Public License v3.0 4 votes vote down vote up
public void updateHq(boolean update) {
	Rect viewArea = new Rect(getLeft(), getTop(), getRight(), getBottom());
	if (viewArea.width() == mSize.x || viewArea.height() == mSize.y) {
		// If the viewArea's size matches the unzoomed size, there is no need for an hq patch
		if (mPatch != null) {
			mPatch.setImageBitmap(null);
			mPatch.invalidate();
		}
	} else {
		final Point patchViewSize = new Point(viewArea.width(), viewArea.height());
		final Rect patchArea = new Rect(0, 0, mParentSize.x, mParentSize.y);

		// Intersect and test that there is an intersection
		if (!patchArea.intersect(viewArea))
			return;

		// Offset patch area to be relative to the view top left
		patchArea.offset(-viewArea.left, -viewArea.top);

		boolean area_unchanged = patchArea.equals(mPatchArea) && patchViewSize.equals(mPatchViewSize);

		// If being asked for the same area as last time and not because of an update then nothing to do
		if (area_unchanged && !update)
			return;

		boolean completeRedraw = !(area_unchanged && update);

		// Stop the drawing of previous patch if still going
		if (mDrawPatch != null) {
			mDrawPatch.cancel();
			mDrawPatch = null;
		}

		// Create and add the image view if not already done
		if (mPatch == null) {
			mPatch = new OpaqueImageView(mContext);
			mPatch.setScaleType(ImageView.ScaleType.MATRIX);
			addView(mPatch);
			mSearchView.bringToFront();
		}

		CancellableTaskDefinition<Void, Void> task;

		if (completeRedraw)
			task = getDrawPageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
								   patchArea.left, patchArea.top,
								   patchArea.width(), patchArea.height());
		else
			task = getUpdatePageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
									 patchArea.left, patchArea.top,
									 patchArea.width(), patchArea.height());

		mDrawPatch = new CancellableAsyncTask<Void,Void>(task) {

			public void onPostExecute(Void result) {
				mPatchViewSize = patchViewSize;
				mPatchArea = patchArea;
				mPatch.setImageBitmap(mPatchBm);
				mPatch.invalidate();
				//requestLayout();
				// Calling requestLayout here doesn't lead to a later call to layout. No idea
				// why, but apparently others have run into the problem.
				mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom);
			}
		};

		mDrawPatch.execute();
	}
}
 
Example 10
Source File: PageView.java    From AndroidDocumentViewer with MIT License 4 votes vote down vote up
public void updateHq(boolean update) {
    Rect viewArea = new Rect(getLeft(), getTop(), getRight(), getBottom());
    if (viewArea.width() == mSize.x || viewArea.height() == mSize.y) {
        // If the viewArea's size matches the unzoomed size, there is no need for an hq patch
        if (mPatch != null) {
            mPatch.setImageBitmap(null);
            mPatch.invalidate();
        }
    } else {
        final Point patchViewSize = new Point(viewArea.width(), viewArea.height());
        final Rect patchArea = new Rect(0, 0, mParentSize.x, mParentSize.y);

        // Intersect and test that there is an intersection
        if (!patchArea.intersect(viewArea))
            return;

        // Offset patch area to be relative to the view top left
        patchArea.offset(-viewArea.left, -viewArea.top);

        boolean area_unchanged = patchArea.equals(mPatchArea) && patchViewSize.equals(mPatchViewSize);

        // If being asked for the same area as last time and not because of an update then nothing to do
        if (area_unchanged && !update)
            return;

        boolean completeRedraw = !(area_unchanged && update);

        // Stop the drawing of previous patch if still going
        if (mDrawPatch != null) {
            mDrawPatch.cancel();
            mDrawPatch = null;
        }

        // Create and add the image view if not already done
        if (mPatch == null) {
            mPatch = new OpaqueImageView(mContext);
            mPatch.setScaleType(ImageView.ScaleType.MATRIX);
            addView(mPatch);
            mSearchView.bringToFront();
        }

        CancellableTaskDefinition<Void, Void> task;

        if (completeRedraw)
            task = getDrawPageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
                    patchArea.left, patchArea.top,
                    patchArea.width(), patchArea.height());
        else
            task = getUpdatePageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
                    patchArea.left, patchArea.top,
                    patchArea.width(), patchArea.height());

        mDrawPatch = new CancellableAsyncTask<Void, Void>(task) {

            public void onPostExecute(Void result) {
                mPatchViewSize = patchViewSize;
                mPatchArea = patchArea;
                mPatch.setImageBitmap(mPatchBm);
                mPatch.invalidate();
                //requestLayout();
                // Calling requestLayout here doesn't lead to a later call to layout. No idea
                // why, but apparently others have run into the problem.
                mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom);
            }
        };

        mDrawPatch.execute();
    }
}
 
Example 11
Source File: PageView.java    From AndroidMuPDF with Apache License 2.0 4 votes vote down vote up
public void updateHq(boolean update) {
	Rect viewArea = new Rect(getLeft(),getTop(),getRight(),getBottom());
	if (viewArea.width() == mSize.x || viewArea.height() == mSize.y) {
		// If the viewArea's size matches the unzoomed size, there is no need for an hq patch
		if (mPatch != null) {
			mPatch.setImageBitmap(null);
			mPatch.invalidate();
		}
	} else {
		final Point patchViewSize = new Point(viewArea.width(), viewArea.height());
		final Rect patchArea = new Rect(0, 0, mParentSize.x, mParentSize.y);

		// Intersect and test that there is an intersection
		if (!patchArea.intersect(viewArea))
			return;

		// Offset patch area to be relative to the view top left
		patchArea.offset(-viewArea.left, -viewArea.top);

		boolean area_unchanged = patchArea.equals(mPatchArea) && patchViewSize.equals(mPatchViewSize);

		// If being asked for the same area as last time and not because of an update then nothing to do
		if (area_unchanged && !update)
			return;

		boolean completeRedraw = !(area_unchanged && update);

		// Stop the drawing of previous patch if still going
		if (mDrawPatch != null) {
			mDrawPatch.cancel();
			mDrawPatch = null;
		}

		// Create and add the image view if not already done
		if (mPatch == null) {
			mPatch = new OpaqueImageView(mContext);
			mPatch.setScaleType(ImageView.ScaleType.MATRIX);
			addView(mPatch);
			mSearchView.bringToFront();
		}

		CancellableTaskDefinition<Void, Void> task;

		if (completeRedraw)
			task = getDrawPageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
							patchArea.left, patchArea.top,
							patchArea.width(), patchArea.height());
		else
			task = getUpdatePageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
					patchArea.left, patchArea.top,
					patchArea.width(), patchArea.height());

		mDrawPatch = new CancellableAsyncTask<Void,Void>(task) {

			public void onPostExecute(Void result) {
				mPatchViewSize = patchViewSize;
				mPatchArea = patchArea;
				mPatch.setImageBitmap(mPatchBm);
				mPatch.invalidate();
				//requestLayout();
				// Calling requestLayout here doesn't lead to a later call to layout. No idea
				// why, but apparently others have run into the problem.
				mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom);
			}
		};

		mDrawPatch.execute();
	}
}
 
Example 12
Source File: CellContainer.java    From openlauncher with Apache License 2.0 4 votes vote down vote up
public final LayoutParams coordinateToLayoutParams(int mX, int mY, int xSpan, int ySpan) {
    Point pos = new Point();
    touchPosToCoordinate(pos, mX, mY, xSpan, ySpan, true);
    return !pos.equals(-1, -1) ? new LayoutParams(WRAP_CONTENT, WRAP_CONTENT, pos.x, pos.y, xSpan, ySpan) : null;
}
 
Example 13
Source File: PageView.java    From Mupdf with Apache License 2.0 4 votes vote down vote up
public void updateHq(boolean update) {
	Rect viewArea = new Rect(getLeft(),getTop(),getRight(),getBottom());
	if (viewArea.width() == mSize.x || viewArea.height() == mSize.y) {
		// If the viewArea's size matches the unzoomed size, there is no need for an hq patch
		if (mPatch != null) {
			mPatch.setImageBitmap(null);
			mPatch.invalidate();
		}
	} else {
		final Point patchViewSize = new Point(viewArea.width(), viewArea.height());
		final Rect patchArea = new Rect(0, 0, mParentSize.x, mParentSize.y);

		// Intersect and test that there is an intersection
		if (!patchArea.intersect(viewArea))
			return;

		// Offset patch area to be relative to the view top left
		patchArea.offset(-viewArea.left, -viewArea.top);

		boolean area_unchanged = patchArea.equals(mPatchArea) && patchViewSize.equals(mPatchViewSize);

		// If being asked for the same area as last time and not because of an update then nothing to do
		if (area_unchanged && !update)
			return;

		boolean completeRedraw = !(area_unchanged && update);

		// Stop the drawing of previous patch if still going
		if (mDrawPatch != null) {
			mDrawPatch.cancel();
			mDrawPatch = null;
		}

		// Create and add the image view if not already done
		if (mPatch == null) {
			mPatch = new OpaqueImageView(mContext);
			mPatch.setScaleType(ImageView.ScaleType.MATRIX);
			addView(mPatch);
			mSearchView.bringToFront();
		}

		CancellableTaskDefinition<Void, Void> task;

		if (completeRedraw)
			task = getDrawPageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
							patchArea.left, patchArea.top,
							patchArea.width(), patchArea.height());
		else
			task = getUpdatePageTask(mPatchBm, patchViewSize.x, patchViewSize.y,
					patchArea.left, patchArea.top,
					patchArea.width(), patchArea.height());

		mDrawPatch = new CancellableAsyncTask<Void,Void>(task) {

			public void onPostExecute(Void result) {
				mPatchViewSize = patchViewSize;
				mPatchArea = patchArea;
				mPatch.setImageBitmap(mPatchBm);
				mPatch.invalidate();
				//requestLayout();
				// Calling requestLayout here doesn't lead to a later call to layout. No idea
				// why, but apparently others have run into the problem.
				mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom);
			}
		};

		mDrawPatch.execute();
	}
}