mirror of
https://github.com/seven332/EhViewer
synced 2026-11-30 11:08:04 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
727eb73721 | ||
|
|
42f5e6ae4e | ||
|
|
7515303e87 | ||
|
|
281af4140a | ||
|
|
4fa6a1f544 | ||
|
|
53f8cc4488 | ||
|
|
0f980a5cee | ||
|
|
6e06cca962 | ||
|
|
ba884f8c99 | ||
|
|
44c2d25218 | ||
|
|
cd33a557cd | ||
|
|
2c4daa447e | ||
|
|
6659fefc21 | ||
|
|
48face0e9e | ||
|
|
fe16ccd8b9 | ||
|
|
99fedf4e3c | ||
|
|
7924b53d00 |
No files matched your search
+5
-5
@@ -10,8 +10,8 @@ android {
|
||||
applicationId "com.hippo.ehviewer"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 23
|
||||
versionCode 50
|
||||
versionName "0.9.2"
|
||||
versionCode 51
|
||||
versionName "0.9.3"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ dependencies {
|
||||
compile project(':yorozuya')
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.2.0'
|
||||
compile 'com.android.support:customtabs:23.2.0'
|
||||
compile 'com.android.support:design:23.2.0'
|
||||
compile 'com.android.support:appcompat-v7:23.2.1'
|
||||
compile 'com.android.support:customtabs:23.2.1'
|
||||
compile 'com.android.support:design:23.2.1'
|
||||
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
|
||||
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.8.6'
|
||||
compile 'de.greenrobot:greendao:2.0.0'
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2016 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.drawable;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.graphics.drawable.DrawableWrapper;
|
||||
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
|
||||
public class PreciselyClipDrawable extends DrawableWrapper {
|
||||
|
||||
private final boolean mClip;
|
||||
private RectF mScale;
|
||||
private Rect mTemp;
|
||||
|
||||
public PreciselyClipDrawable(Drawable drawable, int offsetX, int offsetY, int width, int height) {
|
||||
super(drawable);
|
||||
float originWidth = drawable.getIntrinsicWidth();
|
||||
float originHeight = drawable.getIntrinsicHeight();
|
||||
|
||||
if (originWidth <= 0 || originHeight <= 0) {
|
||||
// Can not clip
|
||||
mClip = false;
|
||||
} else {
|
||||
mClip = true;
|
||||
mScale = new RectF();
|
||||
mScale.set(MathUtils.clamp(offsetX / originWidth, 0.0f, 1.0f),
|
||||
MathUtils.clamp(offsetY / originHeight, 0.0f, 1.0f),
|
||||
MathUtils.clamp((offsetX + width) / originWidth, 0.0f, 1.0f),
|
||||
MathUtils.clamp((offsetY + height) / originHeight, 0.0f, 1.0f));
|
||||
mTemp = new Rect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
if (mClip) {
|
||||
if (!mScale.isEmpty()) {
|
||||
mTemp.left = (int) ((mScale.left * bounds.right - mScale.right * bounds.left) /
|
||||
(mScale.left * (1 - mScale.right) - mScale.right * (1 - mScale.left)));
|
||||
mTemp.right = (int) (((1 - mScale.right) * bounds.left - (1 - mScale.left) * bounds.right) /
|
||||
(mScale.left * (1 - mScale.right) - mScale.right * (1 - mScale.left)));
|
||||
mTemp.top = (int) ((mScale.top * bounds.bottom - mScale.bottom * bounds.top) /
|
||||
(mScale.top * (1 - mScale.bottom) - mScale.bottom * (1 - mScale.top)));
|
||||
mTemp.bottom = (int) (((1 - mScale.bottom) * bounds.top - (1 - mScale.top) * bounds.bottom) /
|
||||
(mScale.top * (1 - mScale.bottom) - mScale.bottom * (1 - mScale.top)));
|
||||
super.onBoundsChange(mTemp);
|
||||
}
|
||||
} else {
|
||||
super.onBoundsChange(bounds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
if (mClip) {
|
||||
return (int) (super.getIntrinsicWidth() * mScale.width());
|
||||
} else {
|
||||
return super.getIntrinsicWidth();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
if (mClip) {
|
||||
return (int) (super.getIntrinsicHeight() * mScale.height());
|
||||
} else {
|
||||
return super.getIntrinsicHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (mClip) {
|
||||
if (!mScale.isEmpty()) {
|
||||
int saveCount = canvas.save();
|
||||
canvas.clipRect(getBounds());
|
||||
super.draw(canvas);
|
||||
canvas.restoreToCount(saveCount);
|
||||
}
|
||||
} else {
|
||||
super.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,6 @@ import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhCookieStore;
|
||||
import com.hippo.ehviewer.client.EhEngine;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.spider.SpiderDen;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
@@ -75,8 +74,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
private BitmapHelper mBitmapHelper;
|
||||
private Conaco<Bitmap> mConaco;
|
||||
private LruCache<Long, GalleryDetail> mGalleryDetailCache;
|
||||
private LruCache<String, LargePreviewSet> mLargePreviewSetCache;
|
||||
private LruCache<Long, Integer> mPreviewPagesCache;
|
||||
private SimpleDiskCache mSpiderInfoCache;
|
||||
private DownloadManager mDownloadManager;
|
||||
|
||||
@@ -131,12 +128,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
if (null != mGalleryDetailCache) {
|
||||
mGalleryDetailCache.evictAll();
|
||||
}
|
||||
if (null != mLargePreviewSetCache) {
|
||||
mLargePreviewSetCache.evictAll();
|
||||
}
|
||||
if (null != mPreviewPagesCache) {
|
||||
mPreviewPagesCache.evictAll();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -269,26 +260,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
|
||||
return application.mGalleryDetailCache;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static LruCache<String, LargePreviewSet> getLargePreviewSetCache(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
if (application.mLargePreviewSetCache == null) {
|
||||
// Max size 50, 3 min timeout
|
||||
application.mLargePreviewSetCache = new LruCache<>(50);
|
||||
}
|
||||
return application.mLargePreviewSetCache;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static LruCache<Long, Integer> getPreviewPagesCache(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
if (application.mPreviewPagesCache == null) {
|
||||
// Max size 50, 3 min timeout
|
||||
application.mPreviewPagesCache = new LruCache<>(50);
|
||||
}
|
||||
return application.mPreviewPagesCache;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static SimpleDiskCache getSpiderInfoCache(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
|
||||
@@ -26,8 +26,8 @@ import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.client.EhConfig;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.gallery.gl.GalleryView;
|
||||
import com.hippo.ehviewer.gallery.gl.ImageView;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
@@ -261,7 +261,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static final String KEY_DEFAULT_CATEGORIES = "default_categories";
|
||||
public static final int DEFAULT_DEFAULT_CATEGORIES = ListUrlBuilder.ALL_CATEGORT;
|
||||
public static final int DEFAULT_DEFAULT_CATEGORIES = EhUtils.ALL_CATEGORY;
|
||||
|
||||
public static int getDefaultCategories() {
|
||||
return getInt(KEY_DEFAULT_CATEGORIES, DEFAULT_DEFAULT_CATEGORIES);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class EhClient {
|
||||
public static final int METHOD_GET_GALLERY_LIST = 1;
|
||||
public static final int METHOD_FILL_GALLERY_LIST_BY_API = 2;
|
||||
public static final int METHOD_GET_GALLERY_DETAIL = 3;
|
||||
public static final int METHOD_GET_LARGE_PREVIEW_SET = 4;
|
||||
public static final int METHOD_GET_PREVIEW_SET = 4;
|
||||
public static final int METHOD_GET_RATE_GALLERY = 5;
|
||||
public static final int METHOD_GET_COMMENT_GALLERY = 6;
|
||||
public static final int METHOD_GET_GALLERY_TOKEN = 7;
|
||||
@@ -155,8 +155,8 @@ public class EhClient {
|
||||
return EhEngine.fillGalleryListByApi(this, mOkHttpClient, (List<GalleryInfo>) params[0]);
|
||||
case METHOD_GET_GALLERY_DETAIL:
|
||||
return EhEngine.getGalleryDetail(this, mOkHttpClient, (String) params[0]);
|
||||
case METHOD_GET_LARGE_PREVIEW_SET:
|
||||
return EhEngine.getLargePreviewSet(this, mOkHttpClient, (String) params[0]);
|
||||
case METHOD_GET_PREVIEW_SET:
|
||||
return EhEngine.getPreviewSet(this, mOkHttpClient, (String) params[0]);
|
||||
case METHOD_GET_RATE_GALLERY:
|
||||
return EhEngine.rateGallery(this, mOkHttpClient, (Long) params[0], (String) params[1], (Float) params[2]);
|
||||
case METHOD_GET_COMMENT_GALLERY:
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
import com.hippo.ehviewer.client.data.PreviewSet;
|
||||
import com.hippo.ehviewer.client.exception.CancelledException;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
@@ -201,7 +201,7 @@ public class EhEngine {
|
||||
}
|
||||
|
||||
// Filter title and uploader
|
||||
List<GalleryInfo> list = result.galleryInfos;
|
||||
List<GalleryInfo> list = result.galleryInfoList;
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTitle(info) || !sEhFilter.filterUploader(info)) {
|
||||
@@ -309,7 +309,7 @@ public class EhEngine {
|
||||
}
|
||||
|
||||
|
||||
public static Pair<LargePreviewSet, Integer> getLargePreviewSet(
|
||||
public static Pair<PreviewSet, Integer> getPreviewSet(
|
||||
EhClient.Task task, OkHttpClient okHttpClient, String url) throws Exception {
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, task.getEhConfig()).build();
|
||||
@@ -326,9 +326,8 @@ public class EhEngine {
|
||||
code = response.code();
|
||||
headers = response.headers();
|
||||
body = response.body().string();
|
||||
Document document = Jsoup.parse(body);
|
||||
return Pair.create(GalleryDetailParser.parseLargePreviewSet(document, body),
|
||||
GalleryDetailParser.parsePreviewPages(document, body));
|
||||
return Pair.create(GalleryDetailParser.parsePreviewSet(body),
|
||||
GalleryDetailParser.parsePreviewPages(body));
|
||||
} catch (Exception e) {
|
||||
throwException(call, code, headers, body, e);
|
||||
throw e;
|
||||
|
||||
@@ -18,17 +18,23 @@ package com.hippo.ehviewer.client;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class EhUtils {
|
||||
|
||||
public static final int NONE = -1; // Use it for homepage
|
||||
public static final int UNKNOWN = 0x400;
|
||||
|
||||
public static final int ALL_CATEGORY = EhUtils.UNKNOWN - 1;
|
||||
//DOUJINSHI|MANGA|ARTIST_CG|GAME_CG|WESTERN|NON_H|IMAGE_SET|COSPLAY|ASIAN_PORN|MISC;
|
||||
|
||||
public static final int BG_COLOR_DOUJINSHI = 0xfff44336;
|
||||
public static final int BG_COLOR_MANGA = 0xffff9800;
|
||||
public static final int BG_COLOR_ARTIST_CG = 0xfffbc02d;
|
||||
@@ -41,6 +47,9 @@ public class EhUtils {
|
||||
public static final int BG_COLOR_MISC = 0xfff06292;
|
||||
public static final int BG_COLOR_UNKNOWN = Color.BLACK;
|
||||
|
||||
public static final Pattern PATTERN_TITLE_PREFIX = Pattern.compile("^(?:(?:\\([^\\)]*\\))|(?:\\[[^\\]]*\\])|(?:\\{[^\\}]*\\})|(?:~[^~]*~)|\\s+)*");
|
||||
public static final Pattern PATTERN_TITLE_SUFFIX = Pattern.compile("(?:(?:\\([^\\)]*\\))|(?:\\[[^\\]]*\\])|(?:\\{[^\\}]*\\})|(?:~[^~]*~)|\\s+)*$");
|
||||
|
||||
private static final int[] CATEGORY_VALUES = {
|
||||
EhConfig.MISC,
|
||||
EhConfig.DOUJINSHI,
|
||||
@@ -133,4 +142,18 @@ public class EhUtils {
|
||||
return TextUtils.isEmpty(gi.title) ? gi.titleJpn : gi.title;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String extractTitle(String title) {
|
||||
if (null == title) {
|
||||
return null;
|
||||
}
|
||||
title = PATTERN_TITLE_PREFIX.matcher(title).replaceFirst("");
|
||||
title = PATTERN_TITLE_SUFFIX.matcher(title).replaceFirst("");
|
||||
if (title.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return title;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,8 +37,7 @@ public class GalleryDetail extends GalleryInfo {
|
||||
public GalleryTagGroup[] tags;
|
||||
public GalleryComment[] comments;
|
||||
public int previewPages;
|
||||
public LargePreviewSet previewSet;
|
||||
|
||||
public PreviewSet previewSet;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
@@ -94,7 +93,7 @@ public class GalleryDetail extends GalleryInfo {
|
||||
this.comments = null;
|
||||
}
|
||||
this.previewPages = in.readInt();
|
||||
this.previewSet = in.readParcelable(LargePreviewSet.class.getClassLoader());
|
||||
this.previewSet = in.readParcelable(PreviewSet.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static final Creator<GalleryDetail> CREATOR = new Creator<GalleryDetail>() {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class GalleryInfo implements Parcelable {
|
||||
|
||||
public static final Pattern[] S_LANG_PATTERNS = {
|
||||
Pattern.compile("[(\\[]eng(?:lish)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[((\\[]chinese[))\\]]|[汉漢]化|中[国國][语語]|中文|[(\\[]CN[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[((\\[]ch(?:inese)?[))\\]]|[汉漢]化|中[国國][语語]|中文", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]spanish[)\\]]|[(\\[]Español[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]korean?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]rus(?:sian)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
|
||||
@@ -19,11 +19,27 @@ package com.hippo.ehviewer.client.data;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.hippo.widget.LoadImageView;
|
||||
|
||||
public class GalleryPreview implements Parcelable {
|
||||
|
||||
public String imageUrl;
|
||||
public String pageUrl;
|
||||
public int index;
|
||||
String imageKey;
|
||||
String imageUrl;
|
||||
String pageUrl;
|
||||
int position;
|
||||
int offsetX = Integer.MIN_VALUE;
|
||||
int offsetY = Integer.MIN_VALUE;
|
||||
int clipWidth = Integer.MIN_VALUE;
|
||||
int clipHeight = Integer.MIN_VALUE;
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void load(LoadImageView view) {
|
||||
view.setClip(offsetX, offsetY, clipWidth, clipHeight);
|
||||
view.load(imageKey, imageUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
@@ -34,7 +50,11 @@ public class GalleryPreview implements Parcelable {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(this.imageUrl);
|
||||
dest.writeString(this.pageUrl);
|
||||
dest.writeInt(this.index);
|
||||
dest.writeInt(this.position);
|
||||
dest.writeInt(this.offsetX);
|
||||
dest.writeInt(this.offsetY);
|
||||
dest.writeInt(this.clipWidth);
|
||||
dest.writeInt(this.clipHeight);
|
||||
}
|
||||
|
||||
public GalleryPreview() {
|
||||
@@ -43,14 +63,20 @@ public class GalleryPreview implements Parcelable {
|
||||
protected GalleryPreview(Parcel in) {
|
||||
this.imageUrl = in.readString();
|
||||
this.pageUrl = in.readString();
|
||||
this.index = in.readInt();
|
||||
this.position = in.readInt();
|
||||
this.offsetX = in.readInt();
|
||||
this.offsetY = in.readInt();
|
||||
this.clipWidth = in.readInt();
|
||||
this.clipHeight = in.readInt();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<GalleryPreview> CREATOR = new Parcelable.Creator<GalleryPreview>() {
|
||||
@Override
|
||||
public GalleryPreview createFromParcel(Parcel source) {
|
||||
return new GalleryPreview(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryPreview[] newArray(int size) {
|
||||
return new GalleryPreview[size];
|
||||
}
|
||||
|
||||
@@ -19,38 +19,56 @@ package com.hippo.ehviewer.client.data;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.yorozuya.IntList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LargePreviewSet implements Parcelable {
|
||||
public class LargePreviewSet extends PreviewSet {
|
||||
|
||||
private final IntList mIndexList;
|
||||
private final IntList mPositionList;
|
||||
private final ArrayList<String> mImageUrlList;
|
||||
private final ArrayList<String> mPageUrlList;
|
||||
|
||||
public int size() {
|
||||
return mImageUrlList.size();
|
||||
}
|
||||
|
||||
public void addItem(int index, String imageUrl, String pageUrl) {
|
||||
mIndexList.add(index);
|
||||
mPositionList.add(index);
|
||||
mImageUrlList.add(imageUrl);
|
||||
mPageUrlList.add(pageUrl);
|
||||
}
|
||||
|
||||
public int getIndexAt(int index) {
|
||||
return mIndexList.get(index);
|
||||
@Override
|
||||
public int size() {
|
||||
return mImageUrlList.size();
|
||||
}
|
||||
|
||||
public String getImageUrlAt(int index) {
|
||||
return mImageUrlList.get(index);
|
||||
@Override
|
||||
public int getPosition(int index) {
|
||||
return mPositionList.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPageUrlAt(int index) {
|
||||
return mPageUrlList.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryPreview getGalleryPreview(long gid, int index) {
|
||||
GalleryPreview galleryPreview = new GalleryPreview();
|
||||
galleryPreview.position = mPositionList.get(index);
|
||||
galleryPreview.imageKey = EhCacheKeyFactory.getLargePreviewKey(gid, galleryPreview.position);
|
||||
galleryPreview.imageUrl = mImageUrlList.get(index);
|
||||
galleryPreview.pageUrl = mPageUrlList.get(index);
|
||||
return galleryPreview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(LoadImageView view, long gid, int index) {
|
||||
view.resetClip();
|
||||
view.load(EhCacheKeyFactory.getLargePreviewKey(gid, mPositionList.get(index)),
|
||||
mImageUrlList.get(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
@@ -58,19 +76,19 @@ public class LargePreviewSet implements Parcelable {
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeParcelable(this.mIndexList, flags);
|
||||
dest.writeParcelable(this.mPositionList, flags);
|
||||
dest.writeStringList(this.mImageUrlList);
|
||||
dest.writeStringList(this.mPageUrlList);
|
||||
}
|
||||
|
||||
public LargePreviewSet() {
|
||||
mIndexList = new IntList();
|
||||
mPositionList = new IntList();
|
||||
mImageUrlList = new ArrayList<>();
|
||||
mPageUrlList = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected LargePreviewSet(Parcel in) {
|
||||
this.mIndexList = in.readParcelable(IntList.class.getClassLoader());
|
||||
this.mPositionList = in.readParcelable(IntList.class.getClassLoader());
|
||||
this.mImageUrlList = in.createStringArrayList();
|
||||
this.mPageUrlList = in.createStringArrayList();
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
public static final int MODE_WHATS_HOT = 0x3;
|
||||
public static final int MODE_IMAGE_SEARCH = 0x4;
|
||||
|
||||
public static final int ALL_CATEGORT = EhUtils.UNKNOWN - 1;
|
||||
//DOUJINSHI|MANGA|ARTIST_CG|GAME_CG|WESTERN|NON_H|IMAGE_SET|COSPLAY|ASIAN_PORN|MISC;
|
||||
|
||||
public static final int DEFAULT_ADVANCE = AdvanceSearchTable.SNAME | AdvanceSearchTable.STAGS;
|
||||
public static final int DEFAULT_MIN_RATING = 2;
|
||||
|
||||
@@ -166,6 +163,30 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
return q;
|
||||
}
|
||||
|
||||
public boolean equalsQuickSearch(QuickSearch q) {
|
||||
if (null == q) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (q.mode != mMode) {
|
||||
return false;
|
||||
}
|
||||
if (q.category != mCategory) {
|
||||
return false;
|
||||
}
|
||||
if (!StringUtils.equals(q.keyword, mKeyword)) {
|
||||
return false;
|
||||
}
|
||||
if (q.advanceSearch != mAdvanceSearch) {
|
||||
return false;
|
||||
}
|
||||
if (q.minRating != mMinRating) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query xxx=yyy&mmm=nnn
|
||||
*/
|
||||
|
||||
@@ -16,40 +16,121 @@
|
||||
|
||||
package com.hippo.ehviewer.client.data;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.yorozuya.IntList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class NormalPreviewSet {
|
||||
public class NormalPreviewSet extends PreviewSet {
|
||||
|
||||
private final IntList mIndexList = new IntList();
|
||||
private final ArrayList<String> mImageUrlList = new ArrayList<>();
|
||||
private final IntList mXOffsetList = new IntList();
|
||||
private final IntList mYOffsetList = new IntList();
|
||||
private final IntList mWidthList = new IntList();
|
||||
private final IntList mHeightList = new IntList();
|
||||
private final ArrayList<String> mPageUrlList = new ArrayList<>();
|
||||
private IntList mPositionList = new IntList();
|
||||
private ArrayList<String> mImageKeyList = new ArrayList<>();
|
||||
private ArrayList<String> mImageUrlList = new ArrayList<>();
|
||||
private IntList mOffsetXList = new IntList();
|
||||
private IntList mOffsetYList = new IntList();
|
||||
private IntList mClipWidthList = new IntList();
|
||||
private IntList mClipHeightList = new IntList();
|
||||
private ArrayList<String> mPageUrlList = new ArrayList<>();
|
||||
|
||||
public void addItem(int index, String imageUrl, int xOffset, int yOffset, int width,
|
||||
private String getImageKey(String imageUrl) {
|
||||
int index = imageUrl.indexOf('/');
|
||||
if (index >= 0) {
|
||||
return imageUrl.substring(index + 1);
|
||||
} else {
|
||||
return imageUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(int position, String imageUrl, int xOffset, int yOffset, int width,
|
||||
int height, String pageUrl) {
|
||||
mIndexList.add(index);
|
||||
mPositionList.add(position);
|
||||
mImageKeyList.add(getImageKey(imageUrl));
|
||||
mImageUrlList.add(imageUrl);
|
||||
mXOffsetList.add(xOffset);
|
||||
mYOffsetList.add(yOffset);
|
||||
mWidthList.add(width);
|
||||
mHeightList.add(height);
|
||||
mOffsetXList.add(xOffset);
|
||||
mOffsetYList.add(yOffset);
|
||||
mClipWidthList.add(width);
|
||||
mClipHeightList.add(height);
|
||||
mPageUrlList.add(pageUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mIndexList.size();
|
||||
return mPositionList.size();
|
||||
}
|
||||
|
||||
public int getIndexAt(int index) {
|
||||
return mIndexList.get(index);
|
||||
@Override
|
||||
public int getPosition(int index) {
|
||||
return mPositionList.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPageUrlAt(int index) {
|
||||
return mPageUrlList.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryPreview getGalleryPreview(long gid, int index) {
|
||||
GalleryPreview galleryPreview = new GalleryPreview();
|
||||
galleryPreview.position = mPositionList.get(index);
|
||||
galleryPreview.imageKey = mImageKeyList.get(index);
|
||||
galleryPreview.imageUrl = mImageUrlList.get(index);
|
||||
galleryPreview.pageUrl = mPageUrlList.get(index);
|
||||
galleryPreview.offsetX = mOffsetXList.get(index);
|
||||
galleryPreview.offsetY = mOffsetYList.get(index);
|
||||
galleryPreview.clipWidth = mClipWidthList.get(index);
|
||||
galleryPreview.clipHeight = mClipHeightList.get(index);
|
||||
return galleryPreview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(LoadImageView view, long gid, int index) {
|
||||
view.setClip(mOffsetXList.get(index), mOffsetYList.get(index),
|
||||
mClipWidthList.get(index), mClipHeightList.get(index));
|
||||
view.load(mImageKeyList.get(index), mImageUrlList.get(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeParcelable(this.mPositionList, flags);
|
||||
dest.writeStringList(this.mImageKeyList);
|
||||
dest.writeStringList(this.mImageUrlList);
|
||||
dest.writeParcelable(this.mOffsetXList, flags);
|
||||
dest.writeParcelable(this.mOffsetYList, flags);
|
||||
dest.writeParcelable(this.mClipWidthList, flags);
|
||||
dest.writeParcelable(this.mClipHeightList, flags);
|
||||
dest.writeStringList(this.mPageUrlList);
|
||||
}
|
||||
|
||||
public NormalPreviewSet() {
|
||||
}
|
||||
|
||||
protected NormalPreviewSet(Parcel in) {
|
||||
this.mPositionList = in.readParcelable(IntList.class.getClassLoader());
|
||||
this.mImageKeyList = in.createStringArrayList();
|
||||
this.mImageUrlList = in.createStringArrayList();
|
||||
this.mOffsetXList = in.readParcelable(IntList.class.getClassLoader());
|
||||
this.mOffsetYList = in.readParcelable(IntList.class.getClassLoader());
|
||||
this.mClipWidthList = in.readParcelable(IntList.class.getClassLoader());
|
||||
this.mClipHeightList = in.readParcelable(IntList.class.getClassLoader());
|
||||
this.mPageUrlList = in.createStringArrayList();
|
||||
}
|
||||
|
||||
public static final Creator<NormalPreviewSet> CREATOR = new Creator<NormalPreviewSet>() {
|
||||
@Override
|
||||
public NormalPreviewSet createFromParcel(Parcel source) {
|
||||
return new NormalPreviewSet(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NormalPreviewSet[] newArray(int size) {
|
||||
return new NormalPreviewSet[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2016 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.client.data;
|
||||
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.hippo.widget.LoadImageView;
|
||||
|
||||
public abstract class PreviewSet implements Parcelable {
|
||||
|
||||
public abstract int size();
|
||||
|
||||
public abstract int getPosition(int index);
|
||||
|
||||
public abstract String getPageUrlAt(int index);
|
||||
|
||||
public abstract GalleryPreview getGalleryPreview(long gid, int index);
|
||||
|
||||
public abstract void load(LoadImageView view, long gid, int index);
|
||||
}
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import com.hippo.ehviewer.GetText;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.util.JsoupUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
@@ -45,6 +48,9 @@ public class FavoritesParser {
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static Result parse(String body) throws Exception {
|
||||
if (body.contains("This page requires you to log on.</p>")) {
|
||||
throw new EhException(GetText.getString(R.string.need_sign_in));
|
||||
}
|
||||
String[] catArray = new String[10];
|
||||
int[] countArray = new int[10];
|
||||
int current;
|
||||
@@ -84,7 +90,7 @@ public class FavoritesParser {
|
||||
re.current = current;
|
||||
re.limit = limit;
|
||||
re.pages = result.pages;
|
||||
re.galleryInfoList = result.galleryInfos;
|
||||
re.galleryInfoList = result.galleryInfoList;
|
||||
|
||||
return re;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
import com.hippo.ehviewer.client.data.NormalPreviewSet;
|
||||
import com.hippo.ehviewer.client.data.PreviewSet;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.ehviewer.client.exception.OffensiveException;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
@@ -129,7 +130,7 @@ public class GalleryDetailParser {
|
||||
galleryDetail.tags = parseTagGroups(document);
|
||||
galleryDetail.comments = parseComments(document);
|
||||
galleryDetail.previewPages = parsePreviewPages(document, body);
|
||||
galleryDetail.previewSet = parseLargePreviewSet(document, body);
|
||||
galleryDetail.previewSet = parsePreviewSet(body);
|
||||
return galleryDetail;
|
||||
}
|
||||
|
||||
@@ -377,10 +378,18 @@ public class GalleryDetailParser {
|
||||
}
|
||||
}
|
||||
|
||||
public static PreviewSet parsePreviewSet(String body) throws ParseException {
|
||||
try {
|
||||
return parseLargePreviewSet(body);
|
||||
} catch (ParseException e) {
|
||||
return parseNormalPreviewSet(body);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse large previews with regular expressions
|
||||
*/
|
||||
public static LargePreviewSet parseLargePreviewSet(Document document, String body) throws ParseException {
|
||||
private static LargePreviewSet parseLargePreviewSet(Document document, String body) throws ParseException {
|
||||
try {
|
||||
LargePreviewSet largePreviewSet = new LargePreviewSet();
|
||||
Element gdt = document.getElementById("gdt");
|
||||
@@ -407,7 +416,7 @@ public class GalleryDetailParser {
|
||||
/**
|
||||
* Parse large previews with regular expressions
|
||||
*/
|
||||
public static LargePreviewSet parseLargePreviewSet(String body) throws ParseException {
|
||||
private static LargePreviewSet parseLargePreviewSet(String body) throws ParseException {
|
||||
Matcher m = LARGE_PREVIEW_PATTERN.matcher(body);
|
||||
LargePreviewSet largePreviewSet = new LargePreviewSet();
|
||||
|
||||
@@ -426,7 +435,7 @@ public class GalleryDetailParser {
|
||||
/**
|
||||
* Parse normal previews with regular expressions
|
||||
*/
|
||||
public static NormalPreviewSet parseNormalPreviewSet(String body) throws ParseException {
|
||||
private static NormalPreviewSet parseNormalPreviewSet(String body) throws ParseException {
|
||||
Matcher m = NORMAL_PREVIEW_PATTERN.matcher(body);
|
||||
NormalPreviewSet normalPreviewSet = new NormalPreviewSet();
|
||||
while (m.find()) {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
@@ -30,6 +32,7 @@ public final class GalleryDetailUrlParser {
|
||||
public static final Pattern URL_PATTERN = Pattern.compile("http://(?:" +
|
||||
EhUrl.DOMAIN_EX + "|" + EhUrl.DOMAIN_G + "|" + EhUrl.DOMAIN_LOFI + ")/g/(\\d+)/(\\w+)");
|
||||
|
||||
@Nullable
|
||||
public static Result parse(String url) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
|
||||
@@ -17,11 +17,20 @@
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.util.JsoupUtils;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -31,90 +40,27 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class GalleryListParser {
|
||||
|
||||
static final Pattern PAGES_PATTERN = Pattern.compile("<a[^<>]+>([\\d]+)</a></td><td[^<>]+>(?:<a[^<>]+>)?&");
|
||||
static final Pattern PATTERN = Pattern.compile(
|
||||
"<td class=\"itdc\">(?:<a.+?>)?<img.+?alt=\"(.+?)\".+?/>(?:</a>)?</td>" // category
|
||||
+ "<td.+?>(.+?)</td>" // posted
|
||||
+ "<td.+?><div.+?><div.+?height:(\\d+)px; width:(\\d+)px\">"
|
||||
+ "(?:<img.+?src=\"(.+?)\".+?alt=\"(.+?)\" style.+?/>"
|
||||
+ "|init~([^<>\"~]+~[^<>\"~]+)~([^<>]+))" // thumb and title
|
||||
+ "</div>"
|
||||
+ ".+?"
|
||||
+ "<div class=\"it5\"><a href=\"([^<>\"]+)\"[^<>]+>(.+?)</a></div>" // url and title
|
||||
+ ".+?"
|
||||
+ "<div class=\"ir it4r\" style=\"([^<>\"]+)\">" // rating
|
||||
+ ".+?"
|
||||
+ "<td class=\"itu\"><div><a.+?>(.+?)</a>"); // uploader
|
||||
static final Pattern RATING_PATTERN = Pattern.compile("\\d+px");
|
||||
private static final String TAG = GalleryListParser.class.getSimpleName();
|
||||
|
||||
private static final Pattern PATTERN_RATING = Pattern.compile("\\d+px");
|
||||
private static final Pattern PATTERN_THUMB_SIZE = Pattern.compile("height:(\\d+)px; width:(\\d+)px");
|
||||
|
||||
public static class Result {
|
||||
public int pages;
|
||||
public List<GalleryInfo> galleryInfos;
|
||||
public List<GalleryInfo> galleryInfoList;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Result parse(@NonNull String body) throws Exception {
|
||||
Result result = new Result();
|
||||
Matcher m;
|
||||
|
||||
// pages
|
||||
m = PAGES_PATTERN.matcher(body);
|
||||
if (m.find()) {
|
||||
result.pages = ParserUtils.parseInt(m.group(1));
|
||||
} else if (body.contains("No hits found</p>")) {
|
||||
result.pages = 0;
|
||||
result.galleryInfos = Collections.EMPTY_LIST;
|
||||
} else {
|
||||
// Can not get page number
|
||||
throw new ParseException("Can't parse gallery list", body);
|
||||
private static int parsePages(Document d, String body) throws ParseException {
|
||||
try {
|
||||
Elements es = d.getElementsByClass("ptt").first().child(0).child(0).children();
|
||||
return Integer.parseInt(es.get(es.size() - 2).text().trim());
|
||||
} catch (Exception e) {
|
||||
throw new ParseException("Can't parse gallery list pages", body);
|
||||
}
|
||||
|
||||
if (result.pages > 0) {
|
||||
List<GalleryInfo> list = new ArrayList<>(25);
|
||||
result.galleryInfos = list;
|
||||
|
||||
m = PATTERN.matcher(body);
|
||||
while (m.find()) {
|
||||
GalleryInfo gi = new GalleryInfo();
|
||||
|
||||
gi.category = EhUtils.getCategory(ParserUtils.trim(m.group(1)));
|
||||
gi.posted = ParserUtils.trim(m.group(2));
|
||||
gi.thumbHeight = ParserUtils.parseInt(m.group(3));
|
||||
gi.thumbWidth = ParserUtils.parseInt(m.group(4));
|
||||
|
||||
if (m.group(5) == null) {
|
||||
gi.thumb = ParserUtils.trim("http://" + m.group(7).replace('~', '/'));
|
||||
gi.title = ParserUtils.trim(m.group(8));
|
||||
} else {
|
||||
gi.thumb = ParserUtils.trim(m.group(5));
|
||||
gi.title = ParserUtils.trim(m.group(6));
|
||||
}
|
||||
|
||||
Matcher matcher = GalleryDetailUrlParser.URL_PATTERN.matcher(m.group(9));
|
||||
if (matcher.find()) {
|
||||
gi.gid = ParserUtils.parseLong(matcher.group(1));
|
||||
gi.token = ParserUtils.trim(matcher.group(2));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
gi.rating = NumberUtils.parseFloatSafely(getRating(m.group(11)), Float.NaN);
|
||||
gi.uploader = ParserUtils.trim(m.group(12));
|
||||
gi.generateSLang();
|
||||
|
||||
list.add(gi);
|
||||
}
|
||||
|
||||
if (list.size() == 0) {
|
||||
throw new ParseException("Can't parse gallery list", body);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String getRating(String rawRate) {
|
||||
Matcher m = RATING_PATTERN.matcher(rawRate);
|
||||
private static String parseRating(String ratingStyle) {
|
||||
Matcher m = PATTERN_RATING.matcher(ratingStyle);
|
||||
int num1;
|
||||
int num2;
|
||||
int rate = 5;
|
||||
@@ -138,4 +84,134 @@ public class GalleryListParser {
|
||||
re = Integer.toString(rate);
|
||||
return re;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static GalleryInfo parseGalleryInfo(Element e) {
|
||||
GalleryInfo gi = new GalleryInfo();
|
||||
// Get category
|
||||
Element ic = JsoupUtils.getElementByClass(e, "ic");
|
||||
if (null != ic) {
|
||||
gi.category = EhUtils.getCategory(ic.attr("alt").trim());
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info category");
|
||||
gi.category = EhUtils.UNKNOWN;
|
||||
}
|
||||
// Posted
|
||||
Element itd = JsoupUtils.getElementByClass(e, "itd");
|
||||
if (null != itd) {
|
||||
gi.posted = itd.text().trim();
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info posted");
|
||||
gi.posted = "";
|
||||
}
|
||||
// Thumb
|
||||
Element it2 = JsoupUtils.getElementByClass(e, "it2");
|
||||
if (null != it2) {
|
||||
// Thumb size
|
||||
Matcher m = PATTERN_THUMB_SIZE.matcher(it2.attr("style"));
|
||||
if (m.find()) {
|
||||
gi.thumbWidth = NumberUtils.parseIntSafely(m.group(2), 0);
|
||||
gi.thumbHeight = NumberUtils.parseIntSafely(m.group(1), 0);
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb size");
|
||||
gi.thumbWidth = 0;
|
||||
gi.thumbHeight = 0;
|
||||
}
|
||||
|
||||
// Thumb url
|
||||
Elements es = it2.children();
|
||||
if (null != es && es.size() >= 1) {
|
||||
gi.thumb = es.get(0).attr("src");
|
||||
} else {
|
||||
String html = it2.html();
|
||||
int index1 = html.indexOf('~');
|
||||
int index2 = StringUtils.ordinalIndexOf(html, '~', 2);
|
||||
if (index1 < index2) {
|
||||
gi.thumb = "http://" +StringUtils.replace(html.substring(index1 + 1, index2), "~", "/");
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb url");
|
||||
gi.thumb = "";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb");
|
||||
gi.thumbWidth = 0;
|
||||
gi.thumbHeight = 0;
|
||||
gi.thumb = "";
|
||||
}
|
||||
// Title (required)
|
||||
Element it5 = JsoupUtils.getElementByClass(e, "it5");
|
||||
if (null == it5) {
|
||||
Log.e(TAG, "Can't parse gallery info title");
|
||||
return null;
|
||||
}
|
||||
Elements es = it5.children();
|
||||
if (null == es || es.size() <= 0) {
|
||||
Log.e(TAG, "Can't parse gallery info title");
|
||||
return null;
|
||||
}
|
||||
Element a = es.get(0);
|
||||
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(a.attr("href"));
|
||||
if (null == result) {
|
||||
Log.e(TAG, "Can't parse gallery info title");
|
||||
return null;
|
||||
}
|
||||
gi.gid = result.gid;
|
||||
gi.token = result.token;
|
||||
gi.title = a.text().trim();
|
||||
// Rating
|
||||
Element it4r = JsoupUtils.getElementByClass(e, "it4r");
|
||||
if (null != it4r) {
|
||||
gi.rating = NumberUtils.parseFloatSafely(parseRating(it4r.attr("style")), Float.NaN);
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info rating");
|
||||
gi.rating = Float.NaN;
|
||||
}
|
||||
// Uploader
|
||||
Element itu = JsoupUtils.getElementByClass(e, "itu");
|
||||
if (null != itu) {
|
||||
gi.uploader = itu.text().trim();
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info uploader");
|
||||
gi.uploader = "";
|
||||
}
|
||||
|
||||
gi.generateSLang();
|
||||
|
||||
return gi;
|
||||
}
|
||||
|
||||
public static Result parse(@NonNull String body) throws Exception {
|
||||
Result result = new Result();
|
||||
Document d = Jsoup.parse(body);
|
||||
|
||||
try {
|
||||
result.pages = parsePages(d, body);
|
||||
} catch (ParseException e) {
|
||||
if (body.contains("No hits found</p>")) {
|
||||
result.pages = 0;
|
||||
//noinspection unchecked
|
||||
result.galleryInfoList = Collections.EMPTY_LIST;
|
||||
return result;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Elements es = d.getElementsByClass("itg").first().child(0).children();
|
||||
List<GalleryInfo> list = new ArrayList<>(es.size() - 1);
|
||||
for (int i = 1; i < es.size(); i++) { // First one is table header, skip it
|
||||
GalleryInfo gi = parseGalleryInfo(es.get(i));
|
||||
if (null != gi) {
|
||||
list.add(gi);
|
||||
}
|
||||
}
|
||||
result.galleryInfoList = list;
|
||||
} catch (Exception e) {
|
||||
throw new ParseException("Can't parse gallery list", body);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,11 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
return mMap.get(label);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DownloadInfo getDownloadInfo(long gid) {
|
||||
return mAllInfoMap.get(gid);
|
||||
}
|
||||
|
||||
public int getDownloadState(long gid) {
|
||||
DownloadInfo info = mAllInfoMap.get(gid);
|
||||
if (null != info) {
|
||||
|
||||
@@ -209,15 +209,6 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
stopAllIntent.setAction(ACTION_STOP_ALL);
|
||||
PendingIntent piStopAll = PendingIntent.getService(this, 0, stopAllIntent, 0);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(DownloadsScene.KEY_ACTION, DownloadsScene.ACTION_CLEAR_DOWNLOAD_SERVICE);
|
||||
Intent activityIntent = new Intent(this, MainActivity.class);
|
||||
activityIntent.setAction(StageActivity.ACTION_START_SCENE);
|
||||
activityIntent.putExtra(StageActivity.KEY_SCENE_NAME, DownloadsScene.class.getName());
|
||||
activityIntent.putExtra(StageActivity.KEY_SCENE_ARGS, bundle);
|
||||
PendingIntent piActivity = PendingIntent.getActivity(DownloadService.this, 0,
|
||||
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
mDownloadingBuilder = new NotificationCompat.Builder(getApplicationContext())
|
||||
.setSmallIcon(android.R.drawable.stat_sys_download)
|
||||
.setOngoing(true)
|
||||
@@ -225,8 +216,7 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
.setCategory(NotificationCompat.CATEGORY_PROGRESS)
|
||||
.setColor(getResources().getColor(R.color.colorPrimary))
|
||||
.addAction(R.drawable.ic_pause_x24, getString(R.string.stat_download_action_stop_all), piStopAll)
|
||||
.setShowWhen(false)
|
||||
.setContentIntent(piActivity);
|
||||
.setShowWhen(false);
|
||||
|
||||
mDownloadingDelay = new NotificationDelay(this, mNotifyManager, mDownloadingBuilder, ID_DOWNLOADING);
|
||||
}
|
||||
@@ -297,10 +287,20 @@ public class DownloadService extends Service implements DownloadManager.Download
|
||||
|
||||
ensureDownloadingBuilder();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(DownloadsScene.KEY_GID, info.gid);
|
||||
Intent activityIntent = new Intent(this, MainActivity.class);
|
||||
activityIntent.setAction(StageActivity.ACTION_START_SCENE);
|
||||
activityIntent.putExtra(StageActivity.KEY_SCENE_NAME, DownloadsScene.class.getName());
|
||||
activityIntent.putExtra(StageActivity.KEY_SCENE_ARGS, bundle);
|
||||
PendingIntent piActivity = PendingIntent.getActivity(DownloadService.this, 0,
|
||||
activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
mDownloadingBuilder.setContentTitle(EhUtils.getSuitableTitle(info))
|
||||
.setContentText(null)
|
||||
.setContentInfo(null)
|
||||
.setProgress(0, 0, true);
|
||||
.setProgress(0, 0, true)
|
||||
.setContentIntent(piActivity);
|
||||
|
||||
mDownloadingDelay.startForeground();
|
||||
}
|
||||
|
||||
@@ -37,8 +37,7 @@ import com.hippo.ehviewer.client.EhConfig;
|
||||
import com.hippo.ehviewer.client.EhRequestBuilder;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
import com.hippo.ehviewer.client.data.NormalPreviewSet;
|
||||
import com.hippo.ehviewer.client.data.PreviewSet;
|
||||
import com.hippo.ehviewer.client.exception.Image509Exception;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.ehviewer.client.parser.GalleryDetailParser;
|
||||
@@ -680,23 +679,12 @@ public class SpiderQueen implements Runnable {
|
||||
}
|
||||
|
||||
private void readPreviews(String body, SpiderInfo spiderInfo) throws ParseException {
|
||||
try {
|
||||
NormalPreviewSet previewSet = GalleryDetailParser.parseNormalPreviewSet(body);
|
||||
spiderInfo.previewPerPage = previewSet.size();
|
||||
for (int i = 0, n = previewSet.size(); i < n; i++) {
|
||||
GalleryPageUrlParser.Result result = GalleryPageUrlParser.parse(previewSet.getPageUrlAt(i));
|
||||
if (result != null) {
|
||||
spiderInfo.pTokenMap.put(result.page, result.pToken);
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
LargePreviewSet previewSet = GalleryDetailParser.parseLargePreviewSet(body);
|
||||
spiderInfo.previewPerPage = previewSet.size();
|
||||
for (int i = 0, n = previewSet.size(); i < n; i++) {
|
||||
GalleryPageUrlParser.Result result = GalleryPageUrlParser.parse(previewSet.getPageUrlAt(i));
|
||||
if (result != null) {
|
||||
spiderInfo.pTokenMap.put(result.page, result.pToken);
|
||||
}
|
||||
PreviewSet previewSet = GalleryDetailParser.parsePreviewSet(body);
|
||||
spiderInfo.previewPerPage = previewSet.size();
|
||||
for (int i = 0, n = previewSet.size(); i < n; i++) {
|
||||
GalleryPageUrlParser.Result result = GalleryPageUrlParser.parse(previewSet.getPageUrlAt(i));
|
||||
if (result != null) {
|
||||
spiderInfo.pTokenMap.put(result.page, result.pToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@@ -80,7 +82,6 @@ public class GalleryActivity extends EhActivity
|
||||
public static final String KEY_FILENAME = "filename";
|
||||
public static final String KEY_GALLERY_INFO = "gallery_info";
|
||||
public static final String KEY_PAGE = "page";
|
||||
public static final String KEY_SHOWING = "showing";
|
||||
public static final String KEY_CURRENT_INDEX = "current_index";
|
||||
|
||||
private static final long SLIDER_ANIMATION_DURING = 150;
|
||||
@@ -101,7 +102,7 @@ public class GalleryActivity extends EhActivity
|
||||
|
||||
@Nullable
|
||||
private SystemUiHelper mSystemUiHelper;
|
||||
private boolean mSystemUiShowing = false;
|
||||
private boolean mShowSystemUi;
|
||||
|
||||
@Nullable
|
||||
private View mClock;
|
||||
@@ -116,24 +117,34 @@ public class GalleryActivity extends EhActivity
|
||||
@Nullable
|
||||
private ReversibleSeekBar mSeekBar;
|
||||
|
||||
private ObjectAnimator mSeekBarPanelAnimator;
|
||||
|
||||
private int mLayoutMode;
|
||||
private int mSize;
|
||||
private int mCurrentIndex;
|
||||
|
||||
private final ConcurrentPool<NotifyTask> mNotifyTaskPool = new ConcurrentPool<>(3);
|
||||
|
||||
private final Runnable mRequestLayoutSliderTask = new Runnable() {
|
||||
private final ValueAnimator.AnimatorUpdateListener mUpdateSliderListener = new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mSeekBarPanel != null) {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
if (null != mSeekBarPanel) {
|
||||
mSeekBarPanel.requestLayout();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final SimpleAnimatorListener mShowSliderListener = new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mSeekBarPanelAnimator = null;
|
||||
}
|
||||
};
|
||||
|
||||
private final SimpleAnimatorListener mHideSliderListener = new SimpleAnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mSeekBarPanelAnimator = null;
|
||||
if (mSeekBarPanel != null) {
|
||||
mSeekBarPanel.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
@@ -199,7 +210,6 @@ public class GalleryActivity extends EhActivity
|
||||
if (mGalleryInfo != null) {
|
||||
outState.putParcelable(KEY_GALLERY_INFO, mGalleryInfo);
|
||||
}
|
||||
outState.putBoolean(KEY_SHOWING, mSystemUiShowing);
|
||||
outState.putInt(KEY_PAGE, mPage);
|
||||
outState.putInt(KEY_CURRENT_INDEX, mCurrentIndex);
|
||||
}
|
||||
@@ -222,7 +232,7 @@ public class GalleryActivity extends EhActivity
|
||||
mGalleryProvider.start();
|
||||
|
||||
setContentView(R.layout.activity_gallery);
|
||||
GLRootView glRootView = (GLRootView) findViewById(R.id.gl_root_view);
|
||||
GLRootView glRootView = (GLRootView) ViewUtils.$$(this, R.id.gl_root_view);
|
||||
mGalleryProvider.setGLRoot(glRootView);
|
||||
mUploader = new ImageTexture.Uploader(glRootView);
|
||||
|
||||
@@ -247,23 +257,18 @@ public class GalleryActivity extends EhActivity
|
||||
}
|
||||
mSystemUiHelper = new SystemUiHelper(this, systemUiLevel,
|
||||
SystemUiHelper.FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES | SystemUiHelper.FLAG_IMMERSIVE_STICKY);
|
||||
if (savedInstanceState == null || !savedInstanceState.getBoolean(KEY_SHOWING, false)) {
|
||||
mSystemUiHelper.hide();
|
||||
mSystemUiShowing = false;
|
||||
} else {
|
||||
mSystemUiHelper.show();
|
||||
mSystemUiShowing = true;
|
||||
}
|
||||
mSystemUiHelper.hide();
|
||||
mShowSystemUi = false;
|
||||
|
||||
mClock = ViewUtils.$$(this, R.id.clock);
|
||||
mBattery = ViewUtils.$$(this, R.id.battery);
|
||||
mClock.setVisibility(Settings.getShowClock() ? View.VISIBLE : View.GONE);
|
||||
mBattery.setVisibility(Settings.getShowBattery() ? View.VISIBLE : View.GONE);
|
||||
|
||||
mSeekBarPanel = findViewById(R.id.seek_bar_panel);
|
||||
mLeftText = (TextView) mSeekBarPanel.findViewById(R.id.left);
|
||||
mRightText = (TextView) mSeekBarPanel.findViewById(R.id.right);
|
||||
mSeekBar = (ReversibleSeekBar) mSeekBarPanel.findViewById(R.id.seek_bar);
|
||||
mSeekBarPanel = ViewUtils.$$(this, R.id.seek_bar_panel);
|
||||
mLeftText = (TextView) ViewUtils.$$(mSeekBarPanel, R.id.left);
|
||||
mRightText = (TextView) ViewUtils.$$(mSeekBarPanel, R.id.right);
|
||||
mSeekBar = (ReversibleSeekBar) ViewUtils.$$(mSeekBarPanel, R.id.seek_bar);
|
||||
mSeekBar.setOnSeekBarChangeListener(this);
|
||||
|
||||
mSize = mGalleryProvider.size();
|
||||
@@ -302,6 +307,8 @@ public class GalleryActivity extends EhActivity
|
||||
mLeftText = null;
|
||||
mRightText = null;
|
||||
mSeekBar = null;
|
||||
|
||||
SimpleHandler.getInstance().removeCallbacks(mHideSliderRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -327,7 +334,7 @@ public class GalleryActivity extends EhActivity
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
|
||||
if (hasFocus && mSystemUiHelper != null) {
|
||||
if (mSystemUiShowing) {
|
||||
if (mShowSystemUi) {
|
||||
mSystemUiHelper.show();
|
||||
} else {
|
||||
mSystemUiHelper.hide();
|
||||
@@ -603,19 +610,44 @@ public class GalleryActivity extends EhActivity
|
||||
}
|
||||
|
||||
private void showSlider(View sliderPanel) {
|
||||
if (null != mSeekBarPanelAnimator) {
|
||||
mSeekBarPanelAnimator.cancel();
|
||||
mSeekBarPanelAnimator = null;
|
||||
}
|
||||
|
||||
sliderPanel.setTranslationY(sliderPanel.getHeight());
|
||||
sliderPanel.setVisibility(View.VISIBLE);
|
||||
sliderPanel.animate().translationY(0.0f).setDuration(SLIDER_ANIMATION_DURING)
|
||||
.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR)
|
||||
.setListener(null).start();
|
||||
// Request layout ensure show it
|
||||
SimpleHandler.getInstance().post(mRequestLayoutSliderTask);
|
||||
|
||||
mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", 0.0f);
|
||||
mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
|
||||
mSeekBarPanelAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
|
||||
mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
|
||||
mSeekBarPanelAnimator.addListener(mShowSliderListener);
|
||||
mSeekBarPanelAnimator.start();
|
||||
|
||||
if (null != mSystemUiHelper) {
|
||||
mSystemUiHelper.show();
|
||||
mShowSystemUi = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void hideSlider(View sliderPanel) {
|
||||
sliderPanel.animate().translationY(sliderPanel.getHeight()).setDuration(SLIDER_ANIMATION_DURING)
|
||||
.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR)
|
||||
.setListener(mHideSliderListener).start();
|
||||
if (null != mSeekBarPanelAnimator) {
|
||||
mSeekBarPanelAnimator.cancel();
|
||||
mSeekBarPanelAnimator = null;
|
||||
}
|
||||
|
||||
mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight());
|
||||
mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
|
||||
mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
|
||||
mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
|
||||
mSeekBarPanelAnimator.addListener(mHideSliderListener);
|
||||
mSeekBarPanelAnimator.start();
|
||||
|
||||
if (null != mSystemUiHelper) {
|
||||
mSystemUiHelper.hide();
|
||||
mShowSystemUi = false;
|
||||
}
|
||||
}
|
||||
|
||||
private class GalleryMenuHelper implements DialogInterface.OnClickListener {
|
||||
|
||||
@@ -102,6 +102,8 @@ public class DownloadsScene extends ToolbarScene
|
||||
|
||||
private static final String TAG = DownloadsScene.class.getSimpleName();
|
||||
|
||||
public static final String KEY_GID = "gid";
|
||||
|
||||
public static final String KEY_ACTION = "action";
|
||||
private static final String KEY_LABEL = "label";
|
||||
|
||||
@@ -133,15 +135,43 @@ public class DownloadsScene extends ToolbarScene
|
||||
|
||||
private ShowcaseView mShowcaseView;
|
||||
|
||||
private int mInitPosition = -1;
|
||||
|
||||
@Override
|
||||
public int getNavCheckedItem() {
|
||||
return R.id.nav_downloads;
|
||||
}
|
||||
|
||||
private void handleArguments(Bundle args) {
|
||||
if (args != null && ACTION_CLEAR_DOWNLOAD_SERVICE.equals(args.getString(KEY_ACTION))) {
|
||||
private boolean handleArguments(Bundle args) {
|
||||
if (null == args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ACTION_CLEAR_DOWNLOAD_SERVICE.equals(args.getString(KEY_ACTION))) {
|
||||
DownloadService.clear();
|
||||
}
|
||||
|
||||
long gid;
|
||||
if (null != mDownloadManager && -1L != (gid = args.getLong(KEY_GID, -1L))) {
|
||||
DownloadInfo info = mDownloadManager.getDownloadInfo(gid);
|
||||
if (null != info) {
|
||||
mLabel = info.getLabel();
|
||||
updateForLabel();
|
||||
updateView();
|
||||
|
||||
// Get position
|
||||
if (null != mList) {
|
||||
int position = mList.indexOf(info);
|
||||
if (position >= 0 && null != mRecyclerView) {
|
||||
mRecyclerView.scrollToPosition(position);
|
||||
} else {
|
||||
mInitPosition = position;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,8 +183,6 @@ public class DownloadsScene extends ToolbarScene
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
handleArguments(getArguments());
|
||||
|
||||
Context context = getContext2();
|
||||
AssertUtils.assertNotNull(context);
|
||||
mDownloadManager = EhApplication.getDownloadManager(context);
|
||||
@@ -218,8 +246,10 @@ public class DownloadsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
private void onInit() {
|
||||
mLabel = Settings.getRecentDownloadLabel();
|
||||
updateForLabel();
|
||||
if (!handleArguments(getArguments())) {
|
||||
mLabel = Settings.getRecentDownloadLabel();
|
||||
updateForLabel();
|
||||
}
|
||||
}
|
||||
|
||||
private void onRestore(@NonNull Bundle savedInstanceState) {
|
||||
@@ -274,6 +304,10 @@ public class DownloadsScene extends ToolbarScene
|
||||
int paddingH = context.getResources().getDimensionPixelOffset(R.dimen.list_content_margin_h);
|
||||
int paddingV = context.getResources().getDimensionPixelOffset(R.dimen.list_content_margin_v);
|
||||
mRecyclerView.setPadding(paddingV, paddingH, paddingV, paddingH);
|
||||
if (mInitPosition >= 0) {
|
||||
mRecyclerView.scrollToPosition(mInitPosition);
|
||||
mInitPosition = -1;
|
||||
}
|
||||
|
||||
fastScroller.attachToRecyclerView(mRecyclerView);
|
||||
HandlerDrawable handlerDrawable = new HandlerDrawable();
|
||||
@@ -1098,7 +1132,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
return;
|
||||
}
|
||||
DownloadInfo info = mList.get(position);
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(info.gid), info.thumb, true);
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(info.gid), info.thumb);
|
||||
holder.title.setText(EhUtils.getSuitableTitle(info));
|
||||
holder.uploader.setText(info.uploader);
|
||||
holder.rating.setRating(info.rating);
|
||||
|
||||
@@ -200,6 +200,5 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> implem
|
||||
@Override
|
||||
public void onReceive(int id, Object obj) {
|
||||
setType(Settings.getListMode());
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
@@ -69,8 +70,8 @@ import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.data.PreviewSet;
|
||||
import com.hippo.ehviewer.client.parser.RateGalleryParser;
|
||||
import com.hippo.ehviewer.dao.DownloadInfo;
|
||||
import com.hippo.ehviewer.dao.Filter;
|
||||
@@ -102,7 +103,6 @@ import com.hippo.yorozuya.ViewUtils;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class GalleryDetailScene extends BaseScene implements View.OnClickListener,
|
||||
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener,
|
||||
@@ -715,7 +715,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
if (ACTION_GALLERY_INFO.equals(mAction) && mGalleryInfo != null) {
|
||||
GalleryInfo gi = mGalleryInfo;
|
||||
mThumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb, true);
|
||||
mThumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb);
|
||||
mTitle.setText(EhUtils.getSuitableTitle(gi));
|
||||
mUploader.setText(gi.uploader);
|
||||
mCategory.setText(EhUtils.getCategory(gi.category));
|
||||
@@ -756,7 +756,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
Resources resources = getResources2();
|
||||
AssertUtils.assertNotNull(resources);
|
||||
|
||||
mThumb.load(EhCacheKeyFactory.getThumbKey(gd.gid), gd.thumb, true);
|
||||
mThumb.load(EhCacheKeyFactory.getThumbKey(gd.gid), gd.thumb);
|
||||
mTitle.setText(EhUtils.getSuitableTitle(gd));
|
||||
mUploader.setText(gd.uploader);
|
||||
mCategory.setText(EhUtils.getCategory(gd.category));
|
||||
@@ -861,6 +861,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void bindPreviews(GalleryDetail gd) {
|
||||
LayoutInflater inflater = getLayoutInflater2();
|
||||
Resources resources = getResources2();
|
||||
@@ -869,7 +870,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
|
||||
mGridLayout.removeAllViews();
|
||||
LargePreviewSet previewSet = gd.previewSet;
|
||||
PreviewSet previewSet = gd.previewSet;
|
||||
if (gd.previewPages <= 0 || previewSet == null || previewSet.size() == 0) {
|
||||
mPreviewText.setText(R.string.no_previews);
|
||||
return;
|
||||
@@ -886,14 +887,12 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
View view = inflater.inflate(R.layout.item_gallery_preview, mGridLayout, false);
|
||||
mGridLayout.addView(view);
|
||||
|
||||
int index = previewSet.getIndexAt(i);
|
||||
String imageUrl = previewSet.getImageUrlAt(i);
|
||||
LoadImageView image = (LoadImageView) view.findViewById(R.id.image);
|
||||
image.load(EhCacheKeyFactory.getLargePreviewKey(gd.gid, index), imageUrl, true);
|
||||
previewSet.load(image, gd.gid, i);
|
||||
image.setTag(R.id.index, i);
|
||||
image.setOnClickListener(this);
|
||||
TextView text = (TextView) view.findViewById(R.id.text);
|
||||
text.setText(String.format(Locale.US, "%d", index + 1));
|
||||
text.setText(Integer.toString(previewSet.getPosition(i) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1006,6 +1005,14 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
if (null == gd) {
|
||||
return;
|
||||
}
|
||||
String keyword = EhUtils.extractTitle(gd.title);
|
||||
if (null != keyword) {
|
||||
ListUrlBuilder lub = new ListUrlBuilder();
|
||||
lub.setMode(ListUrlBuilder.MODE_NORMAL);
|
||||
lub.setKeyword(keyword);
|
||||
GalleryListScene.startScene(this, lub);
|
||||
return;
|
||||
}
|
||||
String artist = getArtist(gd.tags);
|
||||
if (null != artist) {
|
||||
ListUrlBuilder lub = new ListUrlBuilder();
|
||||
@@ -1602,9 +1609,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
// Put gallery detail to cache
|
||||
EhApplication.getGalleryDetailCache(getApplication()).put(result.gid, result);
|
||||
EhApplication.getLargePreviewSetCache(getApplication()).put(
|
||||
EhCacheKeyFactory.getLargePreviewSetKey(result.gid, 0), result.previewSet);
|
||||
EhApplication.getPreviewPagesCache(getApplication()).put(result.gid, result.previewPages);
|
||||
|
||||
// Add history
|
||||
EhDB.putHistoryInfo(result);
|
||||
|
||||
@@ -500,12 +500,21 @@ public final class GalleryListScene extends BaseScene
|
||||
private void showAddQuickSearchDialog(final List<QuickSearch> list,
|
||||
final ArrayAdapter<QuickSearch> adapter, final ListView listView, final TextView tip) {
|
||||
Context context = getContext2();
|
||||
if (null == context || null == mUrlBuilder) {
|
||||
final ListUrlBuilder urlBuilder = mUrlBuilder;
|
||||
if (null == context || null == urlBuilder) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check duplicate
|
||||
for (QuickSearch q: list) {
|
||||
if (urlBuilder.equalsQuickSearch(q)) {
|
||||
showTip(getString(R.string.duplicate_quick_search, q.name), LENGTH_SHORT);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final EditTextDialogBuilder builder = new EditTextDialogBuilder(context,
|
||||
getSuitableTitleForUrlBuilder(context.getResources(), mUrlBuilder, false), getString(R.string.quick_search));
|
||||
getSuitableTitleForUrlBuilder(context.getResources(), urlBuilder, false), getString(R.string.quick_search));
|
||||
builder.setTitle(R.string.add_quick_search_dialog_title);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
final AlertDialog dialog = builder.show();
|
||||
@@ -513,25 +522,36 @@ public final class GalleryListScene extends BaseScene
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String text = builder.getText().trim();
|
||||
|
||||
// Check name empty
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
builder.setError(getString(R.string.name_is_empty));
|
||||
} else {
|
||||
builder.setError(null);
|
||||
dialog.dismiss();
|
||||
QuickSearch quickSearch = mUrlBuilder.toQuickSearch();
|
||||
quickSearch.name = text;
|
||||
EhDB.insertQuickSearch(quickSearch);
|
||||
list.add(quickSearch);
|
||||
adapter.notifyDataSetChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == list.size()) {
|
||||
tip.setVisibility(View.VISIBLE);
|
||||
listView.setVisibility(View.GONE);
|
||||
} else {
|
||||
tip.setVisibility(View.GONE);
|
||||
listView.setVisibility(View.VISIBLE);
|
||||
// Check name duplicate
|
||||
for (QuickSearch q: list) {
|
||||
if (text.equals(q.name)) {
|
||||
builder.setError(getString(R.string.duplicate_name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
builder.setError(null);
|
||||
dialog.dismiss();
|
||||
QuickSearch quickSearch = urlBuilder.toQuickSearch();
|
||||
quickSearch.name = text;
|
||||
EhDB.insertQuickSearch(quickSearch);
|
||||
list.add(quickSearch);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
if (0 == list.size()) {
|
||||
tip.setVisibility(View.VISIBLE);
|
||||
listView.setVisibility(View.GONE);
|
||||
} else {
|
||||
tip.setVisibility(View.GONE);
|
||||
listView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1074,7 +1094,7 @@ public final class GalleryListScene extends BaseScene
|
||||
if (mHelper != null && mSearchBarMover != null &&
|
||||
mHelper.isCurrentTask(taskId) && isViewCreated()) {
|
||||
mHelper.setPages(taskId, result.pages);
|
||||
mHelper.onGetPageData(taskId, result.galleryInfos);
|
||||
mHelper.onGetPageData(taskId, result.galleryInfoList);
|
||||
SimpleHandler.getInstance().post(mReturnSearchBarRunnable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@@ -37,13 +38,12 @@ import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryPreview;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
import com.hippo.ehviewer.client.data.PreviewSet;
|
||||
import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
@@ -54,7 +54,6 @@ import com.hippo.widget.Slider;
|
||||
import com.hippo.widget.recyclerview.AutoGridLayoutManager;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -229,7 +228,7 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
Intent intent = new Intent(context, GalleryActivity.class);
|
||||
intent.setAction(GalleryActivity.ACTION_EH);
|
||||
intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, mGalleryInfo);
|
||||
intent.putExtra(GalleryActivity.KEY_PAGE, p.index);
|
||||
intent.putExtra(GalleryActivity.KEY_PAGE, p.getPosition());
|
||||
startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
@@ -263,11 +262,12 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void onBindViewHolder(GalleryPreviewHolder holder, int position) {
|
||||
if (null != mHelper && null != mGalleryInfo) {
|
||||
if (null != mHelper) {
|
||||
GalleryPreview preview = mHelper.getDataAt(position);
|
||||
holder.image.load(EhCacheKeyFactory.getLargePreviewKey(mGalleryInfo.gid, preview.index), preview.imageUrl);
|
||||
holder.text.setText(String.format(Locale.US, "%d", preview.index + 1));
|
||||
preview.load(holder.image);
|
||||
holder.text.setText(Integer.toString(preview.getPosition() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,24 +287,11 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
return;
|
||||
}
|
||||
|
||||
final LargePreviewSet previewSet = EhApplication.getLargePreviewSetCache(
|
||||
getContext()).get(EhCacheKeyFactory.getLargePreviewSetKey(mGalleryInfo.gid, page));
|
||||
final Integer pages = EhApplication.getPreviewPagesCache(getContext()).get(mGalleryInfo.gid);
|
||||
if (previewSet != null && pages != null) {
|
||||
SimpleHandler.getInstance().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onGetLargePreviewSetSuccess(Pair.create(previewSet, pages), taskId);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
String url = EhUrl.getGalleryDetailUrl(mGalleryInfo.gid, mGalleryInfo.token, page, false);
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_GET_LARGE_PREVIEW_SET);
|
||||
request.setCallback(new GetLargePreviewSetListener(getContext(),
|
||||
activity.getStageId(), getTag(), taskId, mGalleryInfo.gid, page));
|
||||
request.setMethod(EhClient.METHOD_GET_PREVIEW_SET);
|
||||
request.setCallback(new GetPreviewSetListener(getContext(),
|
||||
activity.getStageId(), getTag(), taskId));
|
||||
request.setArgs(url);
|
||||
mClient.execute(request);
|
||||
}
|
||||
@@ -336,17 +323,13 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
}
|
||||
}
|
||||
|
||||
private void onGetLargePreviewSetSuccess(Pair<LargePreviewSet, Integer> result, int taskId) {
|
||||
if (mHelper != null && mHelper.isCurrentTask(taskId) && isViewCreated()) {
|
||||
LargePreviewSet previewSet = result.first;
|
||||
private void onGetPreviewSetSuccess(Pair<PreviewSet, Integer> result, int taskId) {
|
||||
if (null != mHelper && mHelper.isCurrentTask(taskId) && null != mGalleryInfo) {
|
||||
PreviewSet previewSet = result.first;
|
||||
int size = previewSet.size();
|
||||
ArrayList<GalleryPreview> list = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
GalleryPreview preview = new GalleryPreview();
|
||||
preview.imageUrl = previewSet.getImageUrlAt(i);
|
||||
preview.pageUrl = previewSet.getPageUrlAt(i);
|
||||
preview.index = previewSet.getIndexAt(i);
|
||||
list.add(preview);
|
||||
list.add(previewSet.getGalleryPreview(mGalleryInfo.gid, i));
|
||||
}
|
||||
|
||||
mHelper.setPages(taskId, result.second);
|
||||
@@ -354,34 +337,26 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
}
|
||||
}
|
||||
|
||||
private void onGetLargePreviewSetFailure(Exception e, int taskId) {
|
||||
if (mHelper != null && mHelper.isCurrentTask(taskId) && isViewCreated()) {
|
||||
private void onGetPreviewSetFailure(Exception e, int taskId) {
|
||||
if (mHelper != null && mHelper.isCurrentTask(taskId)) {
|
||||
mHelper.onGetException(taskId, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class GetLargePreviewSetListener extends EhCallback<GalleryPreviewsScene, Pair<LargePreviewSet, Integer>> {
|
||||
private static class GetPreviewSetListener extends EhCallback<GalleryPreviewsScene, Pair<PreviewSet, Integer>> {
|
||||
|
||||
private final int mTaskId;
|
||||
private final long mGid;
|
||||
private final int mPage;
|
||||
|
||||
public GetLargePreviewSetListener(Context context, int stageId, String sceneTag, int taskId, long gid, int page) {
|
||||
public GetPreviewSetListener(Context context, int stageId, String sceneTag, int taskId) {
|
||||
super(context, stageId, sceneTag);
|
||||
mTaskId = taskId;
|
||||
mGid = gid;
|
||||
mPage = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Pair<LargePreviewSet, Integer> result) {
|
||||
EhApplication.getLargePreviewSetCache(getApplication()).put(
|
||||
EhCacheKeyFactory.getLargePreviewSetKey(mGid, mPage), result.first);
|
||||
EhApplication.getPreviewPagesCache(getApplication()).put(mGid, result.second);
|
||||
|
||||
public void onSuccess(Pair<PreviewSet, Integer> result) {
|
||||
GalleryPreviewsScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onGetLargePreviewSetSuccess(result, mTaskId);
|
||||
scene.onGetPreviewSetSuccess(result, mTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +364,7 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
public void onFailure(Exception e) {
|
||||
GalleryPreviewsScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onGetLargePreviewSetFailure(e, mTaskId);
|
||||
scene.onGetPreviewSetFailure(e, mTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
@@ -326,6 +328,7 @@ public class HistoryScene extends ToolbarScene
|
||||
}
|
||||
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onBindViewHolder(HistoryHolder holder, int position) {
|
||||
if (null == mLazyList) {
|
||||
return;
|
||||
@@ -344,6 +347,12 @@ public class HistoryScene extends ToolbarScene
|
||||
}
|
||||
holder.posted.setText(gi.posted);
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
|
||||
// Update transition name
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,13 +17,16 @@
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
public class SeekBarPanel extends LinearLayout {
|
||||
|
||||
private SeekBar mSeekBar;
|
||||
@@ -41,17 +44,9 @@ public class SeekBarPanel extends LinearLayout {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAdded(View child) {
|
||||
if (child instanceof SeekBar) {
|
||||
mSeekBar = (SeekBar) child;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View child) {
|
||||
if (child == mSeekBar) {
|
||||
mSeekBar = null;
|
||||
}
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mSeekBar = (SeekBar) ViewUtils.$$(this, R.id.seek_bar);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,4 +62,11 @@ public class SeekBarPanel extends LinearLayout {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected boolean fitSystemWindows(Rect insets) {
|
||||
insets.top = 0;
|
||||
return super.fitSystemWindows(insets);
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.hippo.conaco.ConacoTask;
|
||||
import com.hippo.conaco.DataContainer;
|
||||
import com.hippo.conaco.Unikery;
|
||||
import com.hippo.conaco.ValueHolder;
|
||||
import com.hippo.drawable.PreciselyClipDrawable;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
@@ -49,6 +50,11 @@ public class LoadImageView extends FixedAspectImageView implements Unikery<Bitma
|
||||
private DataContainer mContainer;
|
||||
private boolean mUseNetwork;
|
||||
|
||||
private int mOffsetX = Integer.MIN_VALUE;
|
||||
private int mOffsetY = Integer.MIN_VALUE;
|
||||
private int mClipWidth = Integer.MIN_VALUE;
|
||||
private int mClipHeight = Integer.MIN_VALUE;
|
||||
|
||||
private ValueHolder<Bitmap> mHolder;
|
||||
|
||||
private boolean mFailed;
|
||||
@@ -152,6 +158,20 @@ public class LoadImageView extends FixedAspectImageView implements Unikery<Bitma
|
||||
load(key, url, null, true);
|
||||
}
|
||||
|
||||
public void setClip(int offsetX, int offsetY, int clipWidth, int clipHeight) {
|
||||
mOffsetX = offsetX;
|
||||
mOffsetY = offsetY;
|
||||
mClipWidth = clipWidth;
|
||||
mClipHeight = clipHeight;
|
||||
}
|
||||
|
||||
public void resetClip() {
|
||||
mOffsetX = Integer.MIN_VALUE;
|
||||
mOffsetY = Integer.MIN_VALUE;
|
||||
mClipWidth = Integer.MIN_VALUE;
|
||||
mClipHeight = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
public void load(String key, String url, boolean useNetwork) {
|
||||
load(key, url, null, useNetwork);
|
||||
}
|
||||
@@ -252,6 +272,10 @@ public class LoadImageView extends FixedAspectImageView implements Unikery<Bitma
|
||||
Bitmap bitmap = holder.getValue();
|
||||
Drawable drawable = new BitmapDrawable(getResources(), bitmap);
|
||||
|
||||
if (Integer.MIN_VALUE != mOffsetX) {
|
||||
drawable = new PreciselyClipDrawable(drawable, mOffsetX, mOffsetY, mClipWidth, mClipHeight);
|
||||
}
|
||||
|
||||
if ((source == Conaco.Source.DISK || source == Conaco.Source.NETWORK)) {
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = new ColorDrawable(Color.TRANSPARENT);
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
android:paddingRight="16dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/gallery_slider_background"
|
||||
android:fitsSystemWindows="true"
|
||||
android:visibility="invisible">
|
||||
|
||||
<TextView
|
||||
@@ -65,12 +66,18 @@
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
<com.hippo.ehviewer.widget.ReversibleSeekBar
|
||||
android:id="@+id/seek_bar"
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
android:layout_weight="1">
|
||||
|
||||
<com.hippo.ehviewer.widget.ReversibleSeekBar
|
||||
android:id="@+id/seek_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/right"
|
||||
|
||||
@@ -139,6 +139,8 @@
|
||||
<string name="no_quick_search">这里是快速搜索</string>
|
||||
<string name="add_quick_search_tip">画廊列表的状态将被保存为快速搜索。如果你想保存搜索面板的状态,请先执行搜索。</string>
|
||||
<string name="readme">读我</string>
|
||||
<string name="duplicate_quick_search">已存在相同的快速搜索,名称为“%s”。</string>
|
||||
<string name="duplicate_name">已存在相同名称</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 星</string>
|
||||
@@ -474,6 +476,7 @@
|
||||
<string name="let_me_select">让我选择</string>
|
||||
<string name="favorites_info">收藏信息</string>
|
||||
<string name="collections">收藏夹</string>
|
||||
<string name="need_sign_in">需要登录</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">被玩坏了</string>
|
||||
|
||||
@@ -139,6 +139,8 @@
|
||||
<string name="no_quick_search">這裏是快速搜索</string>
|
||||
<string name="add_quick_search_tip">畫廊列表的狀態將被保存為快速搜索。如果你想保存搜索面板的狀態,請先執行搜索。</string>
|
||||
<string name="readme">讀我</string>
|
||||
<string name="duplicate_quick_search">已存在相同的快速搜索,名稱為“%s”。</string>
|
||||
<string name="duplicate_name">已存在相同名稱</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 星</string>
|
||||
@@ -474,6 +476,7 @@
|
||||
<string name="let_me_select">讓我選擇</string>
|
||||
<string name="favorites_info">收藏信息</string>
|
||||
<string name="collections">收藏夾</string>
|
||||
<string name="need_sign_in">需要登錄</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">被玩壞了</string>
|
||||
|
||||
@@ -139,6 +139,8 @@
|
||||
<string name="no_quick_search">這裡是快速搜尋</string>
|
||||
<string name="add_quick_search_tip">畫廊列表的狀態將被儲存為快速搜尋。如果你想儲存搜尋面板的狀態,請先執行搜尋。</string>
|
||||
<string name="readme">讀我</string>
|
||||
<string name="duplicate_quick_search">已存在相同的快速搜尋,名稱為“%s”。</string>
|
||||
<string name="duplicate_name">已存在相同名稱</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 星</string>
|
||||
@@ -474,6 +476,7 @@
|
||||
<string name="let_me_select">讓我選擇</string>
|
||||
<string name="favorites_info">收藏資訊</string>
|
||||
<string name="collections">收藏夾</string>
|
||||
<string name="need_sign_in">需要登入</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">被玩壞了</string>
|
||||
|
||||
@@ -181,6 +181,8 @@
|
||||
<string name="no_quick_search">Quick search will be shown here</string>
|
||||
<string name="add_quick_search_tip">The state of gallery list will be saved as quick search. Apply search first if you want to save the state of search panel.</string>
|
||||
<string name="readme">README</string>
|
||||
<string name="duplicate_quick_search">A duplicate quick search exists. The name is \"%s\".</string>
|
||||
<string name="duplicate_name">A duplicate name exists</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 stars</string>
|
||||
@@ -521,6 +523,7 @@
|
||||
<string name="let_me_select">Let me select</string>
|
||||
<string name="favorites_info">Favorites info</string>
|
||||
<string name="collections">Collections</string>
|
||||
<string name="need_sign_in">Signing in is required</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">Something wrong happened</string>
|
||||
|
||||
+1
-1
Submodule beerbelly updated: 16a850c533...226afb5f5d.
+1
-1
Submodule conaco updated: 4420aadb7b...e990da228c.
+1
-1
Submodule easyrecyclerview updated: 2cbf2f787e...68135c110b.
+1
-1
Submodule rippleold updated: a433440c98...8e23bfb9b2.
+1
-1
Submodule unifile updated: d04eec1daf...704956a6f5.
+1
-1
Submodule yorozuya updated: fa39102e58...e9d22840d0.
Reference in new issue
Block a user