use of com.hippo.ehviewer.client.data.PreviewSet in project EhViewer by seven332.
the class GalleryDetailScene method bindPreviews.
@SuppressLint("SetTextI18n")
private void bindPreviews(GalleryDetail gd) {
LayoutInflater inflater = getLayoutInflater2();
Resources resources = getResources2();
if (null == inflater || null == resources || null == mGridLayout || null == mPreviewText) {
return;
}
mGridLayout.removeAllViews();
PreviewSet previewSet = gd.previewSet;
if (gd.previewPages <= 0 || previewSet == null || previewSet.size() == 0) {
mPreviewText.setText(R.string.no_previews);
return;
} else if (gd.previewPages == 1) {
mPreviewText.setText(R.string.no_more_previews);
} else {
mPreviewText.setText(R.string.more_previews);
}
int columnWidth = resources.getDimensionPixelOffset(Settings.getThumbSizeResId());
mGridLayout.setColumnSize(columnWidth);
mGridLayout.setStrategy(SimpleGridAutoSpanLayout.STRATEGY_SUITABLE_SIZE);
for (int i = 0, size = previewSet.size(); i < size; i++) {
View view = inflater.inflate(R.layout.item_gallery_preview, mGridLayout, false);
mGridLayout.addView(view);
LoadImageView image = (LoadImageView) view.findViewById(R.id.image);
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(Integer.toString(previewSet.getPosition(i) + 1));
}
}
use of com.hippo.ehviewer.client.data.PreviewSet in project EhViewer by seven332.
the class SpiderQueen method readPreviews.
private void readPreviews(String body, int index, SpiderInfo spiderInfo) throws ParseException {
spiderInfo.pages = GalleryDetailParser.parsePages(body);
spiderInfo.previewPages = GalleryDetailParser.parsePreviewPages(body);
PreviewSet previewSet = GalleryDetailParser.parsePreviewSet(body);
if (previewSet.size() > 0) {
if (index == 0) {
spiderInfo.previewPerPage = previewSet.size();
} else {
spiderInfo.previewPerPage = previewSet.getPosition(0) / index;
}
}
for (int i = 0, n = previewSet.size(); i < n; i++) {
GalleryPageUrlParser.Result result = GalleryPageUrlParser.parse(previewSet.getPageUrlAt(i));
if (result != null) {
synchronized (mPTokenLock) {
spiderInfo.pTokenMap.put(result.page, result.pToken);
}
}
}
}
use of com.hippo.ehviewer.client.data.PreviewSet in project EhViewer by seven332.
the class GalleryPreviewsScene method onGetPreviewSetSuccess.
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++) {
list.add(previewSet.getGalleryPreview(mGalleryInfo.gid, i));
}
mHelper.onGetPageData(taskId, result.second, 0, list);
}
}
Aggregations