use of im.actor.core.api.rpc.ResponseGetFileUrls in project actor-platform by actorapp.
the class FileUrlLoader method checkQueue.
public void checkQueue() {
if (isExecuting) {
return;
}
if (pendingFiles.size() == 0) {
return;
}
final ArrayList<RequestedFile> destFiles = new ArrayList<>(pendingFiles);
pendingFiles.clear();
isExecuting = true;
ArrayList<ApiFileLocation> locations = new ArrayList<>();
for (RequestedFile f : destFiles) {
Log.d("FileUrlLoader", "api: " + f.getFileId());
locations.add(new ApiFileLocation(f.getFileId(), f.getAccessHash()));
}
api(new RequestGetFileUrls(locations)).then(responseGetFileUrls -> {
outer: for (RequestedFile f : destFiles) {
for (ApiFileUrlDescription urlDescription : responseGetFileUrls.getFileUrls()) {
if (f.getFileId() == urlDescription.getFileId()) {
Log.d("FileUrlLoader", "resp: " + f.getFileId());
// TODO: Implement Timeouts
f.getResolver().result(urlDescription.getUrl());
continue outer;
}
}
}
isExecuting = false;
scheduleCheck();
}).failure(e -> {
for (RequestedFile f : destFiles) {
f.getResolver().error(e);
}
isExecuting = false;
scheduleCheck();
});
}
Aggregations