update getUserProfile
parent
06fba0ff0b
commit
48f357de17
|
@ -24,6 +24,7 @@ import com.finogeeks.mop.interfaces.ICallback;
|
||||||
import com.finogeeks.mop.service.MopPluginService;
|
import com.finogeeks.mop.service.MopPluginService;
|
||||||
import com.finogeeks.mop.utils.AppletUtils;
|
import com.finogeeks.mop.utils.AppletUtils;
|
||||||
import com.finogeeks.mop.utils.GsonUtil;
|
import com.finogeeks.mop.utils.GsonUtil;
|
||||||
|
import com.finogeeks.mop.impls.MyUserProfileHandler;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -65,6 +66,9 @@ public class AppletHandlerModule extends BaseApi {
|
||||||
Log.d("AppletHandlerModule", "registerAppletHandler");
|
Log.d("AppletHandlerModule", "registerAppletHandler");
|
||||||
|
|
||||||
MethodChannel channel = MopPluginService.getInstance().getMethodChannel();
|
MethodChannel channel = MopPluginService.getInstance().getMethodChannel();
|
||||||
|
// getUserProfile的内置实现
|
||||||
|
FinAppClient.INSTANCE.getFinAppConfig().setGetUserProfileHandlerClass(MyUserProfileHandler.class.getName());
|
||||||
|
|
||||||
FinAppClient.INSTANCE.getAppletApiManager().setAppletHandler(mIAppletHandler = new IAppletHandler() {
|
FinAppClient.INSTANCE.getAppletApiManager().setAppletHandler(mIAppletHandler = new IAppletHandler() {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.finogeeks.mop.api.BaseApi;
|
||||||
import com.finogeeks.mop.api.mop.util.InitUtils;
|
import com.finogeeks.mop.api.mop.util.InitUtils;
|
||||||
import com.finogeeks.mop.interfaces.ICallback;
|
import com.finogeeks.mop.interfaces.ICallback;
|
||||||
import com.finogeeks.mop.service.MopPluginService;
|
import com.finogeeks.mop.service.MopPluginService;
|
||||||
|
import com.finogeeks.mop.impls.MyUserProfileHandler;
|
||||||
import com.finogeeks.xlog.XLogLevel;
|
import com.finogeeks.xlog.XLogLevel;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
@ -199,6 +200,9 @@ public class InitSDKModule extends BaseApi {
|
||||||
configBuilder.setLocale(Locale.SIMPLIFIED_CHINESE);
|
configBuilder.setLocale(Locale.SIMPLIFIED_CHINESE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getUserProfile的内置实现
|
||||||
|
configBuilder.setGetUserProfileHandlerClass(MyUserProfileHandler.class.getName());
|
||||||
|
|
||||||
// uiConfig
|
// uiConfig
|
||||||
FinAppConfig.UIConfig uiConfig = InitUtils.createUIConfigFromMap(uiConfigMap);
|
FinAppConfig.UIConfig uiConfig = InitUtils.createUIConfigFromMap(uiConfigMap);
|
||||||
if (uiConfig != null) {
|
if (uiConfig != null) {
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package com.finogeeks.mop.impls;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.finogeeks.lib.applet.client.FinAppInfo;
|
||||||
|
import com.finogeeks.lib.applet.modules.userprofile.IUserProfileHandler;
|
||||||
|
import com.finogeeks.mop.service.MopPluginService;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import io.flutter.plugin.common.MethodChannel;
|
||||||
|
|
||||||
|
public class MyUserProfileHandler implements IUserProfileHandler {
|
||||||
|
private static final String TAG = "MyUserProfileHandler";
|
||||||
|
|
||||||
|
private Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getUserProfileWithAppletInfo(@NotNull Context context, @NotNull FinAppInfo finAppInfo, @NotNull UserProfileCallback callback) {
|
||||||
|
MethodChannel channel = MopPluginService.getInstance().getMethodChannel();
|
||||||
|
Log.d(TAG, "getUserProfileWithAppletInfo:");
|
||||||
|
channel.invokeMethod("extensionApi:getUserProfile", null, new MethodChannel.Result() {
|
||||||
|
@Override
|
||||||
|
public void success(Object mapResult) {
|
||||||
|
JSONObject result = null;
|
||||||
|
try {
|
||||||
|
result = new JSONObject(mapResult);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
callback.onError(null);
|
||||||
|
} else {
|
||||||
|
callback.onSuccess(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(String errorCode, String errorMessage, Object errorDetails) {
|
||||||
|
callback.onError(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notImplemented() {
|
||||||
|
callback.onError(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -81,9 +81,26 @@ class _MyAppState extends State<MyApp> {
|
||||||
print(res);
|
print(res);
|
||||||
Mop.instance.registerAppletHandler(MyAppletHandler());
|
Mop.instance.registerAppletHandler(MyAppletHandler());
|
||||||
|
|
||||||
|
Mop.instance.registerExtensionApi('getUserProfile', getUserProfile);
|
||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> getUserProfile(dynamic params) async {
|
||||||
|
Map<String, dynamic> result = {
|
||||||
|
"userInfo":{
|
||||||
|
"nickName" : "haley",
|
||||||
|
"avatarUrl" : "https://www.finclip.com",
|
||||||
|
"gender" : 1,
|
||||||
|
"country" : "China",
|
||||||
|
"province" : "Guangdong",
|
||||||
|
"city" : "shenzhen",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildAppletItem(
|
Widget _buildAppletItem(
|
||||||
String appletId, String itemName, VoidCallback tapAction) {
|
String appletId, String itemName, VoidCallback tapAction) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
|
|
|
@ -115,7 +115,7 @@ packages:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "2.40.13"
|
version: "2.41.1"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -169,14 +169,7 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3"
|
version: "0.4.9"
|
||||||
typed_data:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: typed_data
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.0"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
28
pubspec.lock
28
pubspec.lock
|
@ -42,14 +42,14 @@ packages:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.16.0"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -88,6 +88,13 @@ packages:
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.11"
|
version: "0.12.11"
|
||||||
|
material_color_utilities:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: material_color_utilities
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.4"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -101,7 +108,7 @@ packages:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
@ -113,7 +120,7 @@ packages:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.8.2"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -148,21 +155,14 @@ packages:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3"
|
version: "0.4.9"
|
||||||
typed_data:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: typed_data
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.0"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.14.0 <3.0.0"
|
dart: ">=2.17.0-0 <3.0.0"
|
||||||
flutter: ">=2.2.3"
|
flutter: ">=2.2.3"
|
||||||
|
|
Loading…
Reference in New Issue