Update field name
This commit is contained in:
1 parent
cf0659db85
commit
3cac88362c
10 files changed
+45
-45
No files matched your search
@@ -31,9 +31,9 @@ public class GalleryDetail extends GalleryInfo {
|
||||
public String size;
|
||||
public String resize;
|
||||
public int pages;
|
||||
public int favoredTimes;
|
||||
public boolean isFavored;
|
||||
public int ratedTimes;
|
||||
public int favoriteCount;
|
||||
public boolean isFavorited;
|
||||
public int ratingCount;
|
||||
public GalleryTagGroup[] tags;
|
||||
public GalleryComment[] comments;
|
||||
public int previewPages;
|
||||
@@ -55,9 +55,9 @@ public class GalleryDetail extends GalleryInfo {
|
||||
dest.writeString(this.size);
|
||||
dest.writeString(this.resize);
|
||||
dest.writeInt(this.pages);
|
||||
dest.writeInt(this.favoredTimes);
|
||||
dest.writeByte(isFavored ? (byte) 1 : (byte) 0);
|
||||
dest.writeInt(this.ratedTimes);
|
||||
dest.writeInt(this.favoriteCount);
|
||||
dest.writeByte(isFavorited ? (byte) 1 : (byte) 0);
|
||||
dest.writeInt(this.ratingCount);
|
||||
dest.writeParcelableArray(this.tags, 0);
|
||||
dest.writeParcelableArray(this.comments, 0);
|
||||
dest.writeInt(this.previewPages);
|
||||
@@ -77,9 +77,9 @@ public class GalleryDetail extends GalleryInfo {
|
||||
this.size = in.readString();
|
||||
this.resize = in.readString();
|
||||
this.pages = in.readInt();
|
||||
this.favoredTimes = in.readInt();
|
||||
this.isFavored = in.readByte() != 0;
|
||||
this.ratedTimes = in.readInt();
|
||||
this.favoriteCount = in.readInt();
|
||||
this.isFavorited = in.readByte() != 0;
|
||||
this.ratingCount = in.readInt();
|
||||
Parcelable[] array = in.readParcelableArray(GalleryTagGroup.class.getClassLoader());
|
||||
if (array != null) {
|
||||
this.tags = Arrays.copyOf(array, array.length, GalleryTagGroup[].class);
|
||||
|
||||
@@ -171,7 +171,7 @@ public class GalleryDetailParser {
|
||||
gd.visible = "";
|
||||
gd.size = "";
|
||||
gd.pages = 0;
|
||||
gd.favoredTimes = 0;
|
||||
gd.favoriteCount = 0;
|
||||
try {
|
||||
Elements es = gdd.child(0).child(0).children();
|
||||
for (int i = 0, n = es.size(); i < n; i++) {
|
||||
@@ -184,10 +184,10 @@ public class GalleryDetailParser {
|
||||
// Rating count
|
||||
Element rating_count = gm.getElementById("rating_count");
|
||||
if (null != rating_count) {
|
||||
gd.ratedTimes = NumberUtils.parseIntSafely(
|
||||
gd.ratingCount = NumberUtils.parseIntSafely(
|
||||
StringUtils.trim(rating_count.text()), 0);
|
||||
} else {
|
||||
gd.ratedTimes = 0;
|
||||
gd.ratingCount = 0;
|
||||
}
|
||||
|
||||
// Rating
|
||||
@@ -208,9 +208,9 @@ public class GalleryDetailParser {
|
||||
gd.rating = Float.NaN;
|
||||
}
|
||||
|
||||
// isFavored
|
||||
// isFavorited
|
||||
Element gdf = gm.getElementById("gdf");
|
||||
gd.isFavored = null != gdf && !StringUtils.trim(gdf.text()).equals("Add to Favorites");
|
||||
gd.isFavorited = null != gdf && !StringUtils.trim(gdf.text()).equals("Add to Favorites");
|
||||
} catch (Exception e) {
|
||||
throw new ParseException("Can't parse gallery detail", body);
|
||||
}
|
||||
@@ -244,17 +244,17 @@ public class GalleryDetailParser {
|
||||
} else if (key.startsWith("Favorited")) {
|
||||
switch (value) {
|
||||
case "Never":
|
||||
gd.favoredTimes = 0;
|
||||
gd.favoriteCount = 0;
|
||||
break;
|
||||
case "Once":
|
||||
gd.favoredTimes = 1;
|
||||
gd.favoriteCount = 1;
|
||||
break;
|
||||
default:
|
||||
int index = value.indexOf(' ');
|
||||
if (index == -1) {
|
||||
gd.favoredTimes = 0;
|
||||
gd.favoriteCount = 0;
|
||||
} else {
|
||||
gd.favoredTimes = NumberUtils.parseIntSafely(value.substring(0, index), 0);
|
||||
gd.favoriteCount = NumberUtils.parseIntSafely(value.substring(0, index), 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class GalleryPageParser {
|
||||
|
||||
private static Pattern IMAGE_URL_PATTERN = Pattern.compile("<div id=\"i3\"><a[^>]+><img id=\"img\" src=\"([^\"]+)\"");
|
||||
private static Pattern SKIP_HATH_KEY_PATTERN = Pattern.compile("onclick=\"return nl\\('([^\\)]+)'\\)");
|
||||
private static final Pattern IMAGE_URL_PATTERN = Pattern.compile("<div id=\"i3\"><a[^>]+><img id=\"img\" src=\"([^\"]+)\"");
|
||||
private static final Pattern SKIP_HATH_KEY_PATTERN = Pattern.compile("onclick=\"return nl\\('([^\\)]+)'\\)");
|
||||
|
||||
public static Result parse(String body) throws ParseException {
|
||||
Matcher m;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class RateGalleryParser {
|
||||
|
||||
public static class Result {
|
||||
public float rating;
|
||||
public int ratedTimes;
|
||||
public int ratingCount;
|
||||
}
|
||||
|
||||
public static Result parse(String body) throws Exception {
|
||||
@@ -33,7 +33,7 @@ public class RateGalleryParser {
|
||||
JSONObject jsonObject = new JSONObject(body);
|
||||
Result result = new Result();
|
||||
result.rating = (float)jsonObject.getDouble("rating_avg");
|
||||
result.ratedTimes = jsonObject.getInt("rating_cnt");
|
||||
result.ratingCount = jsonObject.getInt("rating_cnt");
|
||||
return result;
|
||||
} catch (JSONException e) {
|
||||
Exception exception = new ParseException("Can't parse rate gallery", body);
|
||||
|
||||
@@ -734,7 +734,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
return;
|
||||
}
|
||||
|
||||
if (gd.isFavored || EhDB.containLocalFavorites(gd.gid)) {
|
||||
if (gd.isFavorited || EhDB.containLocalFavorites(gd.gid)) {
|
||||
mHeart.setVisibility(View.VISIBLE);
|
||||
mHeartOutline.setVisibility(View.GONE);
|
||||
} else {
|
||||
@@ -769,9 +769,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
R.plurals.page_count, gd.pages, gd.pages));
|
||||
mSize.setText(gd.size);
|
||||
mPosted.setText(gd.posted);
|
||||
mFavoredTimes.setText(resources.getString(R.string.favored_times, gd.favoredTimes));
|
||||
mFavoredTimes.setText(resources.getString(R.string.favored_times, gd.favoriteCount));
|
||||
|
||||
mRatingText.setText(getAllRatingText(gd.rating, gd.ratedTimes));
|
||||
mRatingText.setText(getAllRatingText(gd.rating, gd.ratingCount));
|
||||
mRating.setRating(gd.rating);
|
||||
|
||||
updateFavoriteDrawable();
|
||||
@@ -936,10 +936,10 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
private String getAllRatingText(float rating, int ratedTimes) {
|
||||
private String getAllRatingText(float rating, int ratingCount) {
|
||||
Resources resources = getResources2();
|
||||
AssertUtils.assertNotNull(resources);
|
||||
return resources.getString(R.string.rating_text, getRatingText(rating, resources), rating, ratedTimes);
|
||||
return resources.getString(R.string.rating_text, getRatingText(rating, resources), rating, ratingCount);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@@ -1093,7 +1093,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
EhDB.removeLocalFavorites(mGalleryDetail.gid);
|
||||
remove = true;
|
||||
}
|
||||
if (mGalleryDetail.isFavored) {
|
||||
if (mGalleryDetail.isFavorited) {
|
||||
mModifingFavorites = true;
|
||||
CommonOperations.removeFromFavorites(activity, mGalleryDetail,
|
||||
new ModifyFavoritesListener(context,
|
||||
@@ -1425,12 +1425,12 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private void onRateGallerySuccess(RateGalleryParser.Result result) {
|
||||
if (mGalleryDetail != null) {
|
||||
mGalleryDetail.rating = result.rating;
|
||||
mGalleryDetail.ratedTimes = result.ratedTimes;
|
||||
mGalleryDetail.ratingCount = result.ratingCount;
|
||||
}
|
||||
|
||||
// Update UI
|
||||
if (mRatingText != null && mRating != null) {
|
||||
mRatingText.setText(getAllRatingText(result.rating, result.ratedTimes));
|
||||
mRatingText.setText(getAllRatingText(result.rating, result.ratingCount));
|
||||
mRating.setRating(result.rating);
|
||||
}
|
||||
}
|
||||
@@ -1438,7 +1438,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private void onModifyFavoritesSuccess(boolean addOrRemove) {
|
||||
mModifingFavorites = false;
|
||||
if (mGalleryDetail != null) {
|
||||
mGalleryDetail.isFavored = !addOrRemove;
|
||||
mGalleryDetail.isFavorited = !addOrRemove;
|
||||
updateFavoriteDrawable();
|
||||
}
|
||||
}
|
||||
@@ -1703,7 +1703,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
GalleryDetail gd = EhApplication.getGalleryDetailCache(getApplication()).get(mGid);
|
||||
if (gd != null) {
|
||||
gd.rating = result.rating;
|
||||
gd.ratedTimes = result.ratedTimes;
|
||||
gd.ratingCount = result.ratingCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
mValues.add(gd.size);
|
||||
mKeys.add(resources.getString(R.string.key_resize));
|
||||
mValues.add(gd.resize);
|
||||
mKeys.add(resources.getString(R.string.key_favorites));
|
||||
mValues.add(Integer.toString(gd.favoredTimes));
|
||||
mKeys.add(resources.getString(R.string.key_favorite_count));
|
||||
mValues.add(Integer.toString(gd.favoriteCount));
|
||||
mKeys.add(resources.getString(R.string.key_favorited));
|
||||
mValues.add(Boolean.toString(gd.isFavored));
|
||||
mKeys.add(resources.getString(R.string.key_rates));
|
||||
mValues.add(Integer.toString(gd.ratedTimes));
|
||||
mValues.add(Boolean.toString(gd.isFavorited));
|
||||
mKeys.add(resources.getString(R.string.key_rating_count));
|
||||
mValues.add(Integer.toString(gd.ratingCount));
|
||||
mKeys.add(resources.getString(R.string.key_rating));
|
||||
mValues.add(Float.toString(gd.rating));
|
||||
mKeys.add(resources.getString(R.string.key_torrents));
|
||||
|
||||
Reference in new issue
Block a user