use of com.backendless.async.message.AsyncMessage in project Android-SDK by Backendless.
the class Cache method get.
public <T> void get(final String key, final AsyncCallback<T> callback) {
final Type asyncCallbackType = ReflectionUtil.getCallbackGenericType(callback);
ThreadPoolService.getPoolExecutor().execute(new Runnable() {
@Override
public void run() {
try {
T result = (T) get(key, (Class) asyncCallbackType);
ResponseCarrier.getInstance().deliverMessage(new AsyncMessage<T>(result, callback));
} catch (BackendlessException e) {
ResponseCarrier.getInstance().deliverMessage(new AsyncMessage<T>(new BackendlessFault(e), callback));
}
}
});
}
use of com.backendless.async.message.AsyncMessage in project Android-SDK by Backendless.
the class UploadFileAsyncTask method doInBackground.
private void doInBackground(final File file, final String path) {
final AsyncUploadMessage asyncUploadMessage = new AsyncUploadMessage(uploadCallback);
ThreadPoolService.getPoolExecutor().execute(new Runnable() {
@Override
public void run() {
try {
FileOutputStreamRouter fileOutputStreamRouter = new FileOutputStreamRouter(file, new UploadCallback() {
public void onProgressUpdate(Integer progress) {
asyncUploadMessage.setCurrentProgress(progress);
ResponseCarrier.getInstance().deliverMessage(asyncUploadMessage);
}
});
BackendlessFile result = Backendless.Files.uploadFromStream(fileOutputStreamRouter, file.getName(), path, overwrite);
ResponseCarrier.getInstance().deliverMessage(new AsyncMessage<BackendlessFile>(result, responder));
} catch (Exception e) {
ResponseCarrier.getInstance().deliverMessage(new AsyncMessage<BackendlessFile>(new BackendlessFault(e), responder));
}
}
});
}
Aggregations