Improve GallerySpider

This commit is contained in:
seven332 committed 2015-07-21 10:33:04 +08:00
1 parent ec7e3948d9
commit 702376979a
32 files changed
+2181 -528

No files matched your search

@@ -257,7 +257,7 @@ public final class EhClient {
mEhHttpRequest = null;
mListener = null;
} else if (status == Status.FINISHED) {
mEhHttpRequest.cancel();
mEhHttpRequest.disconnect();
}
}
}
@@ -53,7 +53,7 @@ class EhEngine {
String body = response.getString();
return SignInParser.parse(body);
} catch (Exception e) {
if (httpRequest.isCanceled()) {
if (httpRequest.getState() == HttpRequest.STATE_DISCONNECT) {
throw new CanceledException();
} else {
throw e;
@@ -71,7 +71,7 @@ class EhEngine {
String body = response.getString();
return GalleryListParser.parse(body, source);
} catch (Exception e) {
if (httpRequest.isCanceled()) {
if (httpRequest.getState() == HttpRequest.STATE_DISCONNECT) {
throw new CanceledException();
} else {
throw e;
@@ -93,7 +93,7 @@ class EhEngine {
String body = response.getString();
return PopularParser.parse(body);
} catch (Exception e) {
if (httpRequest.isCanceled()) {
if (httpRequest.getState() == HttpRequest.STATE_DISCONNECT) {
throw new CanceledException();
} else {
throw e;
@@ -116,7 +116,7 @@ class EhEngine {
GalleryDetailParser.REQUEST_PREVIEW |
GalleryDetailParser.REQUEST_COMMENT);
} catch (Exception e) {
if (httpRequest.isCanceled()) {
if (httpRequest.getState() == HttpRequest.STATE_DISCONNECT) {
throw new CanceledException();
} else {
throw e;
@@ -134,7 +134,7 @@ class EhEngine {
String body = response.getString();
return GalleryDetailParser.parsePreview(body, source);
} catch (Exception e) {
if (httpRequest.isCanceled()) {
if (httpRequest.getState() == HttpRequest.STATE_DISCONNECT) {
throw new CanceledException();
} else {
throw e;
@@ -174,7 +174,7 @@ class EhEngine {
return list;
} catch (Exception e) {
if (httpRequest.isCanceled()) {
if (httpRequest.getState() == HttpRequest.STATE_DISCONNECT) {
throw new CanceledException();
} else {
throw e;
@@ -20,6 +20,7 @@ import com.hippo.ehviewer.client.data.GalleryApiDetail;
import com.hippo.ehviewer.client.data.GalleryBase;
import com.hippo.ehviewer.util.EhUtils;
import com.hippo.yorozuya.FileUtils;
import com.hippo.yorozuya.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
@@ -42,10 +43,10 @@ public class GalleryApiParser {
gad.gid = g.getInt("gid");
gad.token = g.getString("token");
gad.archiverKey = g.getString("archiver_key");
gad.title = g.getString("title");
gad.titleJpn = g.getString("title_jpn");
gad.title = StringUtils.unescapeXml(g.getString("title"));
gad.titleJpn = StringUtils.unescapeXml(g.getString("title_jpn"));
gad.category = EhUtils.getCategory(g.getString("category"));
gad.thumb = g.getString("thumb");
gad.thumb = StringUtils.unescapeXml(g.getString("thumb"));
gad.uploader = g.getString("uploader");
gad.posted = GalleryBase.DEFAULT_DATE_FORMAT.format(new Date(Long.parseLong(g.getString("posted")) * 1000));
gad.pageCount = Integer.parseInt(g.getString("filecount"));
@@ -16,13 +16,16 @@
package com.hippo.ehviewer.client.data;
import android.os.Parcel;
import android.os.Parcelable;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;
import java.util.regex.Pattern;
public class GalleryBase {
public class GalleryBase implements Parcelable {
public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
@@ -108,4 +111,52 @@ public class GalleryBase {
}
simpleLanguage = null;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.gid);
dest.writeString(this.token);
dest.writeString(this.title);
dest.writeString(this.titleJpn);
dest.writeString(this.thumb);
dest.writeInt(this.category);
dest.writeString(this.posted);
dest.writeString(this.uploader);
dest.writeFloat(this.rating);
dest.writeString(this.simpleLanguage);
}
public GalleryBase() {
}
protected GalleryBase(Parcel in) {
this.gid = in.readInt();
this.token = in.readString();
this.title = in.readString();
this.titleJpn = in.readString();
this.thumb = in.readString();
this.category = in.readInt();
this.posted = in.readString();
this.uploader = in.readString();
this.rating = in.readFloat();
this.simpleLanguage = in.readString();
}
public static final Parcelable.Creator<GalleryBase> CREATOR = new Parcelable.Creator<GalleryBase>() {
@Override
public GalleryBase createFromParcel(Parcel source) {
return new GalleryBase(source);
}
@Override
public GalleryBase[] newArray(int size) {
return new GalleryBase[size];
}
};
}