Matched API Client to online API return values and calls:

- added fav_file API call
- added "favorites" value to FileInfo holder
This commit is contained in:
CrushedPixel
2015-05-16 17:44:07 +02:00
parent 7c9b0eb8a7
commit 9a83eba6cf
4 changed files with 16 additions and 4 deletions

View File

@@ -73,9 +73,8 @@ public class ApiClient {
return files;
}
public FileInfo[] getFileInfo(String auth, List<Integer> ids) throws IOException, ApiException {
public FileInfo[] getFileInfo(List<Integer> ids) throws IOException, ApiException {
QueryBuilder builder = new QueryBuilder(ApiMethods.replay_files);
builder.put("auth", auth);
builder.put("ids", buildListString(ids));
FileInfo[] info = invokeAndReturn(builder, FileInfo[].class);
return info;
@@ -138,6 +137,14 @@ public class ApiClient {
invokeAndReturn(builder, Success.class);
}
public void favFile(String auth, int file, boolean fav) throws IOException, ApiException {
QueryBuilder builder = new QueryBuilder(ApiMethods.fav_file);
builder.put("auth", auth);
builder.put("id", file);
builder.put("fav", fav);
invokeAndReturn(builder, Success.class);
}
public void removeFile(String auth, int file) throws IOException, ApiException {
QueryBuilder builder = new QueryBuilder(ApiMethods.remove_file);
builder.put("auth", auth);

View File

@@ -13,6 +13,7 @@ public class ApiMethods {
public static final String get_thumbnail = "get_thumbnail";
public static final String remove_file = "remove_file";
public static final String rate_file = "rate_file";
public static final String fav_file = "fav_file";
public static final String check_auth = "check_auth";
public static final String get_language = "get_language";
}

View File

@@ -11,13 +11,14 @@ public class FileInfo {
private int size;
private int category;
private int downloads;
private int favorites;
private String name;
private boolean thumbnail;
public FileInfo(int id, ReplayMetaData metadata, String owner,
Rating ratings, int size, int category, int downloads, String name,
boolean thumbnail) {
boolean thumbnail, int favorites) {
this.id = id;
this.metadata = metadata;
this.owner = owner;
@@ -27,6 +28,7 @@ public class FileInfo {
this.downloads = downloads;
this.name = name;
this.thumbnail = thumbnail;
this.favorites = favorites;
}
public int getId() {
@@ -57,6 +59,8 @@ public class FileInfo {
return downloads;
}
public int getFavorites() { return favorites; }
public String getName() {
return name;
}

View File

@@ -84,7 +84,7 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
for(Pair<Pair<File, ReplayMetaData>, File> p : replayFileList) {
FileInfo fileInfo = new FileInfo(-1, p.first().second(), null, null,
-1, -1, -1, FilenameUtils.getBaseName(p.first().first().getName()), true);
-1, -1, -1, FilenameUtils.getBaseName(p.first().first().getName()), true, -1);
replayGuiList.addEntry(fileInfo, p.second());
}
}