注入更多菜单
parent
b928191653
commit
b297afec5c
|
@ -7,7 +7,9 @@ import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.finogeeks.lib.applet.client.FinAppClient;
|
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.MoreMenuItem;
|
||||||
|
import com.finogeeks.lib.applet.page.view.moremenu.MoreMenuType;
|
||||||
import com.finogeeks.lib.applet.rest.model.GrayAppletVersionConfig;
|
import com.finogeeks.lib.applet.rest.model.GrayAppletVersionConfig;
|
||||||
import com.finogeeks.lib.applet.sdk.api.IAppletHandler;
|
import com.finogeeks.lib.applet.sdk.api.IAppletHandler;
|
||||||
import com.finogeeks.mop.api.BaseApi;
|
import com.finogeeks.mop.api.BaseApi;
|
||||||
|
@ -131,9 +133,17 @@ public class AppletHandlerModule extends BaseApi {
|
||||||
@Override
|
@Override
|
||||||
public void success(Object result) {
|
public void success(Object result) {
|
||||||
List<Map<String, Object>> ret = (List<Map<String, Object>>) result;
|
List<Map<String, Object>> ret = (List<Map<String, Object>>) result;
|
||||||
|
FinAppTrace.d(TAG, "getRegisteredMoreMenuItems success : " + ret + " size : " + ret.size());
|
||||||
if (ret != null) {
|
if (ret != null) {
|
||||||
for (Map<String, Object> map : ret) {
|
for (Map<String, Object> 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();
|
latch.countDown();
|
||||||
|
@ -141,11 +151,13 @@ public class AppletHandlerModule extends BaseApi {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(String errorCode, String errorMessage, Object errorDetails) {
|
public void error(String errorCode, String errorMessage, Object errorDetails) {
|
||||||
|
FinAppTrace.e(TAG, "getRegisteredMoreMenuItems errorCode : " + errorCode + " errorMessage : " + errorMessage);
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notImplemented() {
|
public void notImplemented() {
|
||||||
|
FinAppTrace.d(TAG, "getRegisteredMoreMenuItems notImplemented");
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -155,6 +167,7 @@ public class AppletHandlerModule extends BaseApi {
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
FinAppTrace.d(TAG, "getRegisteredMoreMenuItems moreMenuItems : " + moreMenuItems + " size : " + moreMenuItems.size());
|
||||||
return moreMenuItems;
|
return moreMenuItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,10 +176,13 @@ public class AppletHandlerModule extends BaseApi {
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("appId", appId);
|
params.put("appId", appId);
|
||||||
|
params.put("path", path);
|
||||||
params.put("menuId", menuItemId);
|
params.put("menuId", menuItemId);
|
||||||
|
params.put("appInfo", appInfo);
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
channel.invokeMethod("extensionApi:onCustomMenuClick", params);
|
channel.invokeMethod("extensionApi:onCustomMenuClick", params);
|
||||||
});
|
});
|
||||||
|
callback.onSuccess(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
10
lib/api.dart
10
lib/api.dart
|
@ -1,12 +1,15 @@
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
class CustomMenu {
|
class CustomMenu {
|
||||||
int menuId;
|
String menuId;
|
||||||
String image;
|
String image;
|
||||||
String title;
|
String title;
|
||||||
|
String type;
|
||||||
|
|
||||||
|
CustomMenu(this.menuId, this.image, this.title, this.type);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() =>
|
Map<String, dynamic> toJson() =>
|
||||||
{"menuId": menuId, "image": image, "title": title};
|
{'menuId': menuId, 'image': image, 'title': title, 'type': type};
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class AppletHandler {
|
abstract class AppletHandler {
|
||||||
|
@ -31,5 +34,6 @@ abstract class AppletHandler {
|
||||||
Future<List<CustomMenu>> getCustomMenus(String appId);
|
Future<List<CustomMenu>> getCustomMenus(String appId);
|
||||||
|
|
||||||
///自定义菜单点击处理
|
///自定义菜单点击处理
|
||||||
Future onCustomMenuClick(String appId, int menuId);
|
Future onCustomMenuClick(
|
||||||
|
String appId, String path, String menuId, String appInfo);
|
||||||
}
|
}
|
||||||
|
|
16
lib/mop.dart
16
lib/mop.dart
|
@ -168,11 +168,21 @@ class Mop {
|
||||||
};
|
};
|
||||||
_extensionApis["getCustomMenus"] = (params) async {
|
_extensionApis["getCustomMenus"] = (params) async {
|
||||||
final res = await handler.getCustomMenus(params["appId"]);
|
final res = await handler.getCustomMenus(params["appId"]);
|
||||||
res?.map((e) => e.toJson());
|
List<Map<String, dynamic>> list = [];
|
||||||
return res;
|
res?.forEach((element) {
|
||||||
|
Map<String, dynamic> 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) {
|
_extensionApis["onCustomMenuClick"] = (params) {
|
||||||
return handler.onCustomMenuClick(params["appId"], params["menuId"]);
|
return handler.onCustomMenuClick(
|
||||||
|
params["appId"], params["path"], params["menuId"], params["appInfo"]);
|
||||||
};
|
};
|
||||||
_channel.invokeMethod("registerAppletHandler");
|
_channel.invokeMethod("registerAppletHandler");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue