List of usage examples for android.view View getTag
@ViewDebug.ExportedProperty
public Object getTag()
From source file:com.nttec.everychan.ui.presentation.BoardFragment.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); //? ? -/*w ww . j av a2 s .c o m*/ if (v.getTag() != null && v.getTag() instanceof AttachmentModel) { lastContextMenuAttachment = v; AttachmentModel model = (AttachmentModel) v.getTag(); View tnView = v.findViewById(R.id.post_thumbnail_image); if (tnView != null && tnView.getTag() == Boolean.FALSE && !downloadThumbnails()) { menu.add(Menu.NONE, R.id.context_menu_thumb_load_thumb, 1, R.string.context_menu_show_thumbnail) .setOnMenuItemClickListener(contextMenuListener); } menu.add(Menu.NONE, R.id.context_menu_thumb_download, 2, R.string.context_menu_download_file); menu.add(Menu.NONE, R.id.context_menu_thumb_copy_url, 3, R.string.context_menu_copy_url); menu.add(Menu.NONE, R.id.context_menu_thumb_attachment_info, 4, R.string.context_menu_attachment_info); menu.add(Menu.NONE, R.id.context_menu_thumb_reverse_search, 5, R.string.context_menu_reverse_search); for (int id : new int[] { R.id.context_menu_thumb_download, R.id.context_menu_thumb_copy_url, R.id.context_menu_thumb_attachment_info, R.id.context_menu_thumb_reverse_search }) { menu.findItem(id).setOnMenuItemClickListener(contextMenuListener); } switch (model.type) { case AttachmentModel.TYPE_AUDIO: case AttachmentModel.TYPE_VIDEO: case AttachmentModel.TYPE_OTHER_FILE: menu.findItem(R.id.context_menu_thumb_reverse_search).setVisible(false); break; case AttachmentModel.TYPE_OTHER_NOTFILE: menu.findItem(R.id.context_menu_thumb_reverse_search).setVisible(false); menu.findItem(R.id.context_menu_thumb_download).setVisible(false); break; } if (tabModel.type == TabModel.TYPE_LOCAL) { menu.findItem(R.id.context_menu_thumb_download).setVisible(false); } return; } if (menu.findItem(R.id.context_menu_thumb_copy_url) != null) return; //? ? ? boolean isList = true; lastContextMenuPosition = -1; final PresentationItemModel model; if (v.getId() == android.R.id.list) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; model = adapter.getItem(info.position); if (model.hidden) { return; } } else { if (v.getTag() != null && v.getTag() instanceof PostsListAdapter.PostViewTag) { PostsListAdapter.PostViewTag tag = (PostsListAdapter.PostViewTag) v.getTag(); if (!tag.isPopupDialog) return; isList = false; lastContextMenuPosition = tag.position; model = adapter.getItem(lastContextMenuPosition); } else { return; } } if (pageType == TYPE_POSTSLIST) { menu.add(Menu.NONE, R.id.context_menu_reply, 1, R.string.context_menu_reply); menu.add(Menu.NONE, R.id.context_menu_reply_with_quote, 2, R.string.context_menu_reply_with_quote); menu.add(Menu.NONE, R.id.context_menu_select_text, 3, Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && isList ? R.string.context_menu_select_text : R.string.context_menu_copy_text); menu.add(Menu.NONE, R.id.context_menu_share, 4, R.string.context_menu_share); menu.add(Menu.NONE, R.id.context_menu_hide, 5, R.string.context_menu_hide_post); menu.add(Menu.NONE, R.id.context_menu_delete, 6, R.string.context_menu_delete); menu.add(Menu.NONE, R.id.context_menu_report, 7, R.string.context_menu_report); menu.add(Menu.NONE, R.id.context_menu_subscribe, 8, R.string.context_menu_subscribe); if (!isList) { for (int id : new int[] { R.id.context_menu_reply, R.id.context_menu_reply_with_quote, R.id.context_menu_select_text, R.id.context_menu_share, R.id.context_menu_hide, R.id.context_menu_delete, R.id.context_menu_report, R.id.context_menu_subscribe }) { menu.findItem(id).setOnMenuItemClickListener(contextMenuListener); } } if (presentationModel.source.boardModel.readonlyBoard || tabModel.type == TabModel.TYPE_LOCAL) { menu.findItem(R.id.context_menu_reply).setVisible(false); menu.findItem(R.id.context_menu_reply_with_quote).setVisible(false); } if (model.isDeleted || (!presentationModel.source.boardModel.allowDeletePosts && (!presentationModel.source.boardModel.allowDeleteFiles || model.sourceModel.attachments == null || model.sourceModel.attachments.length == 0)) || tabModel.type == TabModel.TYPE_LOCAL) { menu.findItem(R.id.context_menu_delete).setVisible(false); } if (model.isDeleted || presentationModel.source.boardModel.allowReport == BoardModel.REPORT_NOT_ALLOWED || tabModel.type == TabModel.TYPE_LOCAL) { menu.findItem(R.id.context_menu_report).setVisible(false); } if (settings.isSubscriptionsEnabled()) { if (subscriptions.hasSubscription(chan.getChanName(), presentationModel.source.boardModel.boardName, presentationModel.source.pageModel.threadNumber, model.sourceModel.number)) { menu.findItem(R.id.context_menu_subscribe).setTitle(R.string.context_menu_unsubscribe); } } else { menu.findItem(R.id.context_menu_subscribe).setVisible(false); } } else if (pageType == TYPE_THREADSLIST && isList) { menu.add(Menu.NONE, R.id.context_menu_open_in_new_tab, 1, R.string.context_menu_open_in_new_tab); menu.add(Menu.NONE, R.id.context_menu_thread_preview, 2, R.string.context_menu_thread_preview); menu.add(Menu.NONE, R.id.context_menu_reply_no_reading, 3, R.string.context_menu_reply_no_reading); menu.add(Menu.NONE, R.id.context_menu_hide, 4, R.string.context_menu_hide_thread); if (presentationModel.source.boardModel.readonlyBoard || tabModel.type == TabModel.TYPE_LOCAL) { menu.findItem(R.id.context_menu_reply_no_reading).setVisible(false); } } }
From source file:cc.flydev.launcher.Workspace.java
public View getViewForTag(Object tag) { ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers(); for (ShortcutAndWidgetContainer layout : childrenLayouts) { int count = layout.getChildCount(); for (int i = 0; i < count; i++) { View child = layout.getChildAt(i); if (child.getTag() == tag) { return child; }//from ww w.j a v a2s . co m } } return null; }
From source file:cc.flydev.launcher.Workspace.java
protected void reinflateWidgetsIfNecessary() { final int clCount = getChildCount(); for (int i = 0; i < clCount; i++) { CellLayout cl = (CellLayout) getChildAt(i); ShortcutAndWidgetContainer swc = cl.getShortcutsAndWidgets(); final int itemCount = swc.getChildCount(); for (int j = 0; j < itemCount; j++) { View v = swc.getChildAt(j); if (v.getTag() instanceof LauncherAppWidgetInfo) { LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag(); LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView; if (lahv != null && lahv.orientationChangedSincedInflation()) { mLauncher.removeAppWidget(info); // Remove the current widget which is inflated with the wrong orientation cl.removeView(lahv); mLauncher.bindAppWidget(info); }/*from w w w . j a va 2 s . c o m*/ } } } }
From source file:com.android.leanlauncher.Workspace.java
public void beginDragShared(View child, DragSource source) { child.clearFocus();/* www. j a v a 2s . co m*/ child.setPressed(false); // The outline is used to visualize where the item will land if dropped mDragOutline = createDragOutline(child, DRAG_BITMAP_PADDING); mLauncher.onDragStarted(child); // The drag bitmap follows the touch point around on the screen AtomicInteger padding = new AtomicInteger(DRAG_BITMAP_PADDING); final Bitmap b = createDragBitmap(child, padding); final int bmpWidth = b.getWidth(); final int bmpHeight = b.getHeight(); float scale = mLauncher.getDragLayer().getLocationInDragLayer(child, mTempXY); int dragLayerX = Math.round(mTempXY[0] - (bmpWidth - scale * child.getWidth()) / 2); int dragLayerY = Math.round(mTempXY[1] - (bmpHeight - scale * bmpHeight) / 2 - padding.get() / 2); LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); Point dragVisualizeOffset = null; Rect dragRect = null; if (child instanceof BubbleTextView) { int iconSize = grid.iconSizePx; int top = child.getPaddingTop(); int left = (bmpWidth - iconSize) / 2; int right = left + iconSize; int bottom = top + iconSize; dragLayerY += top; // Note: The drag region is used to calculate drag layer offsets, but the // dragVisualizeOffset in addition to the dragRect (the size) to position the outline. dragVisualizeOffset = new Point(-padding.get() / 2, padding.get() / 2); dragRect = new Rect(left, top, right, bottom); } // Clear the pressed state if necessary if (child instanceof BubbleTextView) { BubbleTextView icon = (BubbleTextView) child; icon.clearPressedBackground(); } if (child.getTag() == null || !(child.getTag() instanceof ItemInfo)) { String msg = "Drag started with a view that has no tag set. This " + "will cause a crash (issue 11627249) down the line. " + "View: " + child + " tag: " + child.getTag(); throw new IllegalStateException(msg); } DragView dv = mDragController.startDrag(b, dragLayerX, dragLayerY, source, child.getTag(), DragController.DRAG_ACTION_MOVE, dragVisualizeOffset, dragRect, scale); dv.setIntrinsicIconScaleFactor(source.getIntrinsicIconScaleFactor()); b.recycle(); }
From source file:cc.flydev.launcher.Workspace.java
void updateShortcuts(ArrayList<AppInfo> apps) { ArrayList<ShortcutAndWidgetContainer> childrenLayouts = getAllShortcutAndWidgetContainers(); for (ShortcutAndWidgetContainer layout : childrenLayouts) { int childCount = layout.getChildCount(); for (int j = 0; j < childCount; j++) { final View view = layout.getChildAt(j); Object tag = view.getTag(); if (LauncherModel.isShortcutInfoUpdateable((ItemInfo) tag)) { ShortcutInfo info = (ShortcutInfo) tag; final Intent intent = info.intent; final ComponentName name = intent.getComponent(); final int appCount = apps.size(); for (int k = 0; k < appCount; k++) { AppInfo app = apps.get(k); if (app.componentName.equals(name)) { BubbleTextView shortcut = (BubbleTextView) view; info.updateIcon(mIconCache); info.title = app.title.toString(); shortcut.applyFromShortcutInfo(info, mIconCache); }/*from www . ja v a 2 s .c o m*/ } } } } }
From source file:cc.flydev.launcher.Workspace.java
void removeItemsByPackageName(final ArrayList<String> packages) { final HashSet<String> packageNames = new HashSet<String>(); packageNames.addAll(packages);/*from w w w . j a v a 2 s .com*/ // Filter out all the ItemInfos that this is going to affect final HashSet<ItemInfo> infos = new HashSet<ItemInfo>(); final HashSet<ComponentName> cns = new HashSet<ComponentName>(); ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts(); for (CellLayout layoutParent : cellLayouts) { ViewGroup layout = layoutParent.getShortcutsAndWidgets(); int childCount = layout.getChildCount(); for (int i = 0; i < childCount; ++i) { View view = layout.getChildAt(i); infos.add((ItemInfo) view.getTag()); } } LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() { @Override public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) { if (packageNames.contains(cn.getPackageName())) { cns.add(cn); return true; } return false; } }; LauncherModel.filterItemInfos(infos, filter); // Remove the affected components removeItemsByComponentName(cns); }
From source file:cc.flydev.launcher.Workspace.java
void updateItemLocationsInDatabase(CellLayout cl) { int count = cl.getShortcutsAndWidgets().getChildCount(); long screenId = getIdForScreen(cl); int container = Favorites.CONTAINER_DESKTOP; if (mLauncher.isHotseatLayout(cl)) { screenId = -1;//from w ww .j a va 2 s. com container = Favorites.CONTAINER_HOTSEAT; } for (int i = 0; i < count; i++) { View v = cl.getShortcutsAndWidgets().getChildAt(i); ItemInfo info = (ItemInfo) v.getTag(); // Null check required as the AllApps button doesn't have an item info if (info != null && info.requiresDbUpdate) { info.requiresDbUpdate = false; LauncherModel.modifyItemInDatabase(mLauncher, info, container, screenId, info.cellX, info.cellY, info.spanX, info.spanY); } } }
From source file:cc.flydev.launcher.Workspace.java
void saveWorkspaceScreenToDb(CellLayout cl) { int count = cl.getShortcutsAndWidgets().getChildCount(); long screenId = getIdForScreen(cl); int container = Favorites.CONTAINER_DESKTOP; Hotseat hotseat = mLauncher.getHotseat(); if (mLauncher.isHotseatLayout(cl)) { screenId = -1;/*w ww.j av a2s . c om*/ container = Favorites.CONTAINER_HOTSEAT; } for (int i = 0; i < count; i++) { View v = cl.getShortcutsAndWidgets().getChildAt(i); ItemInfo info = (ItemInfo) v.getTag(); // Null check required as the AllApps button doesn't have an item info if (info != null) { int cellX = info.cellX; int cellY = info.cellY; if (container == Favorites.CONTAINER_HOTSEAT) { cellX = hotseat.getCellXFromOrder((int) info.screenId); cellY = hotseat.getCellYFromOrder((int) info.screenId); } LauncherModel.addItemToDatabase(mLauncher, info, container, screenId, cellX, cellY, false); } if (v instanceof FolderIcon) { FolderIcon fi = (FolderIcon) v; fi.getFolder().addItemLocationsInDatabase(); } } }
From source file:cc.flydev.launcher.Workspace.java
void removeItemsByComponentName(final HashSet<ComponentName> componentNames) { ArrayList<CellLayout> cellLayouts = getWorkspaceAndHotseatCellLayouts(); for (final CellLayout layoutParent : cellLayouts) { final ViewGroup layout = layoutParent.getShortcutsAndWidgets(); final HashMap<ItemInfo, View> children = new HashMap<ItemInfo, View>(); for (int j = 0; j < layout.getChildCount(); j++) { final View view = layout.getChildAt(j); children.put((ItemInfo) view.getTag(), view); }// w w w . jav a 2 s. c o m final ArrayList<View> childrenToRemove = new ArrayList<View>(); final HashMap<FolderInfo, ArrayList<ShortcutInfo>> folderAppsToRemove = new HashMap<FolderInfo, ArrayList<ShortcutInfo>>(); LauncherModel.ItemInfoFilter filter = new LauncherModel.ItemInfoFilter() { @Override public boolean filterItem(ItemInfo parent, ItemInfo info, ComponentName cn) { if (parent instanceof FolderInfo) { if (componentNames.contains(cn)) { FolderInfo folder = (FolderInfo) parent; ArrayList<ShortcutInfo> appsToRemove; if (folderAppsToRemove.containsKey(folder)) { appsToRemove = folderAppsToRemove.get(folder); } else { appsToRemove = new ArrayList<ShortcutInfo>(); folderAppsToRemove.put(folder, appsToRemove); } appsToRemove.add((ShortcutInfo) info); return true; } } else { if (componentNames.contains(cn)) { childrenToRemove.add(children.get(info)); return true; } } return false; } }; LauncherModel.filterItemInfos(children.keySet(), filter); // Remove all the apps from their folders for (FolderInfo folder : folderAppsToRemove.keySet()) { ArrayList<ShortcutInfo> appsToRemove = folderAppsToRemove.get(folder); for (ShortcutInfo info : appsToRemove) { folder.remove(info); } } // Remove all the other children for (View child : childrenToRemove) { // Note: We can not remove the view directly from CellLayoutChildren as this // does not re-mark the spaces as unoccupied. layoutParent.removeViewInLayout(child); if (child instanceof DropTarget) { mDragController.removeDropTarget((DropTarget) child); } } if (childrenToRemove.size() > 0) { layout.requestLayout(); layout.invalidate(); } } // Strip all the empty screens stripEmptyScreens(); }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
public void reinflateWidgetsIfNecessary() { final int clCount = getChildCount(); for (int i = 0; i < clCount; i++) { CellLayout cl = (CellLayout) getChildAt(i); ShortcutAndWidgetContainer swc = cl.getShortcutsAndWidgets(); final int itemCount = swc.getChildCount(); for (int j = 0; j < itemCount; j++) { View v = swc.getChildAt(j); if (v.getTag() instanceof LauncherAppWidgetInfoBean) { LauncherAppWidgetInfoBean info = (LauncherAppWidgetInfoBean) v.getTag(); LauncherAppWidgetHostView lahv = (LauncherAppWidgetHostView) info.hostView; if (lahv != null && lahv.orientationChangedSincedInflation()) { mLauncher.removeAppWidget(info); // Remove the current widget which is inflated with the // wrong orientation cl.removeView(lahv); mLauncher.bindAppWidget(info); }//from ww w . j av a2 s . c om } } } }