中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

做棋牌網(wǎng)站合法嗎網(wǎng)站排名seo

做棋牌網(wǎng)站合法嗎,網(wǎng)站排名seo,三亞今天最新通知,選擇好的佛山網(wǎng)站建設(shè)前言 如果我們需要固定住布局,不給用戶拖拽,可以通過(guò)修改長(zhǎng)按點(diǎn)擊監(jiān)聽(tīng)事件來(lái)達(dá)到禁止拖拽的目的二、代碼追蹤 1、src/com/android/launcher3/touch/ItemLongClickListener.java 在這個(gè)類開(kāi)頭注冊(cè)了兩種類型的監(jiān)聽(tīng),一個(gè)是在桌面拖拽應(yīng)用&…

前言

如果我們需要固定住布局,不給用戶拖拽,可以通過(guò)修改長(zhǎng)按點(diǎn)擊監(jiān)聽(tīng)事件來(lái)達(dá)到禁止拖拽的目的

二、代碼追蹤

1、src/com/android/launcher3/touch/ItemLongClickListener.java
在這個(gè)類開(kāi)頭注冊(cè)了兩種類型的監(jiān)聽(tīng),一個(gè)是在桌面拖拽應(yīng)用,一個(gè)是在所有應(yīng)用里面長(zhǎng)按拖拽

/*** Class to handle long-clicks on workspace items and start drag as a result.*/
public class ItemLongClickListener {public static final OnLongClickListener INSTANCE_WORKSPACE =ItemLongClickListener::onWorkspaceItemLongClick;public static final OnLongClickListener INSTANCE_ALL_APPS =ItemLongClickListener::onAllAppsItemLongClick;

接著分析桌面的長(zhǎng)按事件

    private static boolean onWorkspaceItemLongClick(View v) {if (v instanceof LauncherAppWidgetHostView) {TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Widgets.onLongClick");} else {TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "onWorkspaceItemLongClick");}Launcher launcher = Launcher.getLauncher(v.getContext());if (!canStartDrag(launcher)) return false;//請(qǐng)注意這里,這里判斷是否允許拖拽,如果不允許拖拽,則用戶長(zhǎng)按的時(shí)候是沒(méi)有任何反應(yīng)的,包括長(zhǎng)按卸載和快捷方式啥的都沒(méi)有了。所以不可以在這里修改if (!launcher.isInState(NORMAL) && !launcher.isInState(OVERVIEW)) return false;if (!(v.getTag() instanceof ItemInfo)) return false;launcher.setWaitingForResult(null);beginDrag(v, launcher, (ItemInfo) v.getTag(), launcher.getDefaultWorkspaceDragOptions());return true;}

我們看到有**beginDrag(v, launcher, (ItemInfo) v.getTag(), launcher.getDefaultWorkspaceDragOptions());**這個(gè)方法,這個(gè)方法也是不能注釋掉的,點(diǎn)進(jìn)去這個(gè)方法

    public static void beginDrag(View v, Launcher launcher, ItemInfo info,DragOptions dragOptions) {if (info.container >= 0) {Folder folder = Folder.getOpen(launcher);if (folder != null) {if (!folder.getIconsInReadingOrder().contains(v)) {folder.close(true);} else {folder.startDrag(v, dragOptions);return;}}}CellLayout.CellInfo longClickCellInfo = new CellLayout.CellInfo(v, info);launcher.getWorkspace().startDrag(longClickCellInfo, dragOptions);}

重點(diǎn)關(guān)注最后一行,發(fā)現(xiàn)走到了我們的主桌面workspace,點(diǎn)進(jìn)去繼續(xù)看

    public void startDrag(CellLayout.CellInfo cellInfo, DragOptions options) {View child = cellInfo.cell;mDragInfo = cellInfo;//child.setVisibility(INVISIBLE);//需要把這一行注釋掉,不然長(zhǎng)按的時(shí)候,圖標(biāo)會(huì)消失不見(jiàn)if (options.isAccessibleDrag) {mDragController.addDragListener(new AccessibleDragListenerAdapter(this, WorkspaceAccessibilityHelper::new) {@Overrideprotected void enableAccessibleDrag(boolean enable) {super.enableAccessibleDrag(enable);setEnableForLayout(mLauncher.getHotseat(), enable);}});}beginDragShared(child, this, options);}

重點(diǎn)關(guān)注最后一行,這一行也不能注釋掉,點(diǎn)擊去到這里

    public void beginDragShared(View child, DragSource source, DragOptions options) {Object dragObject = child.getTag();if (!(dragObject 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);}beginDragShared(child, null, source, (ItemInfo) dragObject,new DragPreviewProvider(child), options);}

還是最后一行代碼,點(diǎn)進(jìn)去才到重點(diǎn)

    /*** Core functionality for beginning a drag operation for an item that will be dropped within* the workspace*/public DragView beginDragShared(View child, DraggableView draggableView, DragSource source,ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions dragOptions) {float iconScale = 1f;if (child instanceof BubbleTextView) {Drawable icon = ((BubbleTextView) child).getIcon();if (icon instanceof FastBitmapDrawable) {iconScale = ((FastBitmapDrawable) icon).getAnimatedScale();}}// Clear the pressed state if necessarychild.clearFocus();child.setPressed(false);if (child instanceof BubbleTextView) {BubbleTextView icon = (BubbleTextView) child;icon.clearPressedBackground();}if (draggableView == null && child instanceof DraggableView) {draggableView = (DraggableView) child;}final View contentView = previewProvider.getContentView();final float scale;// The draggable drawable follows the touch point around on the screenfinal Drawable drawable;if (contentView == null) {drawable = previewProvider.createDrawable();scale = previewProvider.getScaleAndPosition(drawable, mTempXY);} else {drawable = null;scale = previewProvider.getScaleAndPosition(contentView, mTempXY);}int halfPadding = previewProvider.previewPadding / 2;int dragLayerX = mTempXY[0];int dragLayerY = mTempXY[1];Point dragVisualizeOffset = null;Rect dragRect = new Rect();if (draggableView != null) {draggableView.getSourceVisualDragBounds(dragRect);dragLayerY += dragRect.top;dragVisualizeOffset = new Point(- halfPadding, halfPadding);}if (child.getParent() instanceof ShortcutAndWidgetContainer) {mDragSourceInternal = (ShortcutAndWidgetContainer) child.getParent();}if (child instanceof BubbleTextView) {BubbleTextView btv = (BubbleTextView) child;if (!dragOptions.isAccessibleDrag) {dragOptions.preDragCondition = btv.startLongPressAction();}if (btv.isDisplaySearchResult()) {dragOptions.preDragEndScale = (float) mAllAppsIconSize / btv.getIconSize();}}final DragView dv;//start change that do not to drop the workspace and allApps icon./*if (contentView instanceof View) {if (contentView instanceof LauncherAppWidgetHostView) {mDragController.addDragListener(new AppWidgetHostViewDragListener(mLauncher));}dv = mDragController.startDrag(contentView,draggableView,dragLayerX,dragLayerY,source,dragObject,dragVisualizeOffset,dragRect,scale * iconScale,scale,dragOptions);} else {dv = mDragController.startDrag(drawable,draggableView,dragLayerX,dragLayerY,source,dragObject,dragVisualizeOffset,dragRect,scale * iconScale,scale,dragOptions);}return dv;*///end change that do not to drop the workspace and allApps icon.return null;}

這個(gè)方法是拖拽的核心方法,在開(kāi)始拖拽之前執(zhí)行,改方法前面都是一些計(jì)算,不用看,重點(diǎn)看final DragView dv;后面這個(gè)if語(yǔ)句,這里構(gòu)造一個(gè)拖拽對(duì)象,我們將該對(duì)象構(gòu)造過(guò)程給注釋掉,返回一個(gè)null,這樣子,后續(xù)的所有拖拽流程都無(wú)法進(jìn)行了,因?yàn)闆](méi)有拖拽對(duì)象了,這樣子我們就把禁止拖拽禁掉了,同時(shí)長(zhǎng)按桌面添加微件的功能還是正常的,不影響其他長(zhǎng)按功能。
因?yàn)樗袘?yīng)用里面的拖拽最終也是走到了最后一個(gè)方法,所以所有應(yīng)用的拖拽也被禁掉了

http://www.risenshineclean.com/news/2557.html

相關(guān)文章:

  • 官網(wǎng)網(wǎng)站設(shè)計(jì)費(fèi)用網(wǎng)絡(luò)優(yōu)化seo薪酬
  • 云南企業(yè)建站企業(yè)網(wǎng)絡(luò)營(yíng)銷顧問(wèn)
  • 你的網(wǎng)站正在建設(shè)中新聞稿件代發(fā)平臺(tái)
  • 坑梓網(wǎng)站建設(shè)流程網(wǎng)絡(luò)seo是什么意思
  • 文件網(wǎng)站建設(shè)百中搜優(yōu)化軟件靠譜嗎
  • wordpress 按鈕美化網(wǎng)站seo推廣
  • 微網(wǎng)站站點(diǎn)名稱網(wǎng)絡(luò)營(yíng)銷策劃內(nèi)容
  • b2c網(wǎng)站開(kāi)發(fā)公司福州seo推廣外包
  • 網(wǎng)站和公眾號(hào)的區(qū)別是什么意思互聯(lián)網(wǎng)營(yíng)銷方式
  • 天河區(qū)做網(wǎng)站公司產(chǎn)品推廣的目的和意義
  • 千度網(wǎng)站sem競(jìng)價(jià)推廣怎么做
  • 做網(wǎng)站 域名不屬于十大seo公司
  • 深圳 seo 外貿(mào)網(wǎng)站建設(shè) 多語(yǔ)種網(wǎng)頁(yè)設(shè)計(jì)軟件有哪些
  • 金華品牌網(wǎng)站建設(shè)百度愛(ài)采購(gòu)客服電話
  • 義烏開(kāi)鎖做網(wǎng)站哪個(gè)好怎么在百度上發(fā)表文章
  • 養(yǎng)生網(wǎng)站建設(shè)免費(fèi)網(wǎng)絡(luò)輿情管控
  • 專門做狗貓配套網(wǎng)站有什么意思長(zhǎng)春網(wǎng)站公司哪家好
  • wordpress 做的網(wǎng)站站長(zhǎng)工具查詢系統(tǒng)
  • 怎么建設(shè)網(wǎng)站代運(yùn)營(yíng)
  • 網(wǎng)站建設(shè)有用嗎貴陽(yáng)網(wǎng)站建設(shè)推廣
  • 網(wǎng)站推廣員能力要求b站網(wǎng)站推廣mmm
  • 網(wǎng)站圖標(biāo)怎么做的網(wǎng)站建設(shè)及推廣優(yōu)化
  • 網(wǎng)站建設(shè)使用的技術(shù)讓顧客心動(dòng)的句子
  • 優(yōu)秀的個(gè)人網(wǎng)頁(yè)展示關(guān)鍵詞優(yōu)化外包
  • .net網(wǎng)站開(kāi)發(fā)源碼外貿(mào)網(wǎng)站建設(shè)
  • 手機(jī)h5網(wǎng)站開(kāi)發(fā)關(guān)鍵詞點(diǎn)擊價(jià)格查詢
  • offic做網(wǎng)站的軟件網(wǎng)上做推廣怎么收費(fèi)
  • 本地搭建linux服務(wù)器做網(wǎng)站推廣是什么意思
  • 計(jì)算機(jī)考試模擬網(wǎng)站怎么做seo博客模板
  • 職業(yè)做網(wǎng)站游戲的網(wǎng)站查詢工具seo