本文整理匯總了Java中com.android.launcher3.LauncherAppWidgetHostView類的典型用法代碼示例。如果您正苦於以下問題:Java LauncherAppWidgetHostView類的具體用法?Java LauncherAppWidgetHostView怎麽用?Java LauncherAppWidgetHostView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LauncherAppWidgetHostView類屬於com.android.launcher3包,在下文中一共展示了LauncherAppWidgetHostView類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addResizeFrame
import com.android.launcher3.LauncherAppWidgetHostView; //導入依賴的package包/類
public void addResizeFrame(ItemInfo itemInfo, LauncherAppWidgetHostView widget,
CellLayout cellLayout) {
AppWidgetResizeFrame resizeFrame = new AppWidgetResizeFrame(getContext(),
widget, cellLayout, this);
LayoutParams lp = new LayoutParams(-1, -1);
lp.customPosition = true;
addView(resizeFrame, lp);
mResizeFrames.add(resizeFrame);
resizeFrame.snapToWidget(false);
}
示例2: getSupportedResizeActions
import com.android.launcher3.LauncherAppWidgetHostView; //導入依賴的package包/類
private ArrayList<Integer> getSupportedResizeActions(View host, LauncherAppWidgetInfo info) {
ArrayList<Integer> actions = new ArrayList<>();
AppWidgetProviderInfo providerInfo = ((LauncherAppWidgetHostView) host).getAppWidgetInfo();
if (providerInfo == null) {
return actions;
}
CellLayout layout = (CellLayout) host.getParent().getParent();
if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0) {
if (layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY) ||
layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY)) {
actions.add(R.string.action_increase_width);
}
if (info.spanX > info.minSpanX && info.spanX > 1) {
actions.add(R.string.action_decrease_width);
}
}
if ((providerInfo.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0) {
if (layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1) ||
layout.isRegionVacant(info.cellX, info.cellY - 1, info.spanX, 1)) {
actions.add(R.string.action_increase_height);
}
if (info.spanY > info.minSpanY && info.spanY > 1) {
actions.add(R.string.action_decrease_height);
}
}
return actions;
}
示例3: performResizeAction
import com.android.launcher3.LauncherAppWidgetHostView; //導入依賴的package包/類
@Thunk void performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams();
CellLayout layout = (CellLayout) host.getParent().getParent();
layout.markCellsAsUnoccupiedForView(host);
if (action == R.string.action_increase_width) {
if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL)
&& layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY))
|| !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) {
lp.cellX --;
info.cellX --;
}
lp.cellHSpan ++;
info.spanX ++;
} else if (action == R.string.action_decrease_width) {
lp.cellHSpan --;
info.spanX --;
} else if (action == R.string.action_increase_height) {
if (!layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1)) {
lp.cellY --;
info.cellY --;
}
lp.cellVSpan ++;
info.spanY ++;
} else if (action == R.string.action_decrease_height) {
lp.cellVSpan --;
info.spanY --;
}
layout.markCellsAsOccupiedForView(host);
Rect sizeRange = new Rect();
AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, sizeRange);
((LauncherAppWidgetHostView) host).updateAppWidgetSize(null,
sizeRange.left, sizeRange.top, sizeRange.right, sizeRange.bottom);
host.requestLayout();
LauncherModel.updateItemInDatabase(mLauncher, info);
announceConfirmation(mLauncher.getString(R.string.widget_resized, info.spanX, info.spanY));
}