use of im.actor.core.api.ApiFileLocation in project actor-platform by actorapp.
the class FileReference method parse.
@Override
public void parse(BserValues values) throws IOException {
// Is Old layout
if (!values.getBool(5, false)) {
long fileId = values.getLong(1);
long accessHash = values.getLong(2);
setWrapped(new ApiFileLocation(fileId, accessHash));
}
// Deserialize new layout
super.parse(values);
fileSize = values.getInt(3);
fileName = values.getString(4);
}
use of im.actor.core.api.ApiFileLocation 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();
});
}
use of im.actor.core.api.ApiFileLocation in project actor-platform by actorapp.
the class GroupAvatarChangeActor method uploadCompleted.
public void uploadCompleted(final long rid, FileReference fileReference) {
if (!tasksMap.containsKey(rid)) {
return;
}
final int gid = tasksMap.get(rid);
long accessHash = getGroup(gid).getAccessHash();
if (currentTasks.get(gid) != rid) {
return;
}
api(new RequestEditGroupAvatar(new ApiGroupOutPeer(gid, accessHash), rid, new ApiFileLocation(fileReference.getFileId(), fileReference.getAccessHash()), ApiSupportConfiguration.OPTIMIZATIONS)).flatMap(responseEditGroupAvatar -> updates().applyUpdate(responseEditGroupAvatar.getSeq(), responseEditGroupAvatar.getState(), new UpdateGroupAvatarChanged(gid, responseEditGroupAvatar.getAvatar()))).then(v -> avatarChanged(gid, rid)).failure(e -> {
if (!tasksMap.containsKey(rid)) {
return;
}
final int gid2 = tasksMap.get(rid);
if (currentTasks.get(gid2) != rid) {
return;
}
currentTasks.remove(gid2);
tasksMap.remove(rid);
context().getGroupsModule().getAvatarVM(gid2).getUploadState().change(new AvatarUploadState(null, false));
});
}
Aggregations