This commit is contained in:
hrxiang
2021-07-05 11:06:31 +08:00
parent 54d0d62bd9
commit 475f350b99
26 changed files with 54 additions and 1502 deletions

View File

@@ -9,7 +9,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;

View File

@@ -11,9 +11,9 @@ public class AdvancedMsgListenerImpl implements OnAdvancedMsgListener {
final MethodChannel channel;
final Map<String, String> values = new HashMap<>();
public AdvancedMsgListenerImpl(MethodChannel channel, String id) {
public AdvancedMsgListenerImpl(MethodChannel channel, String listenerId) {
this.channel = channel;
this.values.put("id", id);
this.values.put("id", listenerId);
}
@Override

View File

@@ -8,10 +8,10 @@ import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.SendMsgCallBack;
public class SendMsgProgressListener implements SendMsgCallBack {
public class MsgSendProgressListener implements SendMsgCallBack {
public SendMsgProgressListener(MethodChannel.Result result, MethodChannel channel, MethodCall call) {
public MsgSendProgressListener(MethodChannel.Result result, MethodChannel channel, MethodCall call) {
this.result = result;
this.channel = channel;
this.call = call;

View File

@@ -17,13 +17,13 @@ public class ConversationManager {
public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setConversationListener(new ConversationListenerImpl(channel));
}
public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getAllConversationList(new BaseImpl(result));
}
public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getOneConversation(CommonUtil.getConversationId(methodCall), new BaseImpl(result));
Open_im_sdk.getOneConversation(CommonUtil.getConversationSourceId(methodCall), CommonUtil.getConversationSessionType(methodCall), new BaseImpl(result));
}
public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) {

View File

@@ -7,7 +7,7 @@ import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.AdvancedMsgListenerImpl;
import io.openim.flutter_openim_sdk.listener.BaseImpl;
import io.openim.flutter_openim_sdk.listener.SendMsgProgressListener;
import io.openim.flutter_openim_sdk.listener.MsgSendProgressListener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnAdvancedMsgListener;
import open_im_sdk.Open_im_sdk;
@@ -29,7 +29,6 @@ public class MessageManager {
AdvancedMsgListenerImpl listener = new AdvancedMsgListenerImpl(channel, key);
listeners.put(methodCall.argument(KEY_ID), listener);
Open_im_sdk.addAdvancedMsgListener(listener);
System.out.println("=================add msg listener======" + listener);
}
}
@@ -37,12 +36,10 @@ public class MessageManager {
String key = methodCall.argument(KEY_ID);
OnAdvancedMsgListener listener = listeners.remove(key);
Open_im_sdk.removeAdvancedMsgListener(listener);
System.out.println("=================remove msg listener======" + listener);
}
public void sendMessage(MethodCall methodCall, MethodChannel.Result result) {
SendMsgProgressListener listener = new SendMsgProgressListener(result, channel, methodCall);
System.out.println("===============sendMessage===============");
MsgSendProgressListener listener = new MsgSendProgressListener(result, channel, methodCall);
Open_im_sdk.sendMessage(listener, CommonUtil.getSendMessageContent(methodCall), CommonUtil.getSendMessageReceiver(methodCall), CommonUtil.geSendMessageGroupId(methodCall), CommonUtil.getSendMessageOnlineOnly(methodCall));
}

View File

@@ -12,9 +12,6 @@ import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin;
public class CommonUtil {
/**
* 主线程处理器
*/
private final static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
public static <T> T getParamValue(MethodCall methodCall, String param) {
@@ -42,14 +39,7 @@ public class CommonUtil {
MAIN_HANDLER.post(runnable);
}
/**
* 运行主线程返回错误结果执行
*
* @param result 返回结果对象
* @param errorCode 错误码
* @param errorMessage 错误信息
* @param errorDetails 错误内容
*/
public static void runMainThreadReturnError(final MethodChannel.Result result, final String errorCode, final String errorMessage, final Object errorDetails) {
MAIN_HANDLER.post(new Runnable() {
@Override
@@ -63,33 +53,6 @@ public class CommonUtil {
runMainThreadReturnError(result, String.valueOf(errorCode), errorMessage, errorDetails);
}
/*
public static void returnError(final MethodChannel.Result result, int i, String s) {
HashMap<String, Object> err = new HashMap<String, Object>();
err.put("code", i);
err.put("desc", s);
result.success(err);
}
public static void returnError(final MethodChannel.Result result, int i, String s, HashMap<String, Object> data) {
HashMap<String, Object> err = new HashMap<String, Object>();
err.put("code", i);
err.put("desc", s);
err.put("data", data);
result.success(err);
}
public static <T> void returnSuccess(final MethodChannel.Result result, T data) {
HashMap<String, Object> succ = new HashMap<String, Object>();
succ.put("code", 0);
succ.put("desc", "ok");
succ.put("data", data);
result.success(succ);
}
*/
public static <T> void emitEvent(MethodChannel channel, String method, String type, Long errCode, String errMsg, T data) {
runMainThread(new Runnable() {
@Override
@@ -243,6 +206,14 @@ public class CommonUtil {
return getSDKJsonParam(methodCall, KEY_CONVERSATION_IDS);
}
public static String getConversationSourceId(MethodCall methodCall) {
return getParamValue(methodCall, KEY_CONVERSATION_SOURCE_ID);
}
public static int getConversationSessionType(MethodCall methodCall) {
return getParamValue(methodCall, KEY_CONVERSATION_SESSION_TYPE);
}
public static String getConversationDraft(MethodCall methodCall) {
return getParamValue(methodCall, KEY_CONVERSATION_DRAFT);
}
@@ -292,6 +263,8 @@ public class CommonUtil {
final static String KEY_CONVERSATION_IDS = "conversationIDList";
final static String KEY_CONVERSATION_DRAFT = "draftText";
final static String KEY_CONVERSATION_PINNED = "isPinned";
final static String KEY_CONVERSATION_SOURCE_ID = "sourceID";
final static String KEY_CONVERSATION_SESSION_TYPE = "sessionType";
// user info
final static String KEY_USER_IDS = "uidList";
}