Search in sources :

Example 6 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class MediaListFragment method onItemClick.

/**
 * When the target view from {@link View.OnClickListener}
 * is clicked from a view holder this method will be called
 *
 * @param target view that has been clicked
 * @param data   the model that at the click index
 */
@Override
public void onItemClick(View target, MediaList data) {
    switch(target.getId()) {
        case R.id.series_image:
            MediaBase mediaBase = data.getMedia();
            Intent intent = new Intent(getActivity(), MediaActivity.class);
            intent.putExtra(KeyUtil.arg_id, data.getMediaId());
            intent.putExtra(KeyUtil.arg_mediaType, mediaBase.getType());
            CompatUtil.startRevealAnim(getActivity(), target, intent);
            break;
    }
}
Also used : Intent(android.content.Intent) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase)

Example 7 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class GroupingUtil method groupMediaByFormat.

/**
 * Groups media by the media format, assuming that the media has be sorted by format
 * @see KeyUtil.MediaFormat
 * <br/>
 *
 * Only to be used when the sort type is @{@link KeyUtil.MediaSort#FORMAT}
 * which is the default sort type for the request @{@link KeyUtil#STAFF_MEDIA_REQ}
 * <br/>
 *
 * @param edges The potential external model response which needs to be grouped
 * @param model The current model item/s containing all data minus current mediaItems
 */
public static List<EntityGroup> groupMediaByFormat(@NonNull List<MediaBase> edges, @Nullable List<EntityGroup> model) {
    List<EntityGroup> entityMap = new ArrayList<>();
    Map<String, List<MediaBase>> map = Stream.of(edges).filter(value -> !TextUtils.isEmpty(value.getFormat())).collect(Collectors.groupingBy(MediaBase::getFormat));
    for (Map.Entry<String, List<MediaBase>> entry : CompatUtil.getKeyFilteredMap(map)) {
        EntityHeader entityHeader = new EntityHeader(entry.getKey(), entry.getValue().size());
        if (model == null || !model.contains(entityHeader))
            entityMap.add(entityHeader);
        entityMap.addAll(entry.getValue());
    }
    return entityMap;
}
Also used : StaffEdge(com.mxt.anitrend.model.entity.anilist.edge.StaffEdge) Collectors(com.annimon.stream.Collectors) Stream(com.annimon.stream.Stream) CharacterActorsFragment(com.mxt.anitrend.view.fragment.group.CharacterActorsFragment) MediaEdge(com.mxt.anitrend.model.entity.anilist.edge.MediaEdge) StaffBase(com.mxt.anitrend.model.entity.base.StaffBase) EdgeContainer(com.mxt.anitrend.model.entity.container.body.EdgeContainer) EntityHeader(com.mxt.anitrend.model.entity.group.EntityHeader) TextUtils(android.text.TextUtils) NonNull(android.support.annotation.NonNull) CharacterEdge(com.mxt.anitrend.model.entity.anilist.edge.CharacterEdge) EntityGroup(com.mxt.anitrend.model.entity.group.EntityGroup) ArrayList(java.util.ArrayList) List(java.util.List) MediaBase(com.mxt.anitrend.model.entity.base.MediaBase) Map(java.util.Map) Nullable(android.support.annotation.Nullable) EntityHeader(com.mxt.anitrend.model.entity.group.EntityHeader) EntityGroup(com.mxt.anitrend.model.entity.group.EntityGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 8 with MediaBase

use of com.mxt.anitrend.model.entity.base.MediaBase in project anitrend-app by AniTrend.

the class SeriesProgressTextView method setSeriesModel.

public void setSeriesModel(MediaList mediaList, boolean isCurrentUser) {
    MediaBase model = mediaList.getMedia();
    if (MediaUtil.isAnimeType(model)) {
        if (CompatUtil.equals(model.getStatus(), KeyUtil.NOT_YET_RELEASED))
            setText(R.string.TBA);
        else {
            if (isCurrentUser && !MediaUtil.isIncrementLimitReached(mediaList))
                setText(String.format(Locale.getDefault(), "%s/%s +", mediaList.getProgress(), model.getEpisodes() < 1 ? "?" : model.getEpisodes()));
            else
                setText(String.format(Locale.getDefault(), "%s/%s", mediaList.getProgress(), model.getEpisodes() < 1 ? "?" : model.getEpisodes()));
        }
    } else if (MediaUtil.isMangaType(model)) {
        if (CompatUtil.equals(model.getStatus(), KeyUtil.NOT_YET_RELEASED))
            setText(R.string.TBA);
        else {
            if (isCurrentUser && !MediaUtil.isIncrementLimitReached(mediaList))
                setText(String.format(Locale.getDefault(), "%s/%s +", mediaList.getProgress(), model.getChapters() < 1 ? "?" : model.getChapters()));
            else
                setText(String.format(Locale.getDefault(), "%s/%s", mediaList.getProgress(), model.getChapters() < 1 ? "?" : model.getChapters()));
        }
    }
}
Also used : MediaBase(com.mxt.anitrend.model.entity.base.MediaBase)

Aggregations

MediaBase (com.mxt.anitrend.model.entity.base.MediaBase)8 Intent (android.content.Intent)5 QueryContainerBuilder (com.mxt.anitrend.model.entity.container.request.QueryContainerBuilder)4 MediaActivity (com.mxt.anitrend.view.activity.detail.MediaActivity)4 EntityGroup (com.mxt.anitrend.model.entity.group.EntityGroup)3 ProfileActivity (com.mxt.anitrend.view.activity.detail.ProfileActivity)3 UserBase (com.mxt.anitrend.model.entity.base.UserBase)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 TextUtils (android.text.TextUtils)1 View (android.view.View)1 Filter (android.widget.Filter)1 Collectors (com.annimon.stream.Collectors)1 Stream (com.annimon.stream.Stream)1 GroupActorAdapter (com.mxt.anitrend.adapter.recycler.group.GroupActorAdapter)1 MediaList (com.mxt.anitrend.model.entity.anilist.MediaList)1 CharacterEdge (com.mxt.anitrend.model.entity.anilist.edge.CharacterEdge)1 MediaEdge (com.mxt.anitrend.model.entity.anilist.edge.MediaEdge)1