本文整理匯總了Java中com.android.launcher3.Workspace類的典型用法代碼示例。如果您正苦於以下問題:Java Workspace類的具體用法?Java Workspace怎麽用?Java Workspace使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Workspace類屬於com.android.launcher3包,在下文中一共展示了Workspace類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDragBitmap
import com.android.launcher3.Workspace; //導入依賴的package包/類
/**
* Returns a new bitmap to show when the {@link #mView} is being dragged around.
* Responsibility for the bitmap is transferred to the caller.
*/
public Bitmap createDragBitmap(Canvas canvas) {
Bitmap b;
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
b = Bitmap.createBitmap(bounds.width() + DRAG_BITMAP_PADDING,
bounds.height() + DRAG_BITMAP_PADDING, Bitmap.Config.ARGB_8888);
} else {
b = Bitmap.createBitmap(mView.getWidth() + DRAG_BITMAP_PADDING,
mView.getHeight() + DRAG_BITMAP_PADDING, Bitmap.Config.ARGB_8888);
}
canvas.setBitmap(b);
drawDragView(canvas);
canvas.setBitmap(null);
return b;
}
示例2: drawPageHints
import com.android.launcher3.Workspace; //導入依賴的package包/類
private void drawPageHints(Canvas canvas) {
if (mShowPageHints) {
Workspace workspace = mLauncher.getWorkspace();
int width = getMeasuredWidth();
int page = workspace.getNextPage();
CellLayout leftPage = (CellLayout) workspace.getChildAt(mIsRtl ? page + 1 : page - 1);
CellLayout rightPage = (CellLayout) workspace.getChildAt(mIsRtl ? page - 1 : page + 1);
if (leftPage != null && leftPage.isDragTarget()) {
Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ?
mLeftHoverDrawableActive : mLeftHoverDrawable;
left.setBounds(0, mScrollChildPosition.top,
left.getIntrinsicWidth(), mScrollChildPosition.bottom);
left.draw(canvas);
}
if (rightPage != null && rightPage.isDragTarget()) {
Drawable right = mInScrollArea && rightPage.getIsDragOverlapping() ?
mRightHoverDrawableActive : mRightHoverDrawable;
right.setBounds(width - right.getIntrinsicWidth(),
mScrollChildPosition.top, width, mScrollChildPosition.bottom);
right.draw(canvas);
}
}
}
示例3: migrateScreen0
import com.android.launcher3.Workspace; //導入依賴的package包/類
public void migrateScreen0() {
migrateScreen(Workspace.FIRST_SCREEN_ID);
ContentValues tempValues = new ContentValues();
for (DbEntry update : mUpdates) {
DbEntry org = mOriginalItems.get(update.id);
if (org.cellX != update.cellX || org.cellY != update.cellY
|| org.spanX != update.spanX || org.spanY != update.spanY) {
tempValues.clear();
update.addToContentValues(tempValues);
mDb.update(Favorites.TABLE_NAME, tempValues, "_id = ?",
new String[] {Long.toString(update.id)});
}
}
// Delete any carry over items as we are only migration a single screen.
for (DbEntry entry : mCarryOver) {
mEntryToRemove.add(entry.id);
}
if (!mEntryToRemove.isEmpty()) {
mDb.delete(Favorites.TABLE_NAME,
Utilities.createDbSelectionQuery(Favorites._ID, mEntryToRemove), null);
}
}
示例4: DragPreviewProvider
import com.android.launcher3.Workspace; //導入依賴的package包/類
public DragPreviewProvider(View view) {
mView = view;
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
previewPadding = DRAG_BITMAP_PADDING - bounds.left - bounds.top;
} else {
previewPadding = DRAG_BITMAP_PADDING;
}
}
示例5: drawDragView
import com.android.launcher3.Workspace; //導入依賴的package包/類
/**
* Draws the {@link #mView} into the given {@param destCanvas}.
*/
private void drawDragView(Canvas destCanvas) {
destCanvas.save();
if (mView instanceof TextView) {
Drawable d = Workspace.getTextViewIcon((TextView) mView);
Rect bounds = getDrawableBounds(d);
destCanvas.translate(DRAG_BITMAP_PADDING / 2 - bounds.left,
DRAG_BITMAP_PADDING / 2 - bounds.top);
d.draw(destCanvas);
} else {
final Rect clipRect = mTempRect;
mView.getDrawingRect(clipRect);
boolean textVisible = false;
if (mView instanceof FolderIcon) {
// For FolderIcons the text can bleed into the icon area, and so we need to
// hide the text completely (which can't be achieved by clipping).
if (((FolderIcon) mView).getTextVisible()) {
((FolderIcon) mView).setTextVisible(false);
textVisible = true;
}
}
destCanvas.translate(-mView.getScrollX() + DRAG_BITMAP_PADDING / 2,
-mView.getScrollY() + DRAG_BITMAP_PADDING / 2);
destCanvas.clipRect(clipRect, Op.REPLACE);
mView.draw(destCanvas);
// Restore text visibility of FolderIcon if necessary
if (textVisible) {
((FolderIcon) mView).setTextVisible(true);
}
}
destCanvas.restore();
}
示例6: setupViews
import com.android.launcher3.Workspace; //導入依賴的package包/類
public void setupViews(AllAppsContainerView appsView, Hotseat hotseat, Workspace workspace) {
mAppsView = appsView;
mHotseat = hotseat;
mWorkspace = workspace;
mHotseat.addOnLayoutChangeListener(this);
mHotseat.bringToFront();
mCaretController = new AllAppsCaretController(
mWorkspace.getPageIndicator().getCaretDrawable(), mLauncher);
}
示例7: onDropCompleted
import com.android.launcher3.Workspace; //導入依賴的package包/類
@Override
public void onDropCompleted(View target, DropTarget.DragObject d, boolean isFlingToDelete,
boolean success) {
if (isFlingToDelete || !success || (target != mLauncher.getWorkspace() &&
!(target instanceof DeleteDropTarget) && !(target instanceof Folder))) {
// Exit spring loaded mode if we have not successfully dropped or have not handled the
// drop in Workspace
mLauncher.exitSpringLoadedDragModeDelayed(true,
Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null);
}
mLauncher.unlockScreenOrientation(false);
// Display an error message if the drag failed due to there not being enough space on the
// target layout we were dropping on.
if (!success) {
boolean showOutOfSpaceMessage = false;
if (target instanceof Workspace && !mLauncher.getDragController().isDeferringDrag()) {
int currentScreen = mLauncher.getCurrentWorkspaceScreen();
Workspace workspace = (Workspace) target;
CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen);
ItemInfo itemInfo = d.dragInfo;
if (layout != null) {
showOutOfSpaceMessage =
!layout.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY);
}
}
if (showOutOfSpaceMessage) {
mLauncher.showOutOfSpaceMessage(false);
}
d.deferDragViewCleanupPostAnimation = false;
}
}
示例8: onAlarm
import com.android.launcher3.Workspace; //導入依賴的package包/類
public void onAlarm(Alarm alarm) {
if (mScreen != null) {
// Snap to the screen that we are hovering over now
Workspace w = mLauncher.getWorkspace();
int page = w.indexOfChild(mScreen);
if (page != w.getCurrentPage()) {
w.snapToPage(page);
}
} else {
mLauncher.getDragController().cancelDrag();
}
}
示例9: animateViewIntoPosition
import com.android.launcher3.Workspace; //導入依賴的package包/類
public void animateViewIntoPosition(DragView dragView, final View child, int duration,
final Runnable onFinishAnimationRunnable, View anchorView) {
ShortcutAndWidgetContainer parentChildren = (ShortcutAndWidgetContainer) child.getParent();
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams();
parentChildren.measureChild(child);
Rect r = new Rect();
getViewRectRelativeToSelf(dragView, r);
int coord[] = new int[2];
float childScale = child.getScaleX();
coord[0] = lp.x + (int) (child.getMeasuredWidth() * (1 - childScale) / 2);
coord[1] = lp.y + (int) (child.getMeasuredHeight() * (1 - childScale) / 2);
// Since the child hasn't necessarily been laid out, we force the lp to be updated with
// the correct coordinates (above) and use these to determine the final location
float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
// We need to account for the scale of the child itself, as the above only accounts for
// for the scale in parents.
scale *= childScale;
int toX = coord[0];
int toY = coord[1];
float toScale = scale;
if (child instanceof TextView) {
TextView tv = (TextView) child;
// Account for the source scale of the icon (ie. from AllApps to Workspace, in which
// the workspace may have smaller icon bounds).
toScale = scale / dragView.getIntrinsicIconScaleFactor();
// The child may be scaled (always about the center of the view) so to account for it,
// we have to offset the position by the scaled size. Once we do that, we can center
// the drag view about the scaled child view.
toY += Math.round(toScale * tv.getPaddingTop());
toY -= dragView.getMeasuredHeight() * (1 - toScale) / 2;
if (dragView.getDragVisualizeOffset() != null) {
toY -= Math.round(toScale * dragView.getDragVisualizeOffset().y);
}
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} else if (child instanceof FolderIcon) {
// Account for holographic blur padding on the drag view
toY += Math.round(scale * (child.getPaddingTop() - dragView.getDragRegionTop()));
toY -= scale * Workspace.DRAG_BITMAP_PADDING / 2;
toY -= (1 - scale) * dragView.getMeasuredHeight() / 2;
// Center in the x coordinate about the target's drawable
toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
} else {
toY -= (Math.round(scale * (dragView.getHeight() - child.getMeasuredHeight()))) / 2;
toX -= (Math.round(scale * (dragView.getMeasuredWidth()
- child.getMeasuredWidth()))) / 2;
}
final int fromX = r.left;
final int fromY = r.top;
child.setVisibility(INVISIBLE);
Runnable onCompleteRunnable = new Runnable() {
public void run() {
child.setVisibility(VISIBLE);
if (onFinishAnimationRunnable != null) {
onFinishAnimationRunnable.run();
}
}
};
animateViewIntoPosition(dragView, fromX, fromY, toX, toY, 1, 1, 1, toScale, toScale,
onCompleteRunnable, ANIMATION_END_DISAPPEAR, duration, anchorView);
}
示例10: showPageHints
import com.android.launcher3.Workspace; //導入依賴的package包/類
public void showPageHints() {
mShowPageHints = true;
Workspace workspace = mLauncher.getWorkspace();
getDescendantRectRelativeToSelf(workspace.getChildAt(workspace.numCustomPages()),
mScrollChildPosition);
invalidate();
}
示例11: drawChild
import com.android.launcher3.Workspace; //導入依賴的package包/類
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean ret = super.drawChild(canvas, child, drawingTime);
// We want to draw the page hints above the workspace, but below the drag view.
if (child instanceof Workspace) {
drawPageHints(canvas);
}
return ret;
}
示例12: OverviewScreenAccessibilityDelegate
import com.android.launcher3.Workspace; //導入依賴的package包/類
public OverviewScreenAccessibilityDelegate(Workspace workspace) {
mWorkspace = workspace;
Context context = mWorkspace.getContext();
boolean isRtl = Utilities.isRtl(context.getResources());
mActions.put(MOVE_BACKWARD, new AccessibilityAction(MOVE_BACKWARD,
context.getText(isRtl ? R.string.action_move_screen_right :
R.string.action_move_screen_left)));
mActions.put(MOVE_FORWARD, new AccessibilityAction(MOVE_FORWARD,
context.getText(isRtl ? R.string.action_move_screen_left :
R.string.action_move_screen_right)));
}
示例13: beginAccessibleDrag
import com.android.launcher3.Workspace; //導入依賴的package包/類
public void beginAccessibleDrag(View item, ItemInfo info) {
mDragInfo = new DragInfo();
mDragInfo.info = info;
mDragInfo.item = item;
mDragInfo.dragType = DragType.ICON;
if (info instanceof FolderInfo) {
mDragInfo.dragType = DragType.FOLDER;
} else if (info instanceof LauncherAppWidgetInfo) {
mDragInfo.dragType = DragType.WIDGET;
}
CellLayout.CellInfo cellInfo = new CellLayout.CellInfo(item, info);
Rect pos = new Rect();
mLauncher.getDragLayer().getDescendantRectRelativeToSelf(item, pos);
mLauncher.getDragController().prepareAccessibleDrag(pos.centerX(), pos.centerY());
Workspace workspace = mLauncher.getWorkspace();
Folder folder = workspace.getOpenFolder();
if (folder != null) {
if (!folder.getItemsInReadingOrder().contains(item)) {
mLauncher.closeFolder();
folder = null;
}
}
mLauncher.getDragController().addDragListener(this);
DragOptions options = new DragOptions();
options.isAccessibleDrag = true;
if (folder != null) {
folder.startDrag(cellInfo.cell, options);
} else {
workspace.startDrag(cellInfo, options);
}
}
示例14: WallpaperOffsetInterpolator
import com.android.launcher3.Workspace; //導入依賴的package包/類
public WallpaperOffsetInterpolator(Workspace workspace) {
mChoreographer = Choreographer.getInstance();
mInterpolator = new DecelerateInterpolator(1.5f);
mWorkspace = workspace;
mWallpaperManager = WallpaperManager.getInstance(workspace.getContext());
mIsRtl = Utilities.isRtl(workspace.getResources());
}
示例15: onDropCompleted
import com.android.launcher3.Workspace; //導入依賴的package包/類
@Override
public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete,
boolean success) {
if (LOGD) {
Log.d(TAG, "onDropCompleted");
}
if (isFlingToDelete || !success || (target != mLauncher.getWorkspace() &&
!(target instanceof DeleteDropTarget) && !(target instanceof Folder))) {
// Exit spring loaded mode if we have not successfully dropped or have not handled the
// drop in Workspace
mLauncher.exitSpringLoadedDragModeDelayed(true,
Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null);
}
mLauncher.unlockScreenOrientation(false);
// Display an error message if the drag failed due to there not being enough space on the
// target layout we were dropping on.
if (!success) {
boolean showOutOfSpaceMessage = false;
if (target instanceof Workspace) {
int currentScreen = mLauncher.getCurrentWorkspaceScreen();
Workspace workspace = (Workspace) target;
CellLayout layout = (CellLayout) workspace.getChildAt(currentScreen);
ItemInfo itemInfo = d.dragInfo;
if (layout != null) {
showOutOfSpaceMessage =
!layout.findCellForSpan(null, itemInfo.spanX, itemInfo.spanY);
}
}
if (showOutOfSpaceMessage) {
mLauncher.showOutOfSpaceMessage(false);
}
d.deferDragViewCleanupPostAnimation = false;
}
}