parent
0c7124a2a5
commit
e12799da0b
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
Loading…
Reference in new issue