合并getUserProfile的处理
commit
f5b2ae9ca7
|
@ -24,6 +24,7 @@ import com.finogeeks.mop.interfaces.ICallback;
|
|||
import com.finogeeks.mop.service.MopPluginService;
|
||||
import com.finogeeks.mop.utils.AppletUtils;
|
||||
import com.finogeeks.mop.utils.GsonUtil;
|
||||
import com.finogeeks.mop.impls.MyUserProfileHandler;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -65,6 +66,9 @@ public class AppletHandlerModule extends BaseApi {
|
|||
Log.d("AppletHandlerModule", "registerAppletHandler");
|
||||
|
||||
MethodChannel channel = MopPluginService.getInstance().getMethodChannel();
|
||||
// getUserProfile的内置实现
|
||||
FinAppClient.INSTANCE.getFinAppConfig().setGetUserProfileHandlerClass(MyUserProfileHandler.class.getName());
|
||||
|
||||
FinAppClient.INSTANCE.getAppletApiManager().setAppletHandler(mIAppletHandler = new IAppletHandler() {
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.finogeeks.mop.api.BaseApi;
|
|||
import com.finogeeks.mop.api.mop.util.InitUtils;
|
||||
import com.finogeeks.mop.interfaces.ICallback;
|
||||
import com.finogeeks.mop.service.MopPluginService;
|
||||
import com.finogeeks.mop.impls.MyUserProfileHandler;
|
||||
import com.finogeeks.xlog.XLogLevel;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
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:");
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
channel.invokeMethod("extensionApi:getUserProfile", null, new MethodChannel.Result() {
|
||||
@Override
|
||||
public void success(Object mapResult) {
|
||||
JSONObject result = null;
|
||||
try {
|
||||
result = new JSONObject((Map) 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);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -70,7 +70,7 @@ flutter {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
def sdk_version = "2.40.1"
|
||||
compileOnly "com.finogeeks.lib:finapplet:${sdk_version}"
|
||||
def sdk_version = "2.41.3"
|
||||
compileOnly "com.finogeeks.lib:finapplet:2.41.4-dev20230721v13"
|
||||
implementation "com.finogeeks.mop:plugins:${sdk_version}"
|
||||
}
|
||||
|
|
|
@ -81,9 +81,26 @@ class _MyAppState extends State<MyApp> {
|
|||
print(res);
|
||||
Mop.instance.registerAppletHandler(MyAppletHandler());
|
||||
|
||||
Mop.instance.registerExtensionApi('getUserProfile', getUserProfile);
|
||||
|
||||
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 Future.value(result);
|
||||
}
|
||||
|
||||
Widget _buildAppletItem(
|
||||
String appletId, String itemName, VoidCallback tapAction) {
|
||||
return GestureDetector(
|
||||
|
@ -231,7 +248,18 @@ class MyAppletHandler extends AppletHandler {
|
|||
@override
|
||||
Future<Map<String, dynamic>> getUserInfo() {
|
||||
// TODO: implement getUserInfo
|
||||
throw UnimplementedError();
|
||||
Map<String, dynamic> result = {
|
||||
"userInfo":{
|
||||
"nickName" : "haley",
|
||||
"avatarUrl" : "https://www.finclip.com",
|
||||
"gender" : 1,
|
||||
"country" : "China",
|
||||
"province" : "Guangdong",
|
||||
"city" : "shenzhen",
|
||||
}
|
||||
};
|
||||
|
||||
return Future.value(result);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -7,7 +7,7 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
version: "2.9.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -21,21 +21,14 @@ packages:
|
|||
name: characters
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
version: "1.2.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -56,7 +49,7 @@ packages:
|
|||
name: fake_async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.3.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -94,35 +87,35 @@ packages:
|
|||
name: matcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
version: "0.12.12"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.4"
|
||||
version: "0.1.5"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0"
|
||||
mop:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "2.40.13"
|
||||
version: "2.41.1"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.8.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -134,7 +127,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.2"
|
||||
version: "1.9.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -155,28 +148,21 @@ packages:
|
|||
name: string_scanner
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.2.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.4.3"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "0.4.12"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -411,7 +411,6 @@ class UIConfig {
|
|||
"disableSlideCloseAppletGesture": disableSlideCloseAppletGesture,
|
||||
"appletText": appletText,
|
||||
"loadingLayoutCls": loadingLayoutCls,
|
||||
"useNativeLiveComponent": useNativeLiveComponent,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
49
pubspec.lock
49
pubspec.lock
|
@ -7,7 +7,7 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.8.2"
|
||||
version: "2.9.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -21,35 +21,28 @@ packages:
|
|||
name: characters
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
version: "1.2.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
version: "1.16.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.3.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
|
@ -87,21 +80,28 @@ packages:
|
|||
name: matcher
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.12.11"
|
||||
version: "0.12.12"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.1.5"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
version: "1.8.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
@ -113,7 +113,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.8.1"
|
||||
version: "1.9.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -134,35 +134,28 @@ packages:
|
|||
name: string_scanner
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.1.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.2.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "0.4.3"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "0.4.12"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.flutter-io.cn"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "2.1.2"
|
||||
sdks:
|
||||
dart: ">=2.14.0 <3.0.0"
|
||||
dart: ">=2.17.0-0 <3.0.0"
|
||||
flutter: ">=2.2.3"
|
||||
|
|
Loading…
Reference in New Issue