Add share gallery

This commit is contained in:
seven332 committed 2016-02-05 02:22:00 +08:00
1 parent dfbe3767fe
commit 2400fa3dff
3 files changed
+21 -12

No files matched your search

@@ -16,6 +16,8 @@
package com.hippo.ehviewer.client;
import com.hippo.network.UrlBuilder;
public class EhUrl {
public static final String DOMAIN_EX = "exhentai.org";
@@ -30,16 +32,17 @@ public class EhUrl {
public static final String API_EX = HOST_EX + "api.php";
public static String getGalleryDetailUrl(int gid, String token) {
return getGalleryDetailUrl(gid, token, 0);
return getGalleryDetailUrl(gid, token, 0, false);
}
public static String getGalleryDetailUrl(int gid, String token, int index) {
StringBuilder sb = new StringBuilder(HOST_EX);
// TODO set hc 1 or 0
sb.append("g/").append(gid).append('/').append(token).append("/?hc=1");
public static String getGalleryDetailUrl(int gid, String token, int index, boolean allComment) {
UrlBuilder builder = new UrlBuilder(HOST_EX + "g/" + gid + '/' + token + '/');
if (index != 0) {
sb.append("&p=").append(index);
builder.addQuery("p", index);
}
return sb.toString();
if (allComment) {
builder.addQuery("hc", 1);
}
return builder.build();
}
}
@@ -63,6 +63,7 @@ import com.hippo.scene.StageActivity;
import com.hippo.scene.TransitionHelper;
import com.hippo.text.Html;
import com.hippo.text.URLImageGetter;
import com.hippo.util.ActivityHelper;
import com.hippo.util.ApiHelper;
import com.hippo.util.ExceptionUtils;
import com.hippo.util.ReadableTime;
@@ -188,7 +189,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
}
@Nullable
private String getGalleryDetailUrl() {
private String getGalleryDetailUrl(boolean allComment) {
int gid;
String token;
if (mGalleryDetail != null) {
@@ -203,7 +204,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
} else {
return null;
}
return EhUrl.getGalleryDetailUrl(gid, token);
return EhUrl.getGalleryDetailUrl(gid, token, 0, allComment);
}
// -1 for error
@@ -483,7 +484,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
}
private boolean request() {
String url = getGalleryDetailUrl();
String url = getGalleryDetailUrl(true);
if (url == null) {
return false;
}
@@ -804,7 +805,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_open_in_other_app:
String url = getGalleryDetailUrl();
String url = getGalleryDetailUrl(false);
if (url != null) {
OpenUrlHelper.openUrl(getActivity(), url, false, false);
}
@@ -845,6 +846,11 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
Bundle args = new Bundle();
args.putParcelable(GalleryInfoScene.KEY_GALLERY_DETAIL, mGalleryDetail);
startScene(GalleryInfoScene.class, args);
} else if (mShare == v) {
String url = getGalleryDetailUrl(false);
if (url != null) {
ActivityHelper.share(getActivity(), url);
}
} else if (mRate == v) {
if (mGalleryDetail == null) {
return;
@@ -232,7 +232,7 @@ public class GalleryPreviewsScene extends ToolbarScene {
return;
}
String url = EhUrl.getGalleryDetailUrl(mGid, mToken, page);
String url = EhUrl.getGalleryDetailUrl(mGid, mToken, page, false);
EhRequest request = new EhRequest();
request.setMethod(EhClient.METHOD_GET_LARGE_PREVIEW_SET);
request.setCallback(new GetLargePreviewSetListener(getContext(),