Search in sources :

Example 1 with SimpleItemCollection

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

the class BaseItemDataAdapter method bindItemCollectionListHolder.

protected void bindItemCollectionListHolder(RecyclerView.ViewHolder holder, T item, List<SimpleItemCollection> itemCollectionList, @NonNull List<Object> payloads) {
    if (payloads.isEmpty()) {
        bindItemCollectionListHolder(holder, item, itemCollectionList);
    } else {
        // noinspection unchecked
        for (List<Object> payload : (List<List<Object>>) (Object) payloads) {
            int position = (int) payload.get(0);
            SimpleItemCollection newItemCollection = (SimpleItemCollection) CollectionUtils.getOrNull(payload, 1);
            bindItemCollectionListHolder(holder, position, newItemCollection);
        }
    }
}
Also used : List(java.util.List) SimpleItemCollection(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection)

Example 2 with SimpleItemCollection

use of me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection 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 3 with SimpleItemCollection

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

the class ItemCollectionListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
    SimpleItemCollection itemCollection = getItem(position);
    ImageUtils.loadAvatar(holder.avatarImage, itemCollection.user.avatar);
    holder.avatarImage.setOnClickListener(view -> {
        Context context = view.getContext();
        context.startActivity(ProfileActivity.makeIntent(itemCollection.user, context));
    });
    holder.nameText.setText(itemCollection.user.name);
    boolean hasRating = itemCollection.rating != null;
    ViewUtils.setVisibleOrGone(holder.ratingBar, hasRating);
    if (hasRating) {
        holder.ratingBar.setRating(itemCollection.rating.getRatingBarRating());
    }
    holder.dateText.setText(TimeUtils.formatDate(TimeUtils.parseDoubanDateTime(itemCollection.createTime), holder.dateText.getContext()));
    String voteCount = itemCollection.voteCount > 0 ? holder.voteCountText.getContext().getString(R.string.item_collection_vote_count_format, itemCollection.voteCount) : null;
    holder.voteCountText.setText(voteCount);
    holder.voteLayout.setActivated(itemCollection.isVoted);
    holder.voteLayout.setEnabled(!VoteItemCollectionManager.getInstance().isWriting(itemCollection.id));
    holder.voteLayout.setOnClickListener(view -> VoteItemCollectionManager.getInstance().write(mItemType, mItemId, itemCollection, view.getContext()));
    holder.commentText.setText(itemCollection.comment);
    holder.itemView.setOnLongClickListener(view -> {
        mListener.copyText(itemCollection.comment);
        return true;
    });
}
Also used : Context(android.content.Context) SimpleItemCollection(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection)

Example 4 with SimpleItemCollection

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

the class ItemCollectionListResource method onItemCollectionUpdated.

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

Example 5 with SimpleItemCollection

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

the class ItemCollectionFragment method isChanged.

private boolean isChanged() {
    SimpleItemCollection collection = mItem.collection;
    ItemCollectionState state = getState();
    if (collection != null) {
        boolean equalsExtraState = mExtraState != null && state == mExtraState;
        boolean equalsCollectionState = state == collection.getState();
        if (!(equalsExtraState || equalsCollectionState)) {
            return true;
        }
    }
    if (state != ItemCollectionState.TODO) {
        float originalRating = collection != null && collection.rating != null ? collection.rating.getRatingBarRating() : 0;
        float rating = mRatingBar.getRating();
        if (rating != originalRating) {
            return true;
        }
    }
    List<String> tags = getTags();
    List<String> originalTags = collection != null ? collection.tags : Collections.emptyList();
    if (!ObjectsCompat.equals(tags, originalTags)) {
        return true;
    }
    String comment = mCommentEdit.getText().toString();
    String originalComment = collection != null ? MoreTextUtils.nullToEmpty(collection.comment) : "";
    if (!TextUtils.equals(comment, originalComment)) {
        return true;
    }
    return false;
}
Also used : SimpleItemCollection(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection) ItemCollectionState(me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState)

Aggregations

SimpleItemCollection (me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection)7 Context (android.content.Context)4 List (java.util.List)3 CollectableItem (me.zhanghai.android.douya.network.api.info.frodo.CollectableItem)3 BindDimen (butterknife.BindDimen)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 Doulist (me.zhanghai.android.douya.network.api.info.frodo.Doulist)2 ItemAwardItem (me.zhanghai.android.douya.network.api.info.frodo.ItemAwardItem)2 ItemCollectionState (me.zhanghai.android.douya.network.api.info.frodo.ItemCollectionState)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 SimpleItemForumTopic (me.zhanghai.android.douya.network.api.info.frodo.SimpleItemForumTopic)2 SimpleReview (me.zhanghai.android.douya.network.api.info.frodo.SimpleReview)2 BarrierAdapter (me.zhanghai.android.douya.ui.BarrierAdapter)2