putFile -> uploadFile
This commit is contained in:
		
							parent
							
								
									0c7124a2a5
								
							
						
					
					
						commit
						e12799da0b
					
				| @ -53,5 +53,5 @@ dependencies { | ||||
|     // 本地依赖,现将aar复制到libs/io/openim/core-sdk/0.0.1/ 下,命名core-sdk-0.0.1.aar | ||||
| //    implementation 'io.openim:core-sdk:0.0.1@aar' | ||||
| //    api 'io.openim:core-sdk:2.3.5-t44@aar' | ||||
|     implementation 'io.openim:core-sdk:3.0.0-enterprise-beta11@aar' | ||||
|     implementation 'io.openim:core-sdk:3.0.0-enterprise-beta12@aar' | ||||
| } | ||||
| @ -1,86 +0,0 @@ | ||||
| package io.openim.flutter_openim_sdk.listener; | ||||
| 
 | ||||
| import android.util.ArrayMap; | ||||
| 
 | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import io.flutter.plugin.common.MethodCall; | ||||
| import io.flutter.plugin.common.MethodChannel; | ||||
| import io.openim.flutter_openim_sdk.util.CommonUtil; | ||||
| import open_im_sdk_callback.PutFileCallback; | ||||
| 
 | ||||
| public class OnPutFileListener implements PutFileCallback { | ||||
|     final private MethodChannel.Result result; | ||||
|     final private Object putID; | ||||
| 
 | ||||
|     public OnPutFileListener(MethodChannel.Result result, MethodCall call) { | ||||
|         this.result = result; | ||||
|         this.putID = call.argument("putID"); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void hashComplete(String hash, long total) { | ||||
|         if (null != putID) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("putID", putID); | ||||
|             values.put("hash", hash); | ||||
|             values.put("total", total); | ||||
|             CommonUtil.emitEvent("putFileListener", "hashComplete", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void hashProgress(long current, long total) { | ||||
|         if (null != putID) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("putID", putID); | ||||
|             values.put("current", current); | ||||
|             values.put("total", total); | ||||
|             CommonUtil.emitEvent("putFileListener", "hashProgress", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void open(long size) { | ||||
|         if (null != putID) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("putID", putID); | ||||
|             values.put("size", size); | ||||
|             CommonUtil.emitEvent("putFileListener", "open", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void putComplete(long total, long putType) { | ||||
|         if (null != putID) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("putID", putID); | ||||
|             values.put("putType", putType); | ||||
|             values.put("total", total); | ||||
|             CommonUtil.emitEvent("putFileListener", "putComplete", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void putProgress(long save, long current, long total) { | ||||
|         if (null != putID) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("putID", putID); | ||||
|             values.put("save", save); | ||||
|             values.put("current", current); | ||||
|             values.put("total", total); | ||||
|             CommonUtil.emitEvent("putFileListener", "putProgress", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void putStart(long current, long total) { | ||||
|         if (null != putID) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("putID", putID); | ||||
|             values.put("current", current); | ||||
|             values.put("total", total); | ||||
|             CommonUtil.emitEvent("putFileListener", "putStart", values); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,110 @@ | ||||
| package io.openim.flutter_openim_sdk.listener; | ||||
| 
 | ||||
| import android.util.ArrayMap; | ||||
| 
 | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import io.flutter.plugin.common.MethodCall; | ||||
| import io.flutter.plugin.common.MethodChannel; | ||||
| import io.openim.flutter_openim_sdk.util.CommonUtil; | ||||
| import open_im_sdk_callback.UploadFileCallback; | ||||
| 
 | ||||
| public class OnUploadFileListener implements UploadFileCallback { | ||||
|     final private MethodChannel.Result result; | ||||
|     final private Object id; | ||||
| 
 | ||||
|     public OnUploadFileListener(MethodChannel.Result result, MethodCall call) { | ||||
|         this.result = result; | ||||
|         this.id = call.argument("id"); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void complete(long size, String url, int type) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("size", size); | ||||
|             values.put("url", url); | ||||
|             values.put("type", type); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "complete", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void hashPartComplete(String partHash, String fileHash) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("partHash", partHash); | ||||
|             values.put("fileHash", fileHash); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "hashPartComplete", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void hashPartProgress(int index, long size, String partHash) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("index", index); | ||||
|             values.put("size", size); | ||||
|             values.put("partHash", partHash); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "hashPartProgress", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void open(long size) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("size", size); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "open", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void partSize(long partSize, int num) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("partSize", partSize); | ||||
|             values.put("num", num); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "partSize", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void uploadComplete(long fileSize, long streamSize, long storageSize) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("fileSize", fileSize); | ||||
|             values.put("streamSize", streamSize); | ||||
|             values.put("storageSize", storageSize); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "uploadProgress", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void uploadID(String uploadID) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("uploadID", uploadID); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "uploadID", values); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void uploadPartComplete(int index, long partSize, String partHash) { | ||||
|         if (null != id) { | ||||
|             final Map<String, Object> values = new ArrayMap<>(); | ||||
|             values.put("id", id); | ||||
|             values.put("index", index); | ||||
|             values.put("partSize", partSize); | ||||
|             values.put("partHash", partHash); | ||||
|             CommonUtil.emitEvent("uploadFileListener", "uploadPartComplete", values); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -5,7 +5,7 @@ import io.flutter.plugin.common.MethodChannel; | ||||
| import io.openim.flutter_openim_sdk.FlutterOpenimSdkPlugin; | ||||
| import io.openim.flutter_openim_sdk.listener.OnBaseListener; | ||||
| import io.openim.flutter_openim_sdk.listener.OnConnListener; | ||||
| import io.openim.flutter_openim_sdk.listener.OnPutFileListener; | ||||
| import io.openim.flutter_openim_sdk.listener.OnUploadFileListener; | ||||
| import io.openim.flutter_openim_sdk.util.CommonUtil; | ||||
| import open_im_sdk.Open_im_sdk; | ||||
| 
 | ||||
| @ -40,12 +40,12 @@ public class IMManager extends BaseManager { | ||||
|         CommonUtil.runMainThreadReturn(result, Open_im_sdk.getLoginStatus(value(methodCall, "operationID"))); | ||||
|     } | ||||
| 
 | ||||
|     public void putFile(MethodCall methodCall, MethodChannel.Result result) { | ||||
|         Open_im_sdk.putFile( | ||||
|     public void uploadFile(MethodCall methodCall, MethodChannel.Result result) { | ||||
|         Open_im_sdk.uploadFile( | ||||
|                 new OnBaseListener(result, methodCall), | ||||
|                 value(methodCall, "operationID"), | ||||
|                 jsonValue(methodCall), | ||||
|                 new OnPutFileListener(result, methodCall) | ||||
|                 new OnUploadFileListener(result, methodCall) | ||||
|         ); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -20,7 +20,7 @@ export 'src/listener/group_listener.dart'; | ||||
| export 'src/listener/listener_for_service.dart'; | ||||
| export 'src/listener/message_kv_info_listener.dart'; | ||||
| export 'src/listener/msg_send_progress_listener.dart'; | ||||
| export 'src/listener/put_file_listener.dart'; | ||||
| export 'src/listener/upload_file_listener.dart'; | ||||
| export 'src/listener/signaling_listener.dart'; | ||||
| export 'src/listener/user_listener.dart'; | ||||
| export 'src/manager/im_conversation_manager.dart'; | ||||
|  | ||||
| @ -14,5 +14,5 @@ class ListenerType { | ||||
|   static const customBusinessListener = "customBusinessListener"; | ||||
|   static const messageKvInfoListener = "messageKvInfoListener"; | ||||
|   static const listenerForService = "listenerForService"; | ||||
|   static const putFileListener = "putFileListener"; | ||||
|   static const uploadFileListener = "uploadFileListener"; | ||||
| } | ||||
|  | ||||
							
								
								
									
										45
									
								
								lib/src/listener/upload_file_listener.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								lib/src/listener/upload_file_listener.dart
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| class OnUploadFileListener { | ||||
|   Function(String id, int size, String url, int type)? onComplete; | ||||
|   Function(String id, String partHash, String fileHash)? onHashPartComplete; | ||||
|   Function(String id, int index, int size, String partHash)? onHashPartProgress; | ||||
|   Function(String id, int size)? onOpen; | ||||
|   Function(String id, int partSize, int num)? onPartSize; | ||||
|   Function(String id, int fileSize, int streamSize, int storageSize)? | ||||
|       onUploadProgress; | ||||
|   Function(String id, String uploadID)? onUploadID; | ||||
|   Function(String id, int index, int partSize, String partHash)? | ||||
|       onUploadPartComplete; | ||||
| 
 | ||||
|   void complete(String id, int size, String url, int type) { | ||||
|     onComplete?.call(id, size, url, type); | ||||
|   } | ||||
| 
 | ||||
|   void hashPartComplete(String id, String partHash, String fileHash) { | ||||
|     onHashPartComplete?.call(id, partHash, fileHash); | ||||
|   } | ||||
| 
 | ||||
|   void hashPartProgress(String id, int index, int size, String partHash) { | ||||
|     onHashPartProgress?.call(id, index, size, partHash); | ||||
|   } | ||||
| 
 | ||||
|   void open(String id, int size) { | ||||
|     onOpen?.call(id, size); | ||||
|   } | ||||
| 
 | ||||
|   void partSize(String id, int partSize, int num) { | ||||
|     onPartSize?.call(id, partSize, num); | ||||
|   } | ||||
| 
 | ||||
|   void uploadProgress( | ||||
|       String id, int fileSize, int streamSize, int storageSize) { | ||||
|     onUploadProgress?.call(id, fileSize, streamSize, storageSize); | ||||
|   } | ||||
| 
 | ||||
|   void uploadID(String id, String uploadID) { | ||||
|     onUploadID?.call(id, uploadID); | ||||
|   } | ||||
| 
 | ||||
|   void uploadPartComplete(String id, int index, int partSize, String partHash) { | ||||
|     onUploadPartComplete?.call(id, index, partSize, partHash); | ||||
|   } | ||||
| } | ||||
| @ -16,7 +16,7 @@ class IMManager { | ||||
| 
 | ||||
|   late OnConnectListener _connectListener; | ||||
|   OnListenerForService? _listenerForService; | ||||
|   OnPutFileListener? _putFileListener; | ||||
|   OnUploadFileListener? _uploadFileListener; | ||||
|   late String userID; | ||||
|   late UserInfo userInfo; | ||||
|   bool isLogined = false; | ||||
| @ -376,45 +376,61 @@ class IMManager { | ||||
|               _listenerForService?.recvNewMessage(msg); | ||||
|               break; | ||||
|           } | ||||
|         } else if (call.method == ListenerType.putFileListener) { | ||||
|         } else if (call.method == ListenerType.uploadFileListener) { | ||||
|           String type = call.arguments['type']; | ||||
|           dynamic data = call.arguments['data']; | ||||
|           switch (type) { | ||||
|             case 'hashComplete': | ||||
|               String putID = data['putID']; | ||||
|               String hash = data['hash']; | ||||
|               int total = data['total']; | ||||
|               _putFileListener?.hashComplete(putID, hash, total); | ||||
|             case 'complete': | ||||
|               String id = data['id']; | ||||
|               int size = data['size']; | ||||
|               String url = data['url']; | ||||
|               int type = data['type']; | ||||
|               _uploadFileListener?.complete(id, size, url, type); | ||||
|               break; | ||||
|             case 'hashProgress': | ||||
|               String putID = data['putID']; | ||||
|               int current = data['current']; | ||||
|               int total = data['total']; | ||||
|               _putFileListener?.hashProgress(putID, current, total); | ||||
|             case 'hashPartComplete': | ||||
|               String id = data['id']; | ||||
|               String partHash = data['partHash']; | ||||
|               String fileHash = data['fileHash']; | ||||
|               _uploadFileListener?.hashPartComplete(id, partHash, fileHash); | ||||
|               break; | ||||
|             case 'hashPartProgress': | ||||
|               String id = data['id']; | ||||
|               int index = data['index']; | ||||
|               int size = data['size']; | ||||
|               String partHash = data['partHash']; | ||||
|               _uploadFileListener?.hashPartProgress(id, index, size, partHash); | ||||
|               break; | ||||
|             case 'open': | ||||
|               String putID = data['putID']; | ||||
|               String id = data['id']; | ||||
|               int size = data['size']; | ||||
|               _putFileListener?.open(putID, size); | ||||
|               _uploadFileListener?.open(id, size); | ||||
|               break; | ||||
|             case 'putComplete': | ||||
|               String putID = data['putID']; | ||||
|               int putType = data['putType']; | ||||
|               int total = data['total']; | ||||
|               _putFileListener?.putComplete(putID, putType, total); | ||||
|             case 'partSize': | ||||
|               String id = data['id']; | ||||
|               int partSize = data['partSize']; | ||||
|               int num = data['num']; | ||||
|               _uploadFileListener?.partSize(id, partSize, num); | ||||
|               break; | ||||
|             case 'putProgress': | ||||
|               String putID = data['putID']; | ||||
|               int save = data['save']; | ||||
|               int current = data['current']; | ||||
|               int total = data['total']; | ||||
|               _putFileListener?.putProgress(putID, save, current, total); | ||||
|             case 'uploadProgress': | ||||
|               String id = data['id']; | ||||
|               int fileSize = data['fileSize']; | ||||
|               int streamSize = data['streamSize']; | ||||
|               int storageSize = data['storageSize']; | ||||
|               _uploadFileListener?.uploadProgress( | ||||
|                   id, fileSize, streamSize, storageSize); | ||||
|               break; | ||||
|             case 'putStart': | ||||
|               String putID = data['putID']; | ||||
|               int current = data['current']; | ||||
|               int total = data['total']; | ||||
|               _putFileListener?.putStart(putID, current, total); | ||||
|             case 'uploadID': | ||||
|               String id = data['id']; | ||||
|               String uploadID = data['uploadID']; | ||||
|               _uploadFileListener?.uploadID(id, uploadID); | ||||
|               break; | ||||
|             case 'uploadPartComplete': | ||||
|               String id = data['id']; | ||||
|               int index = data['index']; | ||||
|               int partSize = data['partSize']; | ||||
|               String partHash = data['partHash']; | ||||
|               _uploadFileListener?.uploadPartComplete( | ||||
|                   id, index, partSize, partHash); | ||||
|               break; | ||||
|           } | ||||
|         } | ||||
| @ -529,7 +545,9 @@ class IMManager { | ||||
| 
 | ||||
|   /// 获取登录状态 | ||||
|   /// 1: logout 2: logging  3:logged | ||||
|   Future<int?> getLoginStatus({String? operationID}) => | ||||
|   Future<int?> getLoginStatus({ | ||||
|     String? operationID, | ||||
|   }) => | ||||
|       _channel.invokeMethod<int>( | ||||
|           'getLoginStatus', | ||||
|           _buildParam({ | ||||
| @ -543,18 +561,22 @@ class IMManager { | ||||
|   Future<UserInfo> getLoginUserInfo() async => userInfo; | ||||
| 
 | ||||
|   /// | ||||
|   Future putFile({ | ||||
|     required String putID, | ||||
|   Future uploadFile({ | ||||
|     required String id, | ||||
|     required String filePath, | ||||
|     required String fileName, | ||||
|     String? contentType, | ||||
|     String? cause, | ||||
|     String? operationID, | ||||
|   }) => | ||||
|       _channel.invokeMethod( | ||||
|           'putFile', | ||||
|           'uploadFile', | ||||
|           _buildParam({ | ||||
|             'putID': putID, | ||||
|             'id': id, | ||||
|             'filePath': filePath, | ||||
|             'name': fileName, | ||||
|             'contentType': contentType, | ||||
|             'cause': cause, | ||||
|             'operationID': Utils.checkOperationID(operationID), | ||||
|           })); | ||||
| 
 | ||||
| @ -593,8 +615,8 @@ class IMManager { | ||||
|   //           'operationID': Utils.checkOperationID(operationID), | ||||
|   //         })); | ||||
| 
 | ||||
|   void setPutFileListener(OnPutFileListener listener) { | ||||
|     _putFileListener = listener; | ||||
|   void setUploadFileListener(OnUploadFileListener listener) { | ||||
|     _uploadFileListener = listener; | ||||
|   } | ||||
| 
 | ||||
|   /// | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user