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;
}
}
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;
}
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()));
}
}
}
Aggregations