Search in sources :

Example 1 with MediaEdge

use of com.mxt.anitrend.model.entity.anilist.edge.MediaEdge in project anitrend-app by AniTrend.

the class GroupingUtil method groupMediaByRelationType.

public static List<EntityGroup> groupMediaByRelationType(List<MediaEdge> edges) {
    List<EntityGroup> entityMap = new ArrayList<>();
    for (MediaEdge edge : edges) {
        EntityHeader entityHeader = new EntityHeader(edge.getRelationType());
        if (!entityMap.contains(entityHeader))
            entityMap.add(entityHeader);
        else {
            entityHeader.setSize(entityHeader.getSize() + 1);
            entityMap.add(edge.getNode());
        }
    }
    return entityMap;
}
Also used : EntityHeader(com.mxt.anitrend.model.entity.group.EntityHeader) EntityGroup(com.mxt.anitrend.model.entity.group.EntityGroup) ArrayList(java.util.ArrayList) MediaEdge(com.mxt.anitrend.model.entity.anilist.edge.MediaEdge)

Example 2 with MediaEdge

use of com.mxt.anitrend.model.entity.anilist.edge.MediaEdge in project anitrend-app by AniTrend.

the class GroupingUtil method groupActorMediaEdge.

/**
 * Groups edge container items their media/node and the character role
 * N.B. In this use case the main model is not used to check for existence
 * of a given role because the voiceActors and characterRoles are grouped by media
 * <br/>
 *
 * @see CharacterActorsFragment restricted and should only be used by this
 * @see EdgeContainer
 * <br/>
 *
 * @param edges The potential external model response which needs to be grouped
 */
public static List<EntityGroup> groupActorMediaEdge(List<MediaEdge> edges) {
    List<EntityGroup> entityMap = new ArrayList<>();
    for (MediaEdge edge : edges) {
        if (edge.getNode() != null) {
            if (!TextUtils.isEmpty(edge.getCharacterRole()))
                edge.getNode().setSubGroupTitle(edge.getCharacterRole());
            edge.getNode().setContentType(KeyUtil.RECYCLER_TYPE_HEADER);
            entityMap.add(edge.getNode());
        }
        if (!CompatUtil.isEmpty(edge.getVoiceActors()))
            entityMap.addAll(edge.getVoiceActors());
    }
    return entityMap;
}
Also used : EntityGroup(com.mxt.anitrend.model.entity.group.EntityGroup) ArrayList(java.util.ArrayList) MediaEdge(com.mxt.anitrend.model.entity.anilist.edge.MediaEdge)

Aggregations

MediaEdge (com.mxt.anitrend.model.entity.anilist.edge.MediaEdge)2 EntityGroup (com.mxt.anitrend.model.entity.group.EntityGroup)2 ArrayList (java.util.ArrayList)2 EntityHeader (com.mxt.anitrend.model.entity.group.EntityHeader)1