mirror of
https://github.com/seven332/EhViewer
synced 2026-11-28 18:18:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
baeba9251d | ||
|
|
e06db7e16e | ||
|
|
ecd695f4f4 | ||
|
|
10665dfeef |
No files matched your search
+2
-2
@@ -15,8 +15,8 @@
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hippo.ehviewer"
|
||||
android:versionCode="18"
|
||||
android:versionName="0.5.3" >
|
||||
android:versionCode="20"
|
||||
android:versionName="0.5.3.2" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
||||
Binary file not shown.
@@ -1,3 +1,9 @@
|
||||
Version 0.5.3.2 (2014-08-11)
|
||||
* 修正下载错误
|
||||
|
||||
Version 0.5.3.1 (2014-08-09)
|
||||
* 修正由于网站变化而导致分析错误
|
||||
|
||||
Version 0.5.3 (2014-06-15)
|
||||
* 添加热门
|
||||
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
|
||||
package com.hippo.ehviewer.data;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class GalleryDetail extends GalleryInfo{
|
||||
|
||||
|
||||
public String title_jpn;
|
||||
public int pages;
|
||||
public String size;
|
||||
@@ -32,14 +31,14 @@ public class GalleryDetail extends GalleryInfo{
|
||||
public String language;
|
||||
public int people;
|
||||
public String firstPage;
|
||||
public LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>> tags;
|
||||
|
||||
public LinkedHashMap<String, LinkedList<String>> tags;
|
||||
|
||||
// For Preview
|
||||
public int previewSum;
|
||||
public int previewPerPage;
|
||||
public PreviewList[] previewLists;
|
||||
public List<Comment> comments;
|
||||
|
||||
|
||||
public GalleryDetail(GalleryInfo galleryInfo) {
|
||||
gid = galleryInfo.gid;
|
||||
token = galleryInfo.token;
|
||||
|
||||
@@ -19,9 +19,9 @@ package com.hippo.ehviewer.data;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PreviewList {
|
||||
|
||||
|
||||
public class Row {
|
||||
|
||||
|
||||
public class Item {
|
||||
public int xOffset;
|
||||
public int yOffset;
|
||||
@@ -37,20 +37,20 @@ public class PreviewList {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String imageUrl;
|
||||
public ArrayList<Item> itemArray = new ArrayList<Item>();
|
||||
public int startIndex;
|
||||
public Row(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
|
||||
public void addItem(int xOffset, int yOffset, int width, int height,
|
||||
String url) {
|
||||
itemArray.add(new Item(xOffset, yOffset, width, height, url));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Row curRow;
|
||||
public ArrayList<Row> rowArray = new ArrayList<Row>();
|
||||
|
||||
@@ -66,13 +66,13 @@ public class PreviewList {
|
||||
curRow.startIndex = lastRow.startIndex + lastRow.itemArray.size();
|
||||
rowArray.add(curRow);
|
||||
}
|
||||
|
||||
|
||||
curRow.addItem(Integer.parseInt(xOffset),
|
||||
Integer.parseInt(yOffset), Integer.parseInt(width),
|
||||
Integer.parseInt(height), url);
|
||||
}
|
||||
|
||||
public int getSum() {
|
||||
|
||||
public int size() {
|
||||
int sum = 0;
|
||||
for (Row row : rowArray)
|
||||
sum += row.itemArray.size();
|
||||
|
||||
@@ -19,23 +19,20 @@ package com.hippo.ehviewer.ehclient;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.LinkedList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.hippo.ehviewer.ListUrls;
|
||||
import com.hippo.ehviewer.data.Comment;
|
||||
import com.hippo.ehviewer.data.PreviewList;
|
||||
import com.hippo.ehviewer.util.Log;
|
||||
|
||||
public class DetailParser {
|
||||
|
||||
|
||||
private static final String OFFENSIVE_STRING =
|
||||
"<p>(And if you choose to ignore this warning, you lose all rights to complain about it in the future.)</p>";
|
||||
private static final String PINING_STRING =
|
||||
"<p>This gallery is pining for the fjords.</p>";
|
||||
|
||||
|
||||
public static final int DETAIL = 0x1;
|
||||
public static final int TAG = 0x2;
|
||||
public static final int PREVIEW_INFO = 0x4;
|
||||
@@ -43,11 +40,11 @@ public class DetailParser {
|
||||
public static final int COMMENT = 0x10;
|
||||
public static final int OFFENSIVE = 0x20;
|
||||
public static final int PINING = 0x40;
|
||||
|
||||
|
||||
private static final CommentSort cs = new CommentSort();
|
||||
|
||||
|
||||
private int mMode;
|
||||
|
||||
|
||||
public String thumb;
|
||||
public String title;
|
||||
public String title_jpn;
|
||||
@@ -65,27 +62,27 @@ public class DetailParser {
|
||||
public String firstPage;
|
||||
public int previewPerPage;
|
||||
public int previewSum;
|
||||
public LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>> tags;
|
||||
public LinkedHashMap<String, LinkedList<String>> tags;
|
||||
public PreviewList previewList;
|
||||
public LinkedList<Comment> comments;
|
||||
|
||||
|
||||
public void setMode(int mode) {
|
||||
mMode = mode;
|
||||
}
|
||||
|
||||
|
||||
public int parser(String pageContent) {
|
||||
int re = 0;
|
||||
Pattern p;
|
||||
Matcher m;
|
||||
|
||||
|
||||
if (pageContent.contains(OFFENSIVE_STRING)) {
|
||||
return OFFENSIVE;
|
||||
}
|
||||
|
||||
|
||||
if (pageContent.contains(PINING_STRING)) {
|
||||
return PINING;
|
||||
}
|
||||
|
||||
|
||||
// Get detail
|
||||
if ((mMode & DETAIL) != 0) {
|
||||
p = Pattern
|
||||
@@ -114,7 +111,7 @@ public class DetailParser {
|
||||
m = p.matcher(pageContent);
|
||||
if (m.find()) {
|
||||
re |= DETAIL;
|
||||
|
||||
|
||||
thumb = m.group(1);
|
||||
title = m.group(2);
|
||||
title_jpn = m.group(3);
|
||||
@@ -128,45 +125,40 @@ public class DetailParser {
|
||||
visible = m.group(11);
|
||||
language = m.group(12);
|
||||
people = Integer.parseInt(m.group(13).replace(",", ""));
|
||||
|
||||
|
||||
Pattern pattern = Pattern.compile("([\\d|\\.]+)");
|
||||
Matcher matcher = pattern.matcher(m.group(14));
|
||||
if (matcher.find())
|
||||
rating = Float.parseFloat(matcher.group(1));
|
||||
else
|
||||
rating = Float.NaN;
|
||||
|
||||
|
||||
firstPage = m.group(15);
|
||||
}
|
||||
}
|
||||
// Get tag
|
||||
if ((mMode & TAG) != 0) {
|
||||
tags = new LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>>();
|
||||
tags = new LinkedHashMap<String, LinkedList<String>>();
|
||||
p = Pattern
|
||||
.compile("<tr><td[^<>]*>([^<>]+):</td><td>(?:<div[^<>]*><a[^<>]*>[^<>]*</a>[^<>]*<span[^<>]*>\\d+</span>[^<>]*</div>)+</td></tr>");
|
||||
.compile("<tr><td[^<>]+>([\\w\\s]+):</td><td>(?:<div[^<>]+><a[^<>]+>[\\w\\s]+</a></div>)+</td></tr>");
|
||||
m = p.matcher(pageContent);
|
||||
while (m.find()) {
|
||||
re |= TAG;
|
||||
String groupName = m.group(1);
|
||||
LinkedList<SimpleEntry<String, Integer>> group = getTagGroup(m.group(0));
|
||||
LinkedList<String> group = getTagGroup(m.group(0));
|
||||
if (group != null) {
|
||||
tags.put(groupName, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get preview info
|
||||
if ((mMode & PREVIEW_INFO) != 0) {
|
||||
p = Pattern.compile("<p class=\"ip\">Showing ([\\d|,]+) - ([\\d|,]+) of ([\\d|,]+) images</p>");
|
||||
p = Pattern.compile("<td[^>]+><a[^>]+>([\\d,]+)</a></td><td[^>]+>(?:<a[^>]+>)?>(?:</a>)?</td>");
|
||||
m = p.matcher(pageContent);
|
||||
if (m.find()) {
|
||||
re |= PREVIEW_INFO;
|
||||
previewPerPage = Integer.parseInt(m.group(2).replace(",",
|
||||
""))
|
||||
- Integer.parseInt(m.group(1).replace(",", ""))
|
||||
+ 1;
|
||||
int total = Integer.parseInt(m.group(3).replace(",", ""));
|
||||
previewSum = (total + previewPerPage - 1) / previewPerPage;
|
||||
previewSum = Integer.valueOf(m.group(1).replace(",", ""));
|
||||
}
|
||||
}
|
||||
// Get preview
|
||||
@@ -182,6 +174,9 @@ public class DetailParser {
|
||||
previewList.addItem(m.group(3), m.group(4), "0", m.group(1),
|
||||
m.group(2), m.group(5));
|
||||
}
|
||||
// Set previewPerPage
|
||||
if (previewList != null)
|
||||
previewPerPage = previewList.size();
|
||||
}
|
||||
// Get comment
|
||||
if ((mMode & COMMENT) != 0) {
|
||||
@@ -197,24 +192,21 @@ public class DetailParser {
|
||||
}
|
||||
return re;
|
||||
}
|
||||
|
||||
private LinkedList<SimpleEntry<String, Integer>> getTagGroup(String pageContent) {
|
||||
LinkedList<SimpleEntry<String, Integer>> list =
|
||||
new LinkedList<SimpleEntry<String, Integer>>();
|
||||
Pattern p = Pattern.compile("<a[^<>]*>([^<>]+)</a> \\(<span[^<>]*>([\\d|,]+)</span>\\)");
|
||||
|
||||
private LinkedList<String> getTagGroup(String pageContent) {
|
||||
LinkedList<String> list = new LinkedList<String>();
|
||||
Pattern p = Pattern.compile("<div[^<>]+><a[^<>]+>([\\w\\s]+)</a></div>");
|
||||
Matcher m = p.matcher(pageContent);
|
||||
while (m.find())
|
||||
list.add(new SimpleEntry<String, Integer>(m.group(1),
|
||||
Integer.parseInt(m.group(2).replace(",", ""))));
|
||||
|
||||
list.add(m.group(1));
|
||||
if (list.size() == 0)
|
||||
return null;
|
||||
else
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static class CommentSort implements Comparator<Comment> {
|
||||
private int compareNum(String n1, String n2, int median) {
|
||||
int re = 0;
|
||||
@@ -252,7 +244,7 @@ public class DetailParser {
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compare(Comment c1, Comment c2) {
|
||||
int re = 0;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -19,38 +19,9 @@ package com.hippo.ehviewer.ui;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.ImageGeterManager;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.data.Comment;
|
||||
import com.hippo.ehviewer.data.Data;
|
||||
import com.hippo.ehviewer.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.data.PreviewList;
|
||||
import com.hippo.ehviewer.ehclient.DetailParser;
|
||||
import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.util.Cache;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Log;
|
||||
import com.hippo.ehviewer.util.Theme;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.hippo.ehviewer.util.Util;
|
||||
import com.hippo.ehviewer.widget.AlertButton;
|
||||
import com.hippo.ehviewer.widget.AutoWrapLayout;
|
||||
import com.hippo.ehviewer.widget.ButtonsDialogBuilder;
|
||||
import com.hippo.ehviewer.widget.DialogBuilder;
|
||||
import com.hippo.ehviewer.widget.FswView;
|
||||
import com.hippo.ehviewer.widget.LoadImageView;
|
||||
import com.hippo.ehviewer.widget.OlScrollView;
|
||||
import com.hippo.ehviewer.widget.OnFitSystemWindowsListener;
|
||||
import com.hippo.ehviewer.widget.OnLayoutListener;
|
||||
import com.hippo.ehviewer.widget.ProgressiveRatingBar;
|
||||
import com.hippo.ehviewer.widget.SuperToast;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
@@ -72,8 +43,8 @@ import android.view.ContextThemeWrapper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
@@ -85,17 +56,44 @@ import android.widget.TextSwitcher;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ViewSwitcher.ViewFactory;
|
||||
|
||||
import com.hippo.ehviewer.AppContext;
|
||||
import com.hippo.ehviewer.ImageGeterManager;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.data.Comment;
|
||||
import com.hippo.ehviewer.data.Data;
|
||||
import com.hippo.ehviewer.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.data.PreviewList;
|
||||
import com.hippo.ehviewer.ehclient.DetailParser;
|
||||
import com.hippo.ehviewer.ehclient.EhClient;
|
||||
import com.hippo.ehviewer.util.Cache;
|
||||
import com.hippo.ehviewer.util.Config;
|
||||
import com.hippo.ehviewer.util.Log;
|
||||
import com.hippo.ehviewer.util.Theme;
|
||||
import com.hippo.ehviewer.util.Ui;
|
||||
import com.hippo.ehviewer.util.Util;
|
||||
import com.hippo.ehviewer.widget.AlertButton;
|
||||
import com.hippo.ehviewer.widget.AutoWrapLayout;
|
||||
import com.hippo.ehviewer.widget.DialogBuilder;
|
||||
import com.hippo.ehviewer.widget.FswView;
|
||||
import com.hippo.ehviewer.widget.LoadImageView;
|
||||
import com.hippo.ehviewer.widget.OlScrollView;
|
||||
import com.hippo.ehviewer.widget.OnFitSystemWindowsListener;
|
||||
import com.hippo.ehviewer.widget.OnLayoutListener;
|
||||
import com.hippo.ehviewer.widget.ProgressiveRatingBar;
|
||||
import com.hippo.ehviewer.widget.SuperToast;
|
||||
|
||||
public class DetailSectionFragment extends Fragment
|
||||
implements View.OnClickListener {
|
||||
private static final String TAG = "DetailSectionFragment";
|
||||
|
||||
|
||||
private AppContext mAppContext;
|
||||
private MangaDetailActivity mActivity;
|
||||
private EhClient mClient;
|
||||
private Data mData;
|
||||
private GalleryDetail mGalleryDetail;
|
||||
private String mUrl;
|
||||
|
||||
|
||||
private View mRootView;
|
||||
private OlScrollView mScrollView;
|
||||
private Button mReadButton;
|
||||
@@ -118,13 +116,13 @@ public class DetailSectionFragment extends Fragment
|
||||
private View mFrontButton;
|
||||
private View mKnownButton;
|
||||
private View mDivider;
|
||||
|
||||
|
||||
private AlertDialog mGoToDialog;
|
||||
private AlertDialog mTagDialog;
|
||||
|
||||
|
||||
private int mCurPage;
|
||||
private boolean mShowPreview = false;
|
||||
|
||||
|
||||
private ShapeDrawable getArrowShapeDrawable(int color, boolean isToLeft) {
|
||||
Path path = new Path();
|
||||
if (isToLeft) {
|
||||
@@ -143,7 +141,7 @@ public class DetailSectionFragment extends Fragment
|
||||
//d.setBounds(0, 0, Ui.dp2pix(24), Ui.dp2pix(48));
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
private StateListDrawable getArrowClickDrawable(int color, boolean isToLeft) {
|
||||
StateListDrawable sld = new StateListDrawable();
|
||||
ShapeDrawable normal = getArrowShapeDrawable(color, isToLeft);
|
||||
@@ -157,7 +155,7 @@ public class DetailSectionFragment extends Fragment
|
||||
//sld.setBounds(0, 0, Ui.dp2pix(24), Ui.dp2pix(48));
|
||||
return sld;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
@@ -166,7 +164,7 @@ public class DetailSectionFragment extends Fragment
|
||||
mAppContext = (AppContext)mActivity.getApplication();
|
||||
mClient = mAppContext.getEhClient();
|
||||
mData = mAppContext.getData();
|
||||
|
||||
|
||||
GalleryInfo galleryInfo = mActivity.getGalleryInfo();
|
||||
boolean getFromCache = true;
|
||||
mActivity.mGalleryDetail = Cache.mdCache.get(String.valueOf(galleryInfo.gid));
|
||||
@@ -177,7 +175,7 @@ public class DetailSectionFragment extends Fragment
|
||||
mGalleryDetail = mActivity.mGalleryDetail;
|
||||
mUrl = EhClient.getDetailUrl(
|
||||
mGalleryDetail.gid, mGalleryDetail.token);
|
||||
|
||||
|
||||
mRootView = inflater.inflate(
|
||||
R.layout.detail, container, false);
|
||||
mScrollView = (OlScrollView)mRootView.findViewById(R.id.manga_detail_scrollview);
|
||||
@@ -192,7 +190,7 @@ public class DetailSectionFragment extends Fragment
|
||||
mPreviewListLayout = (AutoWrapLayout)mRootView.findViewById(R.id.paper_list_layout);
|
||||
mWaitPreviewList = (ProgressBar)mRootView.findViewById(R.id.paper_list_wait);
|
||||
mPreviewRefreshButton = (Button)mRootView.findViewById(R.id.preview_button_refresh);
|
||||
mBottomPanel = (View)mRootView.findViewById(R.id.bottom_panel);
|
||||
mBottomPanel = mRootView.findViewById(R.id.bottom_panel);
|
||||
mPreviewNumText = (TextView)mBottomPanel.findViewById(R.id.preview_num);
|
||||
mCancelButton = mOffensiveView.findViewById(R.id.detail_button_cancel);
|
||||
mOnceButton = mOffensiveView.findViewById(R.id.detail_button_once);
|
||||
@@ -201,7 +199,7 @@ public class DetailSectionFragment extends Fragment
|
||||
mBackButton = mPreviewListMain.findViewById(R.id.back);
|
||||
mFrontButton = mPreviewListMain.findViewById(R.id.front);
|
||||
mDivider = mNormalView.findViewById(R.id.divider);
|
||||
|
||||
|
||||
boolean isRandomColor = Config.getRandomThemeColor();
|
||||
int color = Config.getThemeColor();
|
||||
// Set random color
|
||||
@@ -224,9 +222,9 @@ public class DetailSectionFragment extends Fragment
|
||||
mPreviewNumText.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
|
||||
mBackButton.setBackgroundDrawable(getArrowClickDrawable(color, true));
|
||||
mFrontButton.setBackgroundDrawable(getArrowClickDrawable(color, false));
|
||||
|
||||
|
||||
mRefreshButton.setOnClickListener(this);
|
||||
|
||||
|
||||
FswView align = (FswView)mActivity.findViewById(R.id.alignment);
|
||||
int paddingLeft = align.getPaddingLeft();
|
||||
int paddingTop = align.getPaddingTop();
|
||||
@@ -244,7 +242,7 @@ public class DetailSectionFragment extends Fragment
|
||||
paddingRight, paddingBottom);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mScrollView.setOnLayoutListener(new OnLayoutListener() {
|
||||
@Override
|
||||
public void onLayout() {
|
||||
@@ -255,7 +253,7 @@ public class DetailSectionFragment extends Fragment
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
LoadImageView thumb = (LoadImageView)mRootView.findViewById(R.id.detail_cover);
|
||||
Bitmap bmp = null;
|
||||
if (Cache.memoryCache != null &&
|
||||
@@ -271,17 +269,17 @@ public class DetailSectionFragment extends Fragment
|
||||
ImageGeterManager.DISK_CACHE | ImageGeterManager.DOWNLOAD,
|
||||
new LoadImageView.SimpleImageGetListener(thumb));
|
||||
}
|
||||
|
||||
|
||||
TextView title = (TextView)mRootView.findViewById(R.id.detail_title);
|
||||
title.setText(mGalleryDetail.title);
|
||||
|
||||
|
||||
TextView uploader = (TextView)mRootView.findViewById(R.id.detail_uploader);
|
||||
uploader.setText(mGalleryDetail.uploader);
|
||||
|
||||
|
||||
TextView category = (TextView)mRootView.findViewById(R.id.detail_category);
|
||||
category.setText(Ui.getCategoryText(mGalleryDetail.category));
|
||||
category.setBackgroundColor(Ui.getCategoryColor(mGalleryDetail.category));
|
||||
|
||||
|
||||
// Make rate and read button same width
|
||||
// Disable them for temp
|
||||
Ui.measureView(mReadButton);
|
||||
@@ -295,26 +293,26 @@ public class DetailSectionFragment extends Fragment
|
||||
}
|
||||
mReadButton.setEnabled(false);
|
||||
mRateButton.setEnabled(false);
|
||||
|
||||
|
||||
// get from cache
|
||||
if (getFromCache)
|
||||
layout(mGalleryDetail);
|
||||
else
|
||||
mClient.getMangaDetail(mUrl, mGalleryDetail, new MangaDetailGetListener());
|
||||
|
||||
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
|
||||
private void addPageItem(int page) {
|
||||
if (mActivity.isFinishing())
|
||||
return;
|
||||
|
||||
|
||||
if (page != mCurPage)
|
||||
return;
|
||||
|
||||
|
||||
mWaitPreviewList.setVisibility(View.GONE);
|
||||
mPreviewRefreshButton.setVisibility(View.GONE);
|
||||
|
||||
|
||||
PreviewList pageList = mGalleryDetail.previewLists[page];
|
||||
if (pageList == null) {
|
||||
Log.d(TAG, "WTF, I may check mangaDetail.pageLists[page] is not null");
|
||||
@@ -337,7 +335,7 @@ public class DetailSectionFragment extends Fragment
|
||||
public void onClick(View v) {
|
||||
// Add to read in Data
|
||||
mData.addRead(mGalleryDetail);
|
||||
|
||||
|
||||
Intent intent = new Intent(mActivity,
|
||||
MangaActivity.class);
|
||||
intent.putExtra("url", ((TextViewWithUrl) v).url);
|
||||
@@ -352,13 +350,13 @@ public class DetailSectionFragment extends Fragment
|
||||
ColorDrawable white = new ColorDrawable(Color.TRANSPARENT);
|
||||
white.setBounds(0, 0, item.width, item.height);
|
||||
tvu.setCompoundDrawables(null, white, null, null);
|
||||
|
||||
|
||||
AutoWrapLayout.LayoutParams lp = new AutoWrapLayout.LayoutParams();
|
||||
lp.leftMargin = Ui.dp2pix(8);
|
||||
lp.topMargin = Ui.dp2pix(8);
|
||||
lp.rightMargin = Ui.dp2pix(8);
|
||||
lp.bottomMargin = Ui.dp2pix(8);
|
||||
|
||||
|
||||
mPreviewListLayout.addView(tvu, lp);
|
||||
index++;
|
||||
}
|
||||
@@ -369,12 +367,12 @@ public class DetailSectionFragment extends Fragment
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void refreshPageList() {
|
||||
mPreviewListLayout.removeAllViews();
|
||||
mWaitPreviewList.setVisibility(View.VISIBLE);
|
||||
mPreviewRefreshButton.setVisibility(View.GONE);
|
||||
|
||||
|
||||
mPreviewNumText.setText(String.format("%d / %d",
|
||||
mCurPage+1, mGalleryDetail.previewSum));
|
||||
|
||||
@@ -389,7 +387,7 @@ public class DetailSectionFragment extends Fragment
|
||||
public void onSuccess(Object checkFlag, PreviewList pageList) {
|
||||
if (mActivity.isFinishing())
|
||||
return;
|
||||
|
||||
|
||||
int page = (Integer)checkFlag;
|
||||
mGalleryDetail.previewLists[page] = pageList;
|
||||
addPageItem(page);
|
||||
@@ -400,14 +398,14 @@ public class DetailSectionFragment extends Fragment
|
||||
public void onFailure(Object checkFlag, String eMsg) {
|
||||
if (mActivity.isFinishing())
|
||||
return;
|
||||
|
||||
|
||||
int page = (Integer)checkFlag;
|
||||
if (page == mCurPage) {
|
||||
new SuperToast(mActivity).setIcon(R.drawable.ic_warning)
|
||||
.setMessage(eMsg)
|
||||
.show();
|
||||
mWaitPreviewList.setVisibility(View.GONE);
|
||||
mPreviewRefreshButton.setVisibility(View.VISIBLE);
|
||||
mPreviewRefreshButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -416,7 +414,7 @@ public class DetailSectionFragment extends Fragment
|
||||
mShowPreview = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private AlertDialog createGoToDialog() {
|
||||
return new DialogBuilder(mActivity).setTitle(R.string.jump)
|
||||
.setAdapter(new BaseAdapter() {
|
||||
@@ -436,7 +434,7 @@ public class DetailSectionFragment extends Fragment
|
||||
public View getView(int position, View convertView,
|
||||
ViewGroup parent) {
|
||||
LayoutInflater inflater = mActivity.getLayoutInflater();
|
||||
View view = (View)inflater.inflate(R.layout.list_item_text, null);
|
||||
View view = inflater.inflate(R.layout.list_item_text, null);
|
||||
TextView tv = (TextView)view.findViewById(android.R.id.text1);
|
||||
tv.setText(String.format(getString(R.string.some_page), position + 1));
|
||||
return tv;
|
||||
@@ -458,12 +456,11 @@ public class DetailSectionFragment extends Fragment
|
||||
}
|
||||
}).create();
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void addTags() {
|
||||
LinearLayout tagsLayout = (LinearLayout)mRootView.findViewById(R.id.tags_layout);
|
||||
LinkedHashMap<String, LinkedList<SimpleEntry<String, Integer>>> tagGroups =
|
||||
mGalleryDetail.tags;
|
||||
LinkedHashMap<String, LinkedList<String>> tagGroups = mGalleryDetail.tags;
|
||||
tagsLayout.removeAllViews();
|
||||
int x = Ui.dp2pix(4);
|
||||
int y = Ui.dp2pix(4);
|
||||
@@ -471,17 +468,17 @@ public class DetailSectionFragment extends Fragment
|
||||
// color
|
||||
boolean isRandomColor = Config.getRandomThemeColor();
|
||||
int color = Config.getThemeColor();
|
||||
|
||||
|
||||
// Get tag view resources
|
||||
int tagTextSize = resources.getDimensionPixelOffset(R.dimen.button_small_size);
|
||||
ColorStateList tagTextColor = resources.getColorStateList(R.color.blue_bn_text);
|
||||
int tagPaddingX = resources.getDimensionPixelOffset(R.dimen.button_tag_padding_x);
|
||||
int tagPaddingY = resources.getDimensionPixelOffset(R.dimen.button_tag_padding_y);
|
||||
for (Entry<String, LinkedList<SimpleEntry<String, Integer>>> tagGroup : tagGroups.entrySet()) {
|
||||
for (Entry<String, LinkedList<String>> tagGroup : tagGroups.entrySet()) {
|
||||
LinearLayout tagGroupLayout = new LinearLayout(mActivity);
|
||||
tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
AutoWrapLayout tagLayout = new AutoWrapLayout(mActivity);
|
||||
|
||||
|
||||
// Group name
|
||||
final String groupName = tagGroup.getKey();
|
||||
TextView groupNameView = new TextView(new ContextThemeWrapper(mActivity, R.style.TextTag));
|
||||
@@ -489,47 +486,28 @@ public class DetailSectionFragment extends Fragment
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
lp.setMargins(x, y, x, y);
|
||||
tagGroupLayout.addView(groupNameView, lp);
|
||||
|
||||
|
||||
// tags
|
||||
// get random color
|
||||
if (isRandomColor)
|
||||
color = Theme.getRandomDeepColor();
|
||||
for (SimpleEntry<String, Integer> tag : tagGroup.getValue()) {
|
||||
final String tagText = tag.getKey();
|
||||
for (final String tag : tagGroup.getValue()) {
|
||||
Button tagView = new Button(mActivity);
|
||||
tagView.setTextSize(TypedValue.COMPLEX_UNIT_PX, tagTextSize);
|
||||
tagView.setText(String.format("%s (%d)", tagText, tag.getValue()));
|
||||
tagView.setText(tag);
|
||||
tagView.setTextColor(tagTextColor);
|
||||
tagView.setBackgroundDrawable(Theme.getClickDrawable(mActivity, color));
|
||||
tagView.setPadding(tagPaddingX, tagPaddingY, tagPaddingX, tagPaddingY);
|
||||
tagView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AlertButton voteUp = new AlertButton(mActivity);
|
||||
voteUp.setText(getString(R.string.vote_up));
|
||||
voteUp.setOnClickListener(new SimpleVote(groupName, tagText, true));
|
||||
AlertButton voteDown = new AlertButton(mActivity);
|
||||
voteDown.setText(getString(R.string.vote_down));
|
||||
voteDown.setOnClickListener(new SimpleVote(groupName, tagText, false));
|
||||
AlertButton showTagged = new AlertButton(mActivity);
|
||||
showTagged.setText(getString(R.string.show_tagged));
|
||||
showTagged.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mTagDialog.dismiss();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(MangaListActivity.KEY_MODE,
|
||||
MangaListActivity.MODE_TAG);
|
||||
intent.putExtra(MangaListActivity.KEY_GROUP, groupName);
|
||||
intent.putExtra(MangaListActivity.KEY_TAG, tagText);
|
||||
mActivity.setResult(Activity.RESULT_OK, intent);
|
||||
mActivity.finish();
|
||||
}
|
||||
});
|
||||
mTagDialog = new ButtonsDialogBuilder(mActivity).setTitle(tagText)
|
||||
.addButton(voteUp).addButton(voteDown).addButton(showTagged)
|
||||
.create();
|
||||
mTagDialog.show();
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(MangaListActivity.KEY_MODE,
|
||||
MangaListActivity.MODE_TAG);
|
||||
intent.putExtra(MangaListActivity.KEY_GROUP, groupName);
|
||||
intent.putExtra(MangaListActivity.KEY_TAG, tag);
|
||||
mActivity.setResult(Activity.RESULT_OK, intent);
|
||||
mActivity.finish();
|
||||
}
|
||||
});
|
||||
AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
|
||||
@@ -539,7 +517,7 @@ public class DetailSectionFragment extends Fragment
|
||||
tagGroupLayout.addView(tagLayout);
|
||||
tagsLayout.addView(tagGroupLayout);
|
||||
}
|
||||
|
||||
|
||||
// Add tag
|
||||
if (isRandomColor)
|
||||
color = Theme.getRandomDeepColor();
|
||||
@@ -565,11 +543,11 @@ public class DetailSectionFragment extends Fragment
|
||||
lp.setMargins(x, y, x, y);
|
||||
tagsLayout.addView(addtagView, lp);
|
||||
}
|
||||
|
||||
|
||||
private void layout(GalleryDetail md) {
|
||||
if (mActivity.isFinishing())
|
||||
return;
|
||||
|
||||
|
||||
// Delete progress bar
|
||||
mWaitPb.setVisibility(View.GONE);
|
||||
|
||||
@@ -591,10 +569,10 @@ public class DetailSectionFragment extends Fragment
|
||||
mReadButton.setOnClickListener(this);
|
||||
mRateButton.setEnabled(true);
|
||||
mRateButton.setOnClickListener(this);
|
||||
|
||||
|
||||
RatingBar rate = (RatingBar)mRootView.findViewById(R.id.detail_rate);
|
||||
rate.setRating(mGalleryDetail.rating);
|
||||
|
||||
|
||||
TextSwitcher averagePeople = (TextSwitcher)mRootView.findViewById(R.id.detail_average_people);
|
||||
averagePeople.setFactory(new ViewFactory() {
|
||||
@Override
|
||||
@@ -605,21 +583,21 @@ public class DetailSectionFragment extends Fragment
|
||||
});
|
||||
averagePeople.setCurrentText(String.format("%.2f (%d)",
|
||||
mGalleryDetail.rating, mGalleryDetail.people));
|
||||
|
||||
|
||||
TextView posted = (TextView)mRootView.findViewById(R.id.detail_posted);
|
||||
posted.setText(mGalleryDetail.posted);
|
||||
|
||||
|
||||
TextView language = (TextView)mRootView.findViewById(R.id.detail_language);
|
||||
language.setText(String.format(getString(R.string.detail_language), mGalleryDetail.language));
|
||||
|
||||
|
||||
TextView pagesSize = (TextView)mRootView.findViewById(R.id.detail_pages_size);
|
||||
pagesSize.setText(String.format(getString(R.string.detail_pages_size),
|
||||
mGalleryDetail.pages, mGalleryDetail.size));
|
||||
|
||||
|
||||
addTags();
|
||||
|
||||
|
||||
mNormalView.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
// paper list
|
||||
if (mGalleryDetail.previewLists[0] != null) {
|
||||
mPreviewListMain.setVisibility(View.VISIBLE);
|
||||
@@ -628,7 +606,7 @@ public class DetailSectionFragment extends Fragment
|
||||
mPreviewNumText.setText(String.format("%d / %d",
|
||||
1, mGalleryDetail.previewSum));
|
||||
mPreviewRefreshButton.setOnClickListener(this);
|
||||
|
||||
|
||||
// Init go to dialog or disable it
|
||||
if (mGalleryDetail.previewSum > 1) {
|
||||
mGoToDialog = createGoToDialog();
|
||||
@@ -640,27 +618,27 @@ public class DetailSectionFragment extends Fragment
|
||||
mBackButton.setClickable(false);
|
||||
mFrontButton.setClickable(false);
|
||||
}
|
||||
|
||||
|
||||
mCurPage = 0;
|
||||
addPageItem(0);
|
||||
} else
|
||||
new SuperToast(mActivity)
|
||||
.setMessage(R.string.detail_preview_error)
|
||||
.show();
|
||||
|
||||
|
||||
// Set comments
|
||||
mActivity.setComments(mGalleryDetail.comments);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == mRateButton) {
|
||||
rate(mGalleryDetail.rating);
|
||||
|
||||
|
||||
} else if (v == mReadButton) {
|
||||
mData.addRead(mGalleryDetail);
|
||||
|
||||
|
||||
Intent intent = new Intent(mActivity,
|
||||
MangaActivity.class);
|
||||
intent.putExtra("url", mGalleryDetail.firstPage);
|
||||
@@ -669,7 +647,7 @@ public class DetailSectionFragment extends Fragment
|
||||
intent.putExtra("firstPage", 0);
|
||||
intent.putExtra("pageSum", mGalleryDetail.pages);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
} else if (v == mRefreshButton) {
|
||||
MangaDetailGetListener listener = new MangaDetailGetListener();
|
||||
mClient.getMangaDetail(mUrl, mGalleryDetail, listener);
|
||||
@@ -677,11 +655,11 @@ public class DetailSectionFragment extends Fragment
|
||||
mRefreshButton.setVisibility(View.GONE);
|
||||
// Add progressBar
|
||||
mWaitPb.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
} else if (v == mCancelButton
|
||||
| v == mKnownButton) {
|
||||
mActivity.finish();
|
||||
|
||||
|
||||
} else if (v == mOnceButton) {
|
||||
// TODO create a class uri
|
||||
MangaDetailGetListener listener = new MangaDetailGetListener();
|
||||
@@ -690,7 +668,7 @@ public class DetailSectionFragment extends Fragment
|
||||
mOffensiveView.setVisibility(View.GONE);
|
||||
// Add progressBar
|
||||
mWaitPb.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
} else if (v == mEveryButton) {
|
||||
MangaDetailGetListener listener = new MangaDetailGetListener();
|
||||
mClient.getMangaDetail(mUrl + "&nw=always", mGalleryDetail, listener);
|
||||
@@ -698,32 +676,32 @@ public class DetailSectionFragment extends Fragment
|
||||
mOffensiveView.setVisibility(View.GONE);
|
||||
// Add progressBar
|
||||
mWaitPb.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
} else if (v == mBackButton) {
|
||||
if (mCurPage <= 0)
|
||||
return;
|
||||
mCurPage--;
|
||||
refreshPageList();
|
||||
|
||||
|
||||
} else if (v == mFrontButton) {
|
||||
if (mCurPage >= mGalleryDetail.previewSum - 1)
|
||||
return;
|
||||
mCurPage++;
|
||||
refreshPageList();
|
||||
|
||||
|
||||
} else if (v == mPreviewRefreshButton) {
|
||||
refreshPageList();
|
||||
|
||||
|
||||
} else if (v == mPreviewNumText) {
|
||||
mGoToDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int getSendableRating(float ratingFloat) {
|
||||
float dr = ratingFloat*2;
|
||||
float dr = ratingFloat*2;
|
||||
return (int)(dr + 0.5);
|
||||
}
|
||||
|
||||
|
||||
public void rate(float defaultRating) {
|
||||
View view = mActivity.getLayoutInflater().inflate(R.layout.rate, null);
|
||||
final TextView tv = (TextView)view.findViewById(R.id.rate_text);
|
||||
@@ -763,7 +741,7 @@ public class DetailSectionFragment extends Fragment
|
||||
//Reset start
|
||||
RatingBar rate = (RatingBar)mRootView.findViewById(R.id.detail_rate);
|
||||
rate.setRating(mGalleryDetail.rating);
|
||||
|
||||
|
||||
TextSwitcher averagePeople = (TextSwitcher)
|
||||
mRootView.findViewById(R.id.detail_average_people);
|
||||
averagePeople.setText(String.format("%.2f (%d)",
|
||||
@@ -787,25 +765,25 @@ public class DetailSectionFragment extends Fragment
|
||||
}
|
||||
}).create().show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Comment> getComments() {
|
||||
if (mGalleryDetail == null)
|
||||
return null;
|
||||
else
|
||||
return mGalleryDetail.comments;
|
||||
}
|
||||
|
||||
|
||||
private class TextViewWithUrl extends TextView {
|
||||
private String url;
|
||||
private final String url;
|
||||
|
||||
public TextViewWithUrl(Context context, String url) {
|
||||
super(context);
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class MangaDetailGetListener
|
||||
implements EhClient.OnGetMangaDetailListener {
|
||||
@Override
|
||||
@@ -813,7 +791,7 @@ public class DetailSectionFragment extends Fragment
|
||||
Cache.mdCache.put(String.valueOf(mGalleryDetail.gid), md);
|
||||
layout(md);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(String eMsg) {
|
||||
// Delete progress bar
|
||||
@@ -840,11 +818,11 @@ public class DetailSectionFragment extends Fragment
|
||||
mWaitPreviewList.setVisibility(View.GONE);
|
||||
mPreviewRefreshButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
private void addPageImage(int page, int rowIndex, Bitmap bitmap) {
|
||||
if (mActivity.isFinishing())
|
||||
return;
|
||||
|
||||
|
||||
if (page != mCurPage)
|
||||
return;
|
||||
PreviewList pageList = mGalleryDetail.previewLists[page];
|
||||
@@ -852,46 +830,46 @@ public class DetailSectionFragment extends Fragment
|
||||
Log.d(TAG, "WTF, I may check mangaDetail.pageLists[page] is not null");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int maxWidth = bitmap.getWidth();
|
||||
int maxHeight = bitmap.getHeight();
|
||||
|
||||
|
||||
PreviewList.Row row = pageList.rowArray.get(rowIndex);
|
||||
ArrayList<PreviewList.Row.Item> items = row.itemArray;
|
||||
|
||||
|
||||
int startIndex = row.startIndex;
|
||||
int endIndex = startIndex + items.size();
|
||||
for(int i = startIndex ; i < endIndex; i++) {
|
||||
PreviewList.Row.Item item = items.get(i - startIndex);
|
||||
|
||||
|
||||
if (item.xOffset + item.width > maxWidth)
|
||||
item.width = maxWidth - item.xOffset;
|
||||
if (item.yOffset + item.height > maxHeight)
|
||||
item.height = maxHeight - item.yOffset;
|
||||
|
||||
|
||||
BitmapDrawable bitmapDrawable = new BitmapDrawable(
|
||||
getResources(), Bitmap.createBitmap(bitmap,
|
||||
item.xOffset, item.yOffset, item.width, item.height));
|
||||
bitmapDrawable.setBounds(0, 0, item.width, item.height);
|
||||
|
||||
|
||||
TextViewWithUrl tvu = (TextViewWithUrl)mPreviewListLayout.getChildAt(i);
|
||||
tvu.setCompoundDrawables(null, bitmapDrawable, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class SimpleVote implements View.OnClickListener {
|
||||
|
||||
private String groupName;
|
||||
private String tagText;
|
||||
private boolean isUp;
|
||||
|
||||
|
||||
private final String groupName;
|
||||
private final String tagText;
|
||||
private final boolean isUp;
|
||||
|
||||
public SimpleVote(String groupName, String tagText, boolean isUp) {
|
||||
this.groupName = groupName;
|
||||
this.tagText = tagText;
|
||||
this.isUp = isUp;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
((AlertButton)v).dialog.dismiss();
|
||||
@@ -899,12 +877,12 @@ public class DetailSectionFragment extends Fragment
|
||||
groupName, tagText, isUp, new SimpleVoteListener());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class SimpleVoteListener implements EhClient.OnVoteListener {
|
||||
@Override
|
||||
public void onSuccess(String tagPane) {
|
||||
new SuperToast(mActivity).setMessage(R.string.vote_succeeded).show();
|
||||
|
||||
|
||||
DetailParser parser = new DetailParser();
|
||||
parser.setMode(DetailParser.TAG);
|
||||
if (parser.parser(tagPane) == DetailParser.TAG) {
|
||||
|
||||
Reference in new issue
Block a user