view/download/comment count

This commit is contained in:
bancika
2016-10-27 12:39:11 +02:00
parent 3e695a37f0
commit 0da4375857
8 changed files with 37 additions and 29 deletions
@@ -94,7 +94,6 @@ public interface IServiceAPI {
*
* @param criteria
* @param category
* @param format
* @param page
* @param itemsPerPage
* @param sort
@@ -102,8 +101,7 @@ public interface IServiceAPI {
* objects.
*/
Object search(@ParamName("criteria") String criteria, @ParamName("category") String category,
@ParamName("format") String format, @ParamName("page") Integer page,
@ParamName("itemsPerPage") Integer itemsPerPage, @ParamName("sort") String sort);
@ParamName("page") Integer page, @ParamName("itemsPerPage") Integer itemsPerPage, @ParamName("sort") String sort);
/**
* Uploads a project using token to authenticate.
@@ -16,26 +16,12 @@ public class ProjectEntity implements Serializable {
private String downloadUrl;
private int viewCount;
private int downloadCount;
private int commentCount;
public ProjectEntity() {
super();
}
public ProjectEntity(int id, String name, String description, String owner, String category, String updated,
String thumbnailUrl, String downloadUrl, int viewCount, int downloadCount) {
super();
this.id = id;
this.name = name;
this.description = description;
this.owner = owner;
this.category = category;
this.updated = updated;
this.thumbnailUrl = thumbnailUrl;
this.downloadUrl = downloadUrl;
this.viewCount = viewCount;
this.downloadCount = downloadCount;
}
public int getId() {
return id;
}
@@ -114,13 +100,22 @@ public class ProjectEntity implements Serializable {
public void setDownloadCount(int downloadCount) {
this.downloadCount = downloadCount;
}
}
public int getCommentCount() {
return commentCount;
}
public void setCommentCount(int commentCount) {
this.commentCount = commentCount;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((category == null) ? 0 : category.hashCode());
result = prime * result + commentCount;
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + downloadCount;
result = prime * result + ((downloadUrl == null) ? 0 : downloadUrl.hashCode());
@@ -147,6 +142,8 @@ public class ProjectEntity implements Serializable {
return false;
} else if (!category.equals(other.category))
return false;
if (commentCount != other.commentCount)
return false;
if (description == null) {
if (other.description != null)
return false;
@@ -215,7 +215,7 @@ public class CloudPresenter {
throws CloudException {
LOG.info(String.format("search(%1$s,%2$s,%3$s,%4$d,%5$d)", criteria, category, sortOrder, pageNumber, itemsPerPage));
try {
Object res = service.search(criteria, category, "json", pageNumber, itemsPerPage, sortOrder);
Object res = service.search(criteria, category, pageNumber, itemsPerPage, sortOrder);
// Thread.sleep(2000);
if (res == null)
throw new CloudException("Failed to retreive search results.");
@@ -225,7 +225,8 @@ public class CloudPresenter {
@SuppressWarnings("unchecked")
List<ProjectEntity> projects = (List<ProjectEntity>) res;
LOG.info("Received " + projects.size() + " results. Downloading thumbnails...");
// Download thumbnails and replace urls with local paths to speed up loading in the main thread
// Download thumbnails and replace urls with local paths to speed up loading in the main
// thread
for (int i = 0; i < projects.size(); i++) {
String url = projects.get(i).getThumbnailUrl();
URL website = new URL(url);
@@ -233,7 +234,7 @@ public class CloudPresenter {
File temp = File.createTempFile("thumbnail", ".png");
FileOutputStream fos = new FileOutputStream(temp);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
projects.get(i).setThumbnailUrl(temp.getAbsolutePath());
projects.get(i).setThumbnailUrl(temp.getAbsolutePath());
fos.close();
}
LOG.info("Finished downloading thumbnails.");