Network
Network 은 HSP 에서 기본으로 제공하는 API로 별도의 설정 없이 사용 가능하다.
Network HSP 의 Operation 또는 Hub 와 통신을 쉽게 사용하기 위해서 만들어졌으며 서버와 주고 받는 데이터는 Map 을 통해 전달할 수 있다.
doPost
doPost 는 POST 형식으로 HSP 의 Operation 또는 Hub 에 데이터를 전달한다.
Example 1
val container = MessageContainer<Map<String, Any>>().apply {
setContext(MapUtils.newNetworkContext(SERVICE_NAME))
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, String>().apply {
put(PUBLIC_KEY, "publicKey")
})
})
}
// 3.10.18 이상
DAPNetwork.doPost(activity, container, {
// TODO
}) {
// TODO
}
// 3.10.18 이하
DAPNetwork.doPost(activity, container) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
setContext(MapUtils.newNetworkContext(SERVICE_NAME))
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, String>().apply {
put(PUBLIC_KEY, "publicKey")
})
})
}
// 3.10.18 이상
DAPNetwork.doPost(activity, container, {
// TODO
}) {
// TODO
}
// 3.10.18 이하
DAPNetwork.doPost(activity, container) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
HashMap<String, String> payload = new HashMap<>();
payload.put(PUBLIC_KEY, "publicKey");
HoneMobileMessage<Map> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer container = new MessageContainer();
container.setContext(MapUtils.newNetworkContext(SERVICE_NAME));
container.setMessage(message);
// 3.10.18 이상
DAPNetwork.doPost(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
});
// 3.10.18 이하
DAPNetwork.doPost(MainActivity.this, container, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
payload.put(PUBLIC_KEY, "publicKey");
HoneMobileMessage<Map> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer container = new MessageContainer();
container.setContext(MapUtils.newNetworkContext(SERVICE_NAME));
container.setMessage(message);
// 3.10.18 이상
DAPNetwork.doPost(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
});
// 3.10.18 이하
DAPNetwork.doPost(MainActivity.this, container, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
Example 2
val paramsMap = hashMapOf<String, Any>().apply {
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "notice")
put("serviceName", "getNotice")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("pageNumber", "1")
put("rowsPerPage", "10")
})
})
}
// 인자가 Map 형태인 경우 3.10.18 이하에서만 사용 가능 합니다.
DAPNetwork.doPost(activity, paramsMap) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "notice")
put("serviceName", "getNotice")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("pageNumber", "1")
put("rowsPerPage", "10")
})
})
}
// 인자가 Map 형태인 경우 3.10.18 이하에서만 사용 가능 합니다.
DAPNetwork.doPost(activity, paramsMap) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "notice");
context.put("serviceName", "getNotice");
Map<String, Object> payload = new HashMap<>();
payload.put("pageNumber", "1");
payload.put("rowsPerPage", "10");
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
// 인자가 Map 형태인 경우 3.10.18 이하에서만 사용 가능 합니다.
DAPNetwork.doPost(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
context.put("targetName", "hub1");
context.put("serviceCategory", "notice");
context.put("serviceName", "getNotice");
Map<String, Object> payload = new HashMap<>();
payload.put("pageNumber", "1");
payload.put("rowsPerPage", "10");
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
// 인자가 Map 형태인 경우 3.10.18 이하에서만 사용 가능 합니다.
DAPNetwork.doPost(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
doUpload
doUpload 는 HSP 의 Hub 에 파일 업로드를 요청 한다.
Example (3.10.18 이상)
val container = MessageContainer<Map<String, Any>>().apply {
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUpload(activity, container, {
// TODO
}) {
// TODO
}
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUpload(activity, container, {
// TODO
}) {
// TODO
}
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doUpload(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doUpload(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
});
Example (3.10.18 이하)
val paramsMap = hashMapOf<String, Any>().apply {
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUpload(activity, paramsMap) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUpload(activity, paramsMap) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
// doUpload 는 async 형태가 아니며 async 형태로 사용을 원하면 asyncDoUpload 를 이용하면 된다.
DAPNetwork.doUpload(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
// doUpload 는 async 형태가 아니며 async 형태로 사용을 원하면 asyncDoUpload 를 이용하면 된다.
DAPNetwork.doUpload(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
doDownload
doDownload 는 HSP 의 Hub 에 파일 다운로드를 요청 한다.
Example (3.10.18 이상)
val container = MessageContainer<Map<String, Any>>().apply {
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownload(activity, container, {
// TODO
}) {
// TODO
}
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownload(activity, container, {
// TODO
}) {
// TODO
}
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doDownload(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doDownload(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
});
Example (3.10.18 이하)
val paramsMap = hashMapOf<String, Any>().apply {
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownload(activity, paramsMap) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownload(activity, paramsMap) { result, value ->
when (result) {
OnResultListener.TRUE -> {
// TODO
}
else -> {
// TODO
}
}
}
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
DAPNetwork.doDownload(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
DAPNetwork.doDownload(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
});
doUploadWithProgress
doUploadWithProgress 는 HSP 의 Hub 에 파일 업로드를 요청하면서 진행 상황을 전달 받는다.
Example (3.10.18 이상)
val container = MessageContainer<Map<String, Any>>().apply {
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUploadWithProgress(activity, container, {
// TODO
}, {
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUploadWithProgress(activity, container, {
// TODO
}, {
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doUploadWithProgress(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doUploadWithProgress(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});
Example (3.10.18 이하)
val paramsMap = hashMapOf<String, Any>().apply {
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUploadWithProgress(activity, paramsMap, { result, value ->
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileUpload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("mulitpartFiles", arrayListOf("/sdcard/test.png"))
})
})
}
DAPNetwork.doUploadWithProgress(activity, paramsMap, { result, value ->
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
DAPNetwork.doUploadWithProgress(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileUpload");
ArrayList<String> pathes = new ArrayList<>();
pathes.add("/sdcard/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("mulitpartFiles", pathes);
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
DAPNetwork.doUploadWithProgress(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});
doDownloadWithProgress
doDownloadWithProgress 는 HSP 의 Hub 에 파일 다운로드를 요청 하면서 진행 상황을 전달 받는다.
Example (3.10.18 이상)
val container = MessageContainer<Map<String, Any>>().apply {
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownloadWithProgress(activity, container, {
// TODO
}, {
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
setContext(hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
setMessage(HoneMobileMessage<Map<String, Any>>().apply {
setPayload(hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownloadWithProgress(activity, container, {
// TODO
}, {
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doDownloadWithProgress(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
HoneMobileMessage<Map<String, Object>> message = new HoneMobileMessage<>();
message.setPayload(payload);
MessageContainer<Map<String, Object>> container = new MessageContainer<>();
container.setContext(context);
container.setMessage(message);
DAPNetwork.doDownloadWithProgress(MainActivity.this, container, result -> {
// TODO
}, e -> {
// TODO
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});
Example (3.10.18 이하)
val paramsMap = hashMapOf<String, Any>().apply {
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownloadWithProgress(activity, paramsMap, {
// TODO
}, {
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
put("context", hashMapOf<String, Any>().apply {
put("targetName", "hub1")
put("serviceCategory", "util")
put("serviceName", "fileDownload")
})
put("message", hashMapOf<String, Any>().apply {
put("header", hashMapOf<String, Any>())
put("payload", hashMapOf<String, Any>().apply {
put("userId", "user")
put("key2", "value")
put("files", arrayListOf("/test.png"))
})
})
}
DAPNetwork.doDownloadWithProgress(activity, paramsMap, {
// TODO
}, {
// TODO
}, object: OnUpdateListener() {
override fun onProgress(currentByte: Long, totalByte: Long, percent: Int) {
// TODO
}
})
Map<String, Object> context = new HashMap<>();
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
DAPNetwork.doDownloadWithProgress(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});
context.put("targetName", "hub1");
context.put("serviceCategory", "util");
context.put("serviceName", "fileDownload");
ArrayList<String> files = new ArrayList<>();
files.add("/test.png");
Map<String, Object> payload = new HashMap<>();
payload.put("userId", "user");
payload.put("files", files);
payload.put("key2", "value");
Map<String, Object> message = new HashMap<>();
message.put("header", new HashMap());
message.put("payload", payload);
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("context", context);
paramsMap.put("message", message);
DAPNetwork.doDownloadWithProgress(MainActivity.this, paramsMap, (result, value) -> {
switch (result) {
case OnResultListener.TRUE:
// TODO
break;
default:
// TODO
break;
}
}, new OnUpdateListener() {
@Override
public void onProgress(long currentByte, long totalByte, int percent) {
// TODO
}
});