putFile replace to uploadFile
This commit is contained in:
parent
27eb0f78d2
commit
c0618458fa
@ -53,5 +53,5 @@ dependencies {
|
|||||||
// 本地依赖,现将aar复制到libs/io/openim/core-sdk/0.0.1/ 下,命名core-sdk-0.0.1.aar
|
// 本地依赖,现将aar复制到libs/io/openim/core-sdk/0.0.1/ 下,命名core-sdk-0.0.1.aar
|
||||||
// implementation 'io.openim: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'
|
// api 'io.openim:core-sdk:2.3.5-t44@aar'
|
||||||
implementation 'io.openim:core-sdk:3.0.0-beta09@aar'
|
implementation 'io.openim:core-sdk:3.0.0-beta11@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", "uploadComplete", 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.FlutterOpenimSdkPlugin;
|
||||||
import io.openim.flutter_openim_sdk.listener.OnBaseListener;
|
import io.openim.flutter_openim_sdk.listener.OnBaseListener;
|
||||||
import io.openim.flutter_openim_sdk.listener.OnConnListener;
|
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 io.openim.flutter_openim_sdk.util.CommonUtil;
|
||||||
import open_im_sdk.Open_im_sdk;
|
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")));
|
CommonUtil.runMainThreadReturn(result, Open_im_sdk.getLoginStatus(value(methodCall, "operationID")));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void putFile(MethodCall methodCall, MethodChannel.Result result) {
|
public void uploadFile(MethodCall methodCall, MethodChannel.Result result) {
|
||||||
Open_im_sdk.putFile(
|
Open_im_sdk.uploadFile(
|
||||||
new OnBaseListener(result, methodCall),
|
new OnBaseListener(result, methodCall),
|
||||||
value(methodCall, "operationID"),
|
value(methodCall, "operationID"),
|
||||||
jsonValue(methodCall),
|
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/listener_for_service.dart';
|
||||||
export 'src/listener/message_kv_info_listener.dart';
|
export 'src/listener/message_kv_info_listener.dart';
|
||||||
export 'src/listener/msg_send_progress_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/user_listener.dart';
|
export 'src/listener/user_listener.dart';
|
||||||
export 'src/manager/im_conversation_manager.dart';
|
export 'src/manager/im_conversation_manager.dart';
|
||||||
export 'src/manager/im_friendship_manager.dart';
|
export 'src/manager/im_friendship_manager.dart';
|
||||||
|
@ -14,5 +14,5 @@ class ListenerType {
|
|||||||
static const customBusinessListener = "customBusinessListener";
|
static const customBusinessListener = "customBusinessListener";
|
||||||
static const messageKvInfoListener = "messageKvInfoListener";
|
static const messageKvInfoListener = "messageKvInfoListener";
|
||||||
static const listenerForService = "listenerForService";
|
static const listenerForService = "listenerForService";
|
||||||
static const putFileListener = "putFileListener";
|
static const uploadFileListener = "uploadFileListener";
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
class OnPutFileListener {
|
|
||||||
Function(String putID, String hash, int total)? onHashComplete;
|
|
||||||
Function(String putID, int current, int total)? onHashProgress;
|
|
||||||
Function(String putID, int size)? onOpen;
|
|
||||||
Function(String putID, int total, int putType)? onPutComplete;
|
|
||||||
Function(String putID, int save, int current, int total)? onPutProgress;
|
|
||||||
Function(String putID, int current, int total)? onPutStart;
|
|
||||||
|
|
||||||
void hashComplete(String putID, String hash, int total) {
|
|
||||||
onHashComplete?.call(putID, hash, total);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hashProgress(String putID, int current, int total) {
|
|
||||||
onHashProgress?.call(putID, current, total);
|
|
||||||
}
|
|
||||||
|
|
||||||
void open(String putID, int size) {
|
|
||||||
onOpen?.call(putID, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void putComplete(String putID, int total, int putType) {
|
|
||||||
onPutComplete?.call(putID, total, putType);
|
|
||||||
}
|
|
||||||
|
|
||||||
void putProgress(String putID, int save, int current, int total) {
|
|
||||||
onPutProgress?.call(putID, save, current, total);
|
|
||||||
}
|
|
||||||
|
|
||||||
void putStart(String putID, int current, int total) {
|
|
||||||
onPutStart?.call(putID, current, total);
|
|
||||||
}
|
|
||||||
}
|
|
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)?
|
||||||
|
onUploadComplete;
|
||||||
|
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 uploadComplete(
|
||||||
|
String id, int fileSize, int streamSize, int storageSize) {
|
||||||
|
onUploadComplete?.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);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||||
|
import 'package:flutter_openim_sdk/src/listener/upload_file_listener.dart';
|
||||||
import 'package:flutter_openim_sdk/src/logger.dart';
|
import 'package:flutter_openim_sdk/src/logger.dart';
|
||||||
|
|
||||||
class IMManager {
|
class IMManager {
|
||||||
@ -15,7 +16,7 @@ class IMManager {
|
|||||||
|
|
||||||
late OnConnectListener _connectListener;
|
late OnConnectListener _connectListener;
|
||||||
OnListenerForService? _listenerForService;
|
OnListenerForService? _listenerForService;
|
||||||
OnPutFileListener? _putFileListener;
|
OnUploadFileListener? _uploadFileListener;
|
||||||
late String userID;
|
late String userID;
|
||||||
late UserInfo userInfo;
|
late UserInfo userInfo;
|
||||||
bool isLogined = false;
|
bool isLogined = false;
|
||||||
@ -316,45 +317,61 @@ class IMManager {
|
|||||||
_listenerForService?.recvNewMessage(msg);
|
_listenerForService?.recvNewMessage(msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (call.method == ListenerType.putFileListener) {
|
} else if (call.method == ListenerType.uploadFileListener) {
|
||||||
String type = call.arguments['type'];
|
String type = call.arguments['type'];
|
||||||
dynamic data = call.arguments['data'];
|
dynamic data = call.arguments['data'];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'hashComplete':
|
case 'complete':
|
||||||
String putID = data['putID'];
|
String id = data['id'];
|
||||||
String hash = data['hash'];
|
int size = data['size'];
|
||||||
int total = data['total'];
|
String url = data['url'];
|
||||||
_putFileListener?.hashComplete(putID, hash, total);
|
int type = data['type'];
|
||||||
|
_uploadFileListener?.complete(id, size, url, type);
|
||||||
break;
|
break;
|
||||||
case 'hashProgress':
|
case 'hashPartComplete':
|
||||||
String putID = data['putID'];
|
String id = data['id'];
|
||||||
int current = data['current'];
|
String partHash = data['partHash'];
|
||||||
int total = data['total'];
|
String fileHash = data['fileHash'];
|
||||||
_putFileListener?.hashProgress(putID, current, total);
|
_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;
|
break;
|
||||||
case 'open':
|
case 'open':
|
||||||
String putID = data['putID'];
|
String id = data['id'];
|
||||||
int size = data['size'];
|
int size = data['size'];
|
||||||
_putFileListener?.open(putID, size);
|
_uploadFileListener?.open(id, size);
|
||||||
break;
|
break;
|
||||||
case 'putComplete':
|
case 'partSize':
|
||||||
String putID = data['putID'];
|
String id = data['id'];
|
||||||
int putType = data['putType'];
|
int partSize = data['partSize'];
|
||||||
int total = data['total'];
|
int num = data['num'];
|
||||||
_putFileListener?.putComplete(putID, putType, total);
|
_uploadFileListener?.partSize(id, partSize, num);
|
||||||
break;
|
break;
|
||||||
case 'putProgress':
|
case 'uploadComplete':
|
||||||
String putID = data['putID'];
|
String id = data['id'];
|
||||||
int save = data['save'];
|
int fileSize = data['fileSize'];
|
||||||
int current = data['current'];
|
int streamSize = data['streamSize'];
|
||||||
int total = data['total'];
|
int storageSize = data['storageSize'];
|
||||||
_putFileListener?.putProgress(putID, save, current, total);
|
_uploadFileListener?.uploadComplete(
|
||||||
|
id, fileSize, streamSize, storageSize);
|
||||||
break;
|
break;
|
||||||
case 'putStart':
|
case 'uploadID':
|
||||||
String putID = data['putID'];
|
String id = data['id'];
|
||||||
int current = data['current'];
|
String uploadID = data['uploadID'];
|
||||||
int total = data['total'];
|
_uploadFileListener?.uploadID(id, uploadID);
|
||||||
_putFileListener?.putStart(putID, current, total);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,18 +502,22 @@ class IMManager {
|
|||||||
Future<UserInfo> getLoginUserInfo() async => userInfo;
|
Future<UserInfo> getLoginUserInfo() async => userInfo;
|
||||||
|
|
||||||
///
|
///
|
||||||
Future putFile({
|
Future uploadFile({
|
||||||
required String putID,
|
required String id,
|
||||||
required String filePath,
|
required String filePath,
|
||||||
required String fileName,
|
required String fileName,
|
||||||
|
String? contentType,
|
||||||
|
String? cause,
|
||||||
String? operationID,
|
String? operationID,
|
||||||
}) =>
|
}) =>
|
||||||
_channel.invokeMethod(
|
_channel.invokeMethod(
|
||||||
'putFile',
|
'uploadFile',
|
||||||
_buildParam({
|
_buildParam({
|
||||||
'putID': putID,
|
'id': id,
|
||||||
'filePath': filePath,
|
'filePath': filePath,
|
||||||
'name': fileName,
|
'name': fileName,
|
||||||
|
'contentType': contentType,
|
||||||
|
'cause': cause,
|
||||||
'operationID': Utils.checkOperationID(operationID),
|
'operationID': Utils.checkOperationID(operationID),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -535,8 +556,8 @@ class IMManager {
|
|||||||
// 'operationID': Utils.checkOperationID(operationID),
|
// 'operationID': Utils.checkOperationID(operationID),
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
void setPutFileListener(OnPutFileListener listener) {
|
void setUploadFileListener(OnUploadFileListener listener) {
|
||||||
_putFileListener = listener;
|
_uploadFileListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user