Search in sources :

Example 1 with PreviewSet

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));
    }
}
Also used : LoadImageView(com.hippo.widget.LoadImageView) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ObservedTextView(com.hippo.widget.ObservedTextView) AttrResources(com.hippo.android.resource.AttrResources) Resources(android.content.res.Resources) PreviewSet(com.hippo.ehviewer.client.data.PreviewSet) ImageView(android.widget.ImageView) LoadImageView(com.hippo.widget.LoadImageView) ProgressView(com.hippo.widget.ProgressView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ObservedTextView(com.hippo.widget.ObservedTextView) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 2 with PreviewSet

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);
            }
        }
    }
}
Also used : GalleryPageUrlParser(com.hippo.ehviewer.client.parser.GalleryPageUrlParser) PreviewSet(com.hippo.ehviewer.client.data.PreviewSet)

Example 3 with PreviewSet

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);
    }
}
Also used : ArrayList(java.util.ArrayList) PreviewSet(com.hippo.ehviewer.client.data.PreviewSet) SuppressLint(android.annotation.SuppressLint) GalleryPreview(com.hippo.ehviewer.client.data.GalleryPreview)

Aggregations

PreviewSet (com.hippo.ehviewer.client.data.PreviewSet)3 SuppressLint (android.annotation.SuppressLint)2 Resources (android.content.res.Resources)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 AttrResources (com.hippo.android.resource.AttrResources)1 GalleryPreview (com.hippo.ehviewer.client.data.GalleryPreview)1 GalleryPageUrlParser (com.hippo.ehviewer.client.parser.GalleryPageUrlParser)1 LoadImageView (com.hippo.widget.LoadImageView)1 ObservedTextView (com.hippo.widget.ObservedTextView)1 ProgressView (com.hippo.widget.ProgressView)1 ArrayList (java.util.ArrayList)1