Search in sources :

Example 1 with GalleryDetail

use of com.hippo.ehviewer.client.data.GalleryDetail in project EhViewer by seven332.

the class GalleryDetailScene method bindViewSecond.

private void bindViewSecond() {
    GalleryDetail gd = mGalleryDetail;
    if (gd == null) {
        return;
    }
    if (mThumb == null || mTitle == null || mUploader == null || mCategory == null || mLanguage == null || mPages == null || mSize == null || mPosted == null || mFavoredTimes == null || mRatingText == null || mRating == null || mTorrent == null) {
        return;
    }
    Resources resources = getResources2();
    Assert.assertNotNull(resources);
    mThumb.load(EhCacheKeyFactory.getThumbKey(gd.gid), gd.thumb);
    mTitle.setText(EhUtils.getSuitableTitle(gd));
    mUploader.setText(gd.uploader);
    mCategory.setText(EhUtils.getCategory(gd.category));
    mCategory.setTextColor(EhUtils.getCategoryColor(gd.category));
    updateDownloadText();
    mLanguage.setText(gd.language);
    mPages.setText(resources.getQuantityString(R.plurals.page_count, gd.pages, gd.pages));
    mSize.setText(gd.size);
    mPosted.setText(gd.posted);
    mFavoredTimes.setText(resources.getString(R.string.favored_times, gd.favoriteCount));
    mRatingText.setText(getAllRatingText(gd.rating, gd.ratingCount));
    mRating.setRating(gd.rating);
    updateFavoriteDrawable();
    mTorrent.setText(resources.getString(R.string.torrent_count, gd.torrentCount));
    bindTags(gd.tags);
    bindComments(gd.comments);
    bindPreviews(gd);
}
Also used : GalleryDetail(com.hippo.ehviewer.client.data.GalleryDetail) Resources(android.content.res.Resources)

Example 2 with GalleryDetail

use of com.hippo.ehviewer.client.data.GalleryDetail in project EhViewer by seven332.

the class GalleryInfoScene method handlerArgs.

private void handlerArgs(Bundle args) {
    if (args == null) {
        return;
    }
    GalleryDetail gd = args.getParcelable(KEY_GALLERY_DETAIL);
    if (gd == null) {
        return;
    }
    if (mKeys == null || mValues == null) {
        return;
    }
    Resources resources = getResources2();
    Assert.assertNotNull(resources);
    mKeys.add(resources.getString(R.string.header_key));
    mValues.add(resources.getString(R.string.header_value));
    mKeys.add(resources.getString(R.string.key_gid));
    mValues.add(Long.toString(gd.gid));
    mKeys.add(resources.getString(R.string.key_token));
    mValues.add(gd.token);
    mKeys.add(resources.getString(R.string.key_url));
    mValues.add(EhUrl.getGalleryDetailUrl(gd.gid, gd.token));
    mKeys.add(resources.getString(R.string.key_title));
    mValues.add(gd.title);
    mKeys.add(resources.getString(R.string.key_title_jpn));
    mValues.add(gd.titleJpn);
    mKeys.add(resources.getString(R.string.key_thumb));
    mValues.add(gd.thumb);
    mKeys.add(resources.getString(R.string.key_category));
    mValues.add(EhUtils.getCategory(gd.category));
    mKeys.add(resources.getString(R.string.key_uploader));
    mValues.add(gd.uploader);
    mKeys.add(resources.getString(R.string.key_posted));
    mValues.add(gd.posted);
    mKeys.add(resources.getString(R.string.key_parent));
    mValues.add(gd.parent);
    mKeys.add(resources.getString(R.string.key_visible));
    mValues.add(gd.visible);
    mKeys.add(resources.getString(R.string.key_language));
    mValues.add(gd.language);
    mKeys.add(resources.getString(R.string.key_pages));
    mValues.add(Integer.toString(gd.pages));
    mKeys.add(resources.getString(R.string.key_size));
    mValues.add(gd.size);
    mKeys.add(resources.getString(R.string.key_favorite_count));
    mValues.add(Integer.toString(gd.favoriteCount));
    mKeys.add(resources.getString(R.string.key_favorited));
    mValues.add(Boolean.toString(gd.isFavorited));
    mKeys.add(resources.getString(R.string.key_rating_count));
    mValues.add(Integer.toString(gd.ratingCount));
    mKeys.add(resources.getString(R.string.key_rating));
    mValues.add(Float.toString(gd.rating));
    mKeys.add(resources.getString(R.string.key_torrents));
    mValues.add(Integer.toString(gd.torrentCount));
    mKeys.add(resources.getString(R.string.key_torrent_url));
    mValues.add(gd.torrentUrl);
}
Also used : GalleryDetail(com.hippo.ehviewer.client.data.GalleryDetail) Resources(android.content.res.Resources)

Example 3 with GalleryDetail

use of com.hippo.ehviewer.client.data.GalleryDetail in project EhViewer by seven332.

the class GalleryDetailScene method updateFavoriteDrawable.

private void updateFavoriteDrawable() {
    GalleryDetail gd = mGalleryDetail;
    if (gd == null) {
        return;
    }
    if (mHeart == null || mHeartOutline == null) {
        return;
    }
    if (gd.isFavorited || EhDB.containLocalFavorites(gd.gid)) {
        mHeart.setVisibility(View.VISIBLE);
        mHeartOutline.setVisibility(View.GONE);
    } else {
        mHeart.setVisibility(View.GONE);
        mHeartOutline.setVisibility(View.VISIBLE);
    }
}
Also used : GalleryDetail(com.hippo.ehviewer.client.data.GalleryDetail)

Example 4 with GalleryDetail

use of com.hippo.ehviewer.client.data.GalleryDetail in project EhViewer by seven332.

the class GalleryDetailScene method showSimilarGalleryList.

private void showSimilarGalleryList() {
    GalleryDetail gd = mGalleryDetail;
    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();
        lub.setMode(ListUrlBuilder.MODE_TAG);
        lub.setKeyword("artist:" + artist);
        GalleryListScene.startScene(this, lub);
        return;
    }
    if (null != gd.uploader) {
        ListUrlBuilder lub = new ListUrlBuilder();
        lub.setMode(ListUrlBuilder.MODE_UPLOADER);
        lub.setKeyword(gd.uploader);
        GalleryListScene.startScene(this, lub);
    }
}
Also used : ListUrlBuilder(com.hippo.ehviewer.client.data.ListUrlBuilder) GalleryDetail(com.hippo.ehviewer.client.data.GalleryDetail)

Example 5 with GalleryDetail

use of com.hippo.ehviewer.client.data.GalleryDetail in project EhViewer by seven332.

the class GalleryDetailParser method parse.

public static GalleryDetail parse(String body) throws EhException {
    if (body.contains(OFFENSIVE_STRING)) {
        throw new OffensiveException();
    }
    if (body.contains(PINING_STRING)) {
        throw new PiningException();
    }
    // Error info
    Matcher m = PATTERN_ERROR.matcher(body);
    if (m.find()) {
        throw new EhException(m.group(1));
    }
    GalleryDetail galleryDetail = new GalleryDetail();
    Document document = Jsoup.parse(body);
    parseDetail(galleryDetail, document, body);
    galleryDetail.tags = parseTagGroups(document);
    galleryDetail.comments = parseComments(document);
    galleryDetail.previewPages = parsePreviewPages(document, body);
    galleryDetail.previewSet = parsePreviewSet(document, body);
    return galleryDetail;
}
Also used : EhException(com.hippo.ehviewer.client.exception.EhException) Matcher(java.util.regex.Matcher) PiningException(com.hippo.ehviewer.client.exception.PiningException) GalleryDetail(com.hippo.ehviewer.client.data.GalleryDetail) Document(org.jsoup.nodes.Document) OffensiveException(com.hippo.ehviewer.client.exception.OffensiveException)

Aggregations

GalleryDetail (com.hippo.ehviewer.client.data.GalleryDetail)5 Resources (android.content.res.Resources)2 ListUrlBuilder (com.hippo.ehviewer.client.data.ListUrlBuilder)1 EhException (com.hippo.ehviewer.client.exception.EhException)1 OffensiveException (com.hippo.ehviewer.client.exception.OffensiveException)1 PiningException (com.hippo.ehviewer.client.exception.PiningException)1 Matcher (java.util.regex.Matcher)1 Document (org.jsoup.nodes.Document)1