diff --git a/res/layout/list_item.xml b/res/layout/list_item.xml
index 85c553a88..75cd49c18 100644
--- a/res/layout/list_item.xml
+++ b/res/layout/list_item.xml
@@ -33,7 +33,7 @@
android:layout_toRightOf="@id/cover"
android:layout_marginLeft="8.0dip"
android:layout_marginTop="1.0dip"
- android:layout_marginRight="4.0dip" />
+ android:layout_marginRight="32.0dip" />
+
+
\ No newline at end of file
diff --git a/src/com/hippo/ehviewer/data/GalleryPopular.java b/src/com/hippo/ehviewer/data/GalleryPopular.java
new file mode 100644
index 000000000..d8b84a3d8
--- /dev/null
+++ b/src/com/hippo/ehviewer/data/GalleryPopular.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2014 Hippo Seven
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hippo.ehviewer.data;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class GalleryPopular extends GalleryInfo {
+ public long count;
+
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ @Override
+ public GalleryPopular createFromParcel(Parcel source) {
+ GalleryPopular p = new GalleryPopular();
+ p.gid = source.readInt();
+ p.token = source.readString();
+ p.title = source.readString();
+ p.posted = source.readString();
+ p.category = source.readInt();
+ p.thumb = source.readString();
+ p.uploader = source.readString();
+ p.rating = source.readFloat();
+ p.count = source.readLong();
+ return p;
+ }
+
+ @Override
+ public GalleryPopular[] newArray(int size) {
+ return new GalleryPopular[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(gid);
+ dest.writeString(token);
+ dest.writeString(title);
+ dest.writeString(posted);
+ dest.writeInt(category);
+ dest.writeString(thumb);
+ dest.writeString(uploader);
+ dest.writeFloat(rating);
+ dest.writeLong(count);
+ }
+}
diff --git a/src/com/hippo/ehviewer/ehclient/EhClient.java b/src/com/hippo/ehviewer/ehclient/EhClient.java
index 350613f14..78be7ca0d 100644
--- a/src/com/hippo/ehviewer/ehclient/EhClient.java
+++ b/src/com/hippo/ehviewer/ehclient/EhClient.java
@@ -45,6 +45,7 @@ import com.hippo.ehviewer.R;
import com.hippo.ehviewer.data.Comment;
import com.hippo.ehviewer.data.GalleryDetail;
import com.hippo.ehviewer.data.GalleryInfo;
+import com.hippo.ehviewer.data.GalleryPopular;
import com.hippo.ehviewer.data.PreviewList;
import com.hippo.ehviewer.gallery.data.ImageSet;
import com.hippo.ehviewer.network.Downloader;
@@ -1813,7 +1814,7 @@ public class EhClient {
JSONArray ja = js.getJSONArray("galleries");
for (int i = 0; i < ja.length(); i++) {
JSONObject j = ja.getJSONObject(i);
- GalleryInfo gi = new GalleryInfo();
+ GalleryPopular gi = new GalleryPopular();
gi.gid = j.getInt("gid");
gi.token = j.getString("token");
gi.title = StringEscapeUtils.unescapeHtml4(j.getString("title"));
@@ -1822,6 +1823,7 @@ public class EhClient {
gi.category = getType(j.getString("category"));
gi.uploader = j.getString("uploader");
gi.rating = Float.parseFloat(j.getString("rating"));
+ gi.count = j.getLong("count");
gis.add(gi);
}
diff --git a/src/com/hippo/ehviewer/ui/AbstractGalleryActivity.java b/src/com/hippo/ehviewer/ui/AbstractGalleryActivity.java
index 9f71c6379..910420f15 100644
--- a/src/com/hippo/ehviewer/ui/AbstractGalleryActivity.java
+++ b/src/com/hippo/ehviewer/ui/AbstractGalleryActivity.java
@@ -23,6 +23,7 @@ import com.hippo.ehviewer.AppContext;
import com.hippo.ehviewer.ImageGeterManager;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.data.GalleryInfo;
+import com.hippo.ehviewer.data.GalleryPopular;
import com.hippo.ehviewer.ehclient.EhClient;
import com.hippo.ehviewer.util.Cache;
import com.hippo.ehviewer.util.Ui;
@@ -399,6 +400,23 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
public long getItemId(int position) {
return position;
}
+
+ public String getCountStr(long count) {
+ String str = null;
+ if (count < 0) {
+ str = "0";
+ } else if (count < 1000) {
+ str = String.valueOf(count);
+ } else if (count < 1E10) {
+ double p = Math.log10(count);
+ int pInt = (int)p;
+ str = Math.round(count / Math.pow(10, pInt)) + "E" + pInt;
+ } else {
+ str = "***";
+ }
+ return str;
+ }
+
@Override
public View getView(int position, View convertView, ViewGroup parent) {
GalleryInfo gi= mGiList.get(position);
@@ -448,6 +466,15 @@ public abstract class AbstractGalleryActivity extends AbstractSlidingActivity
// set posted
TextView posted = (TextView) convertView.findViewById(R.id.posted);
posted.setText(gi.posted);
+
+ // Show count if possible
+ TextView count = (TextView) convertView.findViewById(R.id.count);
+ if (gi instanceof GalleryPopular) {
+ count.setVisibility(View.VISIBLE);
+ count.setText(getCountStr(((GalleryPopular)gi).count));
+ } else {
+ count.setVisibility(View.GONE);
+ }
}
return convertView;
}