Skip to content

Commit

Permalink
Close seven332#659, fix parsing gallery parent
Browse files Browse the repository at this point in the history
  • Loading branch information
seven332 committed Jul 29, 2019
1 parent 8a7adbe commit 47c9d48
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ private static void parseDetailInfo(GalleryDetail gd, Element e, String body) {
if (key.startsWith("Posted")) {
gd.posted = value;
} else if (key.startsWith("Parent")) {
gd.parent = value;
Element a = es.get(1).children().first();
if (a != null) {
gd.parent = a.attr("href");
}
} else if (key.startsWith("Visible")) {
gd.visible = value;
} else if (key.startsWith("Language")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
import com.hippo.ehviewer.UrlOpener;
import com.hippo.ehviewer.client.EhUrl;
import com.hippo.ehviewer.client.EhUtils;
import com.hippo.ehviewer.client.data.GalleryDetail;
Expand All @@ -51,6 +52,9 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
public static final String KEY_KEYS = "keys";
public static final String KEY_VALUES = "values";

private static final int INDEX_URL = 3;
private static final int INDEX_PARENT = 10;

/*---------------
Whole life cycle
---------------*/
Expand Down Expand Up @@ -199,15 +203,19 @@ public void onDestroyView() {
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
Context context = getContext2();
if (null != context && 0 != position && null != mValues) {
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setPrimaryClip(ClipData.newPlainText(null, mValues.get(position)));
if (position == INDEX_PARENT) {
UrlOpener.openUrl(context, mValues.get(position), true);
} else {
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
cmb.setPrimaryClip(ClipData.newPlainText(null, mValues.get(position)));

if (position == 3) {
// Save it to avoid detect the gallery
Settings.putClipboardTextHashCode(mValues.get(position).hashCode());
}
if (position == INDEX_URL) {
// Save it to avoid detect the gallery
Settings.putClipboardTextHashCode(mValues.get(position).hashCode());
}

showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
}
return true;
} else {
return false;
Expand Down

0 comments on commit 47c9d48

Please sign in to comment.