From b297afec5c3b05beb17134e0f7d894c2d7f61d40 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Tue, 2 Mar 2021 14:04:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=85=A5=E6=9B=B4=E5=A4=9A=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mop/api/mop/AppletHandlerModule.java | 18 +++++++++++++++++- lib/api.dart | 10 +++++++--- lib/mop.dart | 16 +++++++++++++--- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java index 7ab62d4..355fea6 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/AppletHandlerModule.java @@ -7,7 +7,9 @@ import android.os.Looper; import android.util.Log; import com.finogeeks.lib.applet.client.FinAppClient; +import com.finogeeks.lib.applet.client.FinAppTrace; import com.finogeeks.lib.applet.page.view.moremenu.MoreMenuItem; +import com.finogeeks.lib.applet.page.view.moremenu.MoreMenuType; import com.finogeeks.lib.applet.rest.model.GrayAppletVersionConfig; import com.finogeeks.lib.applet.sdk.api.IAppletHandler; import com.finogeeks.mop.api.BaseApi; @@ -131,9 +133,17 @@ public class AppletHandlerModule extends BaseApi { @Override public void success(Object result) { List> ret = (List>) result; + FinAppTrace.d(TAG, "getRegisteredMoreMenuItems success : " + ret + " size : " + ret.size()); if (ret != null) { for (Map map : ret) { - moreMenuItems.add(new MoreMenuItem((Integer) map.get("menuId"), 0, (String) map.get("title"), true)); + String type = (String) map.get("type"); + MoreMenuType moreMenuType; + if ("common".equals(type)) { + moreMenuType = MoreMenuType.COMMON; + } else { + moreMenuType = MoreMenuType.ON_MINI_PROGRAM; + } + moreMenuItems.add(new MoreMenuItem((String) map.get("menuId"), (String) map.get("title"), moreMenuType)); } } latch.countDown(); @@ -141,11 +151,13 @@ public class AppletHandlerModule extends BaseApi { @Override public void error(String errorCode, String errorMessage, Object errorDetails) { + FinAppTrace.e(TAG, "getRegisteredMoreMenuItems errorCode : " + errorCode + " errorMessage : " + errorMessage); latch.countDown(); } @Override public void notImplemented() { + FinAppTrace.d(TAG, "getRegisteredMoreMenuItems notImplemented"); latch.countDown(); } }); @@ -155,6 +167,7 @@ public class AppletHandlerModule extends BaseApi { } catch (InterruptedException e) { e.printStackTrace(); } + FinAppTrace.d(TAG, "getRegisteredMoreMenuItems moreMenuItems : " + moreMenuItems + " size : " + moreMenuItems.size()); return moreMenuItems; } @@ -163,10 +176,13 @@ public class AppletHandlerModule extends BaseApi { Map params = new HashMap<>(); params.put("appId", appId); + params.put("path", path); params.put("menuId", menuItemId); + params.put("appInfo", appInfo); handler.post(() -> { channel.invokeMethod("extensionApi:onCustomMenuClick", params); }); + callback.onSuccess(null); } @Override diff --git a/lib/api.dart b/lib/api.dart index b48683d..1b6b61e 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -1,12 +1,15 @@ import 'dart:typed_data'; class CustomMenu { - int menuId; + String menuId; String image; String title; + String type; + + CustomMenu(this.menuId, this.image, this.title, this.type); Map toJson() => - {"menuId": menuId, "image": image, "title": title}; + {'menuId': menuId, 'image': image, 'title': title, 'type': type}; } abstract class AppletHandler { @@ -31,5 +34,6 @@ abstract class AppletHandler { Future> getCustomMenus(String appId); ///自定义菜单点击处理 - Future onCustomMenuClick(String appId, int menuId); + Future onCustomMenuClick( + String appId, String path, String menuId, String appInfo); } diff --git a/lib/mop.dart b/lib/mop.dart index b3e8c91..82c141b 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -168,11 +168,21 @@ class Mop { }; _extensionApis["getCustomMenus"] = (params) async { final res = await handler.getCustomMenus(params["appId"]); - res?.map((e) => e.toJson()); - return res; + List> list = []; + res?.forEach((element) { + Map map = Map(); + map["menuId"] = element.menuId; + map["image"] = element.image; + map["title"] = element.title; + map["type"] = element.type; + list.add(map); + }); + print("registerAppletHandler getCustomMenus list $list"); + return list; }; _extensionApis["onCustomMenuClick"] = (params) { - return handler.onCustomMenuClick(params["appId"], params["menuId"]); + return handler.onCustomMenuClick( + params["appId"], params["path"], params["menuId"], params["appInfo"]); }; _channel.invokeMethod("registerAppletHandler"); }