Search in sources :

Example 1 with SimpleReview

use of me.zhanghai.android.douya.network.api.info.frodo.SimpleReview in project Douya by DreaminginCodeZH.

the class MovieFragment method update.

private void update(Movie movie, Rating rating, List<Photo> photoList, List<SimpleCelebrity> celebrityList, List<ItemAwardItem> awardList, List<SimpleItemCollection> itemCollectionList, List<SimpleReview> reviewList, List<SimpleItemForumTopic> forumTopicList, List<CollectableItem> recommendationList, List<Doulist> relatedDoulistList) {
    if (movie != null) {
        super.updateWithSimpleItem(movie);
    }
    if (movie == null || photoList == null) {
        return;
    }
    if (!mBackdropBound) {
        boolean hasTrailer = movie.trailer != null;
        mExcludeFirstPhoto = false;
        String backdropUrl = null;
        if (hasTrailer) {
            backdropUrl = movie.trailer.coverUrl;
            mBackdropLayout.setOnClickListener(view -> {
                // TODO
                UriHandler.open(movie.trailer.videoUrl, view.getContext());
            });
        } else if (!photoList.isEmpty()) {
            backdropUrl = photoList.get(0).getLargeUrl();
            mExcludeFirstPhoto = true;
            mBackdropLayout.setOnClickListener(view -> {
                // TODO
                Context context = view.getContext();
                context.startActivity(GalleryActivity.makeImageListIntent(photoList, 0, context));
            });
        } else if (movie.poster != null) {
            backdropUrl = movie.poster.getLargeUrl();
            mBackdropLayout.setOnClickListener(view -> {
                // TODO
                Context context = view.getContext();
                context.startActivity(GalleryActivity.makeIntent(movie.poster, context));
            });
        } else if (movie.cover != null) {
            backdropUrl = movie.cover.getLargeUrl();
            mBackdropLayout.setOnClickListener(view -> {
                // TODO
                Context context = view.getContext();
                context.startActivity(GalleryActivity.makeIntent(movie.cover, context));
            });
        }
        if (backdropUrl != null) {
            ImageUtils.loadItemBackdropAndFadeIn(mBackdropImage, backdropUrl, hasTrailer ? mBackdropPlayImage : null);
        } else {
            mBackdropImage.setBackgroundColor(movie.getThemeColor());
            ViewUtils.fadeIn(mBackdropImage);
        }
        mBackdropBound = true;
    }
    mAdapter.setData(new MovieDataAdapter.Data(movie, rating, photoList, mExcludeFirstPhoto, celebrityList, awardList, itemCollectionList, reviewList, forumTopicList, recommendationList, relatedDoulistList));
    if (mAdapter.getItemCount() > 0) {
        mContentStateLayout.setLoaded(true);
    }
}
Also used : SimpleReview(me.zhanghai.android.douya.network.api.info.frodo.SimpleReview) Context(android.content.Context) UncollectItemManager(me.zhanghai.android.douya.item.content.UncollectItemManager) UriHandler(me.zhanghai.android.douya.link.UriHandler) GalleryActivity(me.zhanghai.android.douya.gallery.ui.GalleryActivity) BaseItemFragmentResource(me.zhanghai.android.douya.item.content.BaseItemFragmentResource) CollectableItem(me.zhanghai.android.douya.network.api.info.frodo.CollectableItem) CopyTextDialogFragment(me.zhanghai.android.douya.ui.CopyTextDialogFragment) BindDimen(butterknife.BindDimen) Doulist(me.zhanghai.android.douya.network.api.info.frodo.Doulist) Rating(me.zhanghai.android.douya.network.api.info.frodo.Rating) ImageUtils(me.zhanghai.android.douya.util.ImageUtils) SimpleMovie(me.zhanghai.android.douya.network.api.info.frodo.SimpleMovie) ViewUtils(me.zhanghai.android.douya.util.ViewUtils) ConfirmUncollectItemDialogFragment(me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment) MovieFragmentResource(me.zhanghai.android.douya.item.content.MovieFragmentResource) ItemAwardItem(me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem) Movie(me.zhanghai.android.douya.network.api.info.frodo.Movie) SimpleCelebrity(me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity) BarrierAdapter(me.zhanghai.android.douya.ui.BarrierAdapter) R(me.zhanghai.android.douya.R) DoubanUtils(me.zhanghai.android.douya.util.DoubanUtils) List(java.util.List) SimpleItemForumTopic(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic) SimpleItemCollection(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection) Photo(me.zhanghai.android.douya.network.api.info.frodo.Photo) Context(android.content.Context)

Example 2 with SimpleReview

use of me.zhanghai.android.douya.network.api.info.frodo.SimpleReview in project Douya by DreaminginCodeZH.

the class ReviewListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    SimpleReview review = getItem(position);
    ImageUtils.loadAvatar(holder.avatarImage, review.author.avatar);
    holder.titleText.setText(review.title);
    holder.nameText.setText(review.author.name);
    boolean hasRating = review.rating != null;
    ViewUtils.setVisibleOrGone(holder.ratingBar, hasRating);
    if (hasRating) {
        holder.ratingBar.setRating(review.rating.getRatingBarRating());
    }
    String usefulness = holder.usefulnessText.getContext().getString(R.string.item_review_usefulness_format, review.usefulCount, review.usefulCount + review.uselessCount);
    holder.usefulnessText.setText(usefulness);
    holder.abstractText.setText(review.abstract_);
    holder.itemView.setOnClickListener(view -> {
        // TODO
        UriHandler.open(review.url, view.getContext());
    });
}
Also used : SimpleReview(me.zhanghai.android.douya.network.api.info.frodo.SimpleReview)

Example 3 with SimpleReview

use of me.zhanghai.android.douya.network.api.info.frodo.SimpleReview in project Douya by DreaminginCodeZH.

the class BaseReviewListResource method onReviewUpdated.

@Subscribe(threadMode = ThreadMode.POSTING)
public void onReviewUpdated(ReviewUpdatedEvent event) {
    if (event.isFromMyself(this) || isEmpty()) {
        return;
    }
    List<SimpleReview> reviewList = get();
    for (int i = 0, size = reviewList.size(); i < size; ++i) {
        SimpleReview review = reviewList.get(i);
        if (review.id == event.review.id) {
            reviewList.set(i, event.review);
            getListener().onReviewChanged(getRequestCode(), i, reviewList.get(i));
        }
    }
}
Also used : SimpleReview(me.zhanghai.android.douya.network.api.info.frodo.SimpleReview) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 4 with SimpleReview

use of me.zhanghai.android.douya.network.api.info.frodo.SimpleReview in project Douya by DreaminginCodeZH.

the class GameFragment method update.

private void update(Game game, Rating rating, List<Photo> photoList, List<SimpleItemCollection> itemCollectionList, List<SimpleReview> gameGuideList, List<SimpleReview> reviewList, List<SimpleItemForumTopic> forumTopicList, List<CollectableItem> recommendationList, List<Doulist> relatedDoulistList) {
    if (game != null) {
        super.updateWithSimpleItem(game);
    }
    if (game == null || photoList == null) {
        return;
    }
    if (!mBackdropBound) {
        // TODO: Add game videos like movie trailer.
        mExcludeFirstPhoto = false;
        String backdropUrl = null;
        if (!photoList.isEmpty()) {
            backdropUrl = photoList.get(0).getLargeUrl();
            mExcludeFirstPhoto = true;
            mBackdropLayout.setOnClickListener(view -> {
                // TODO
                Context context = view.getContext();
                context.startActivity(GalleryActivity.makeImageListIntent(photoList, 0, context));
            });
        } else if (game.cover != null) {
            backdropUrl = game.cover.getLargeUrl();
            mBackdropLayout.setOnClickListener(view -> {
                // TODO
                Context context = view.getContext();
                context.startActivity(GalleryActivity.makeIntent(game.cover, context));
            });
        }
        if (backdropUrl != null) {
            ImageUtils.loadItemBackdropAndFadeIn(mBackdropImage, backdropUrl, null);
        } else {
            mBackdropImage.setBackgroundColor(game.getThemeColor());
            ViewUtils.fadeIn(mBackdropImage);
        }
        mBackdropBound = true;
    }
    mAdapter.setData(new GameDataAdapter.Data(game, rating, photoList, mExcludeFirstPhoto, itemCollectionList, gameGuideList, reviewList, forumTopicList, recommendationList, relatedDoulistList));
    if (mAdapter.getItemCount() > 0) {
        mContentStateLayout.setLoaded(true);
    }
}
Also used : Context(android.content.Context) SimpleReview(me.zhanghai.android.douya.network.api.info.frodo.SimpleReview) Context(android.content.Context) UncollectItemManager(me.zhanghai.android.douya.item.content.UncollectItemManager) UriHandler(me.zhanghai.android.douya.link.UriHandler) GalleryActivity(me.zhanghai.android.douya.gallery.ui.GalleryActivity) BaseItemFragmentResource(me.zhanghai.android.douya.item.content.BaseItemFragmentResource) CollectableItem(me.zhanghai.android.douya.network.api.info.frodo.CollectableItem) CopyTextDialogFragment(me.zhanghai.android.douya.ui.CopyTextDialogFragment) BindDimen(butterknife.BindDimen) Doulist(me.zhanghai.android.douya.network.api.info.frodo.Doulist) Rating(me.zhanghai.android.douya.network.api.info.frodo.Rating) Game(me.zhanghai.android.douya.network.api.info.frodo.Game) ImageUtils(me.zhanghai.android.douya.util.ImageUtils) ViewUtils(me.zhanghai.android.douya.util.ViewUtils) ConfirmUncollectItemDialogFragment(me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment) ItemAwardItem(me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem) SimpleCelebrity(me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity) BarrierAdapter(me.zhanghai.android.douya.ui.BarrierAdapter) R(me.zhanghai.android.douya.R) GameFragmentResource(me.zhanghai.android.douya.item.content.GameFragmentResource) DoubanUtils(me.zhanghai.android.douya.util.DoubanUtils) List(java.util.List) SimpleItemForumTopic(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic) SimpleItemCollection(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection) Photo(me.zhanghai.android.douya.network.api.info.frodo.Photo) SimpleGame(me.zhanghai.android.douya.network.api.info.frodo.SimpleGame)

Example 5 with SimpleReview

use of me.zhanghai.android.douya.network.api.info.frodo.SimpleReview in project Douya by DreaminginCodeZH.

the class ProfileReviewsLayout method bind.

public void bind(final User user, List<SimpleReview> reviewList) {
    final Context context = getContext();
    OnClickListener viewMoreListener = new OnClickListener() {

        @Override
        public void onClick(View view) {
            // TODO
            UriHandler.open(StringUtils.formatUs("https://www.douban.com/people/%s/reviews", user.getIdOrUid()), context);
        // context.startActivity(ReviewListActivity.makeIntent(mUser, context));
        }
    };
    mTitleText.setOnClickListener(viewMoreListener);
    mViewMoreText.setOnClickListener(viewMoreListener);
    int i = 0;
    for (final SimpleReview review : reviewList) {
        if (i >= REVIEW_COUNT_MAX) {
            break;
        }
        if (i >= mReviewList.getChildCount()) {
            LayoutInflater.from(context).inflate(R.layout.profile_review_item, mReviewList);
        }
        View reviewLayout = mReviewList.getChildAt(i);
        ReviewLayoutHolder holder = (ReviewLayoutHolder) reviewLayout.getTag();
        if (holder == null) {
            holder = new ReviewLayoutHolder(reviewLayout);
            reviewLayout.setTag(holder);
            ViewUtils.setTextViewLinkClickable(holder.titleText);
        }
        String coverUrl = review.coverUrl;
        if (TextUtils.isEmpty(coverUrl) && review.item != null && review.item.cover != null) {
            coverUrl = review.item.cover.getMediumUrl();
        }
        if (!TextUtils.isEmpty(coverUrl)) {
            holder.coverImage.setVisibility(VISIBLE);
            ImageUtils.loadImage(holder.coverImage, coverUrl);
        } else {
            holder.coverImage.setVisibility(GONE);
        }
        holder.titleText.setText(review.title);
        holder.abstractText.setText(review.abstract_);
        reviewLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                // TODO
                UriHandler.open(StringUtils.formatUs("https://www.douban.com/review/%d", review.id), context);
            // context.startActivity(ReviewActivity.makeIntent(review, context));
            }
        });
        ++i;
    }
    ViewUtils.setVisibleOrGone(mReviewList, i != 0);
    ViewUtils.setVisibleOrGone(mEmptyView, i == 0);
    // if (mUser.reviewCount > i) {
    if (reviewList.size() > i) {
        mViewMoreText.setText(R.string.view_more);
    } else {
        mViewMoreText.setVisibility(GONE);
    }
    for (int count = mReviewList.getChildCount(); i < count; ++i) {
        ViewUtils.setVisibleOrGone(mReviewList.getChildAt(i), false);
    }
}
Also used : Context(android.content.Context) SimpleReview(me.zhanghai.android.douya.network.api.info.frodo.SimpleReview) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) FriendlyCardView(me.zhanghai.android.douya.ui.FriendlyCardView)

Aggregations

SimpleReview (me.zhanghai.android.douya.network.api.info.frodo.SimpleReview)7 Context (android.content.Context)3 BindDimen (butterknife.BindDimen)2 List (java.util.List)2 R (me.zhanghai.android.douya.R)2 GalleryActivity (me.zhanghai.android.douya.gallery.ui.GalleryActivity)2 BaseItemFragmentResource (me.zhanghai.android.douya.item.content.BaseItemFragmentResource)2 ConfirmUncollectItemDialogFragment (me.zhanghai.android.douya.item.content.ConfirmUncollectItemDialogFragment)2 UncollectItemManager (me.zhanghai.android.douya.item.content.UncollectItemManager)2 UriHandler (me.zhanghai.android.douya.link.UriHandler)2 CollectableItem (me.zhanghai.android.douya.network.api.info.frodo.CollectableItem)2 Doulist (me.zhanghai.android.douya.network.api.info.frodo.Doulist)2 ItemAwardItem (me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem)2 Photo (me.zhanghai.android.douya.network.api.info.frodo.Photo)2 Rating (me.zhanghai.android.douya.network.api.info.frodo.Rating)2 SimpleCelebrity (me.zhanghai.android.douya.network.api.info.frodo.SimpleCelebrity)2 SimpleItemCollection (me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection)2 SimpleItemForumTopic (me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic)2 BarrierAdapter (me.zhanghai.android.douya.ui.BarrierAdapter)2 CopyTextDialogFragment (me.zhanghai.android.douya.ui.CopyTextDialogFragment)2