Search in sources :

Example 1 with Team

use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.

the class TeamInfoSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind = new TeamInfoBinder.Model();
    Map<MediaType, String> socialMediaByType = Utilities.getMapForPlatform(MediaType.class, String.class);
    Team team = mAPIData.team;
    List<Media> socialMedia = mAPIData.socialMedia;
    mDataToBind.teamKey = team.getKey();
    mDataToBind.fullName = team.getName();
    mDataToBind.nickname = team.getNickname();
    mDataToBind.teamNumber = team.getTeamNumber();
    mDataToBind.location = team.getLocation();
    if (team.getWebsite() != null) {
        mDataToBind.website = team.getWebsite();
    } else {
        mDataToBind.website = "";
    }
    if (team.getMotto() != null) {
        mDataToBind.motto = team.getMotto();
    } else {
        mDataToBind.motto = "";
    }
    // Separate social medias by type
    mDataToBind.socialMedia = socialMediaByType;
    for (int i = 0; socialMedia != null && i < socialMedia.size(); i++) {
        Media media = socialMedia.get(i);
        MediaType mediaType = MediaType.fromString(media.getType());
        socialMediaByType.put(mediaType, media.getForeignKey());
    }
    // CMP Pit Location Stuff
    mDataToBind.showPitLocation = PitLocationHelper.shouldShowPitLocation(mAppConfig);
    mDataToBind.pitLocation = PitLocationHelper.getPitLocation(mContext, team.getKey());
}
Also used : TeamInfoBinder(com.thebluealliance.androidclient.binders.TeamInfoBinder) Media(com.thebluealliance.androidclient.models.Media) MediaType(com.thebluealliance.androidclient.types.MediaType) Team(com.thebluealliance.androidclient.models.Team)

Example 2 with Team

use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.

the class TeamListRecyclerSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    Collections.sort(mAPIData, mComparator);
    for (int i = 0; i < mAPIData.size(); i++) {
        Team team = mAPIData.get(i);
        if (team == null) {
            continue;
        }
        TeamViewModel item = team.renderToViewModel(mContext, mRenderMode);
        if (item == null) {
            continue;
        }
        mDataToBind.add(item);
    }
}
Also used : TeamViewModel(com.thebluealliance.androidclient.viewmodels.TeamViewModel) Team(com.thebluealliance.androidclient.models.Team)

Example 3 with Team

use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.

the class TeamListSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    Collections.sort(mAPIData, mComparator);
    for (int i = 0; i < mAPIData.size(); i++) {
        Team team = mAPIData.get(i);
        if (team == null) {
            continue;
        }
        ListItem item = mRenderer.renderFromModel(team, mRenderMode);
        if (item == null) {
            continue;
        }
        mDataToBind.add(item);
    }
}
Also used : Team(com.thebluealliance.androidclient.models.Team) ListItem(com.thebluealliance.androidclient.listitems.ListItem)

Example 4 with Team

use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.

the class AwardsListSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    Map<String, Team> teams = Utilities.getMapForPlatform(String.class, Team.class);
    ArrayList<Award> sortedAwards = new ArrayList<>(mAPIData);
    Collections.sort(sortedAwards, AWARD_COMPARATOR);
    for (int i = 0; i < sortedAwards.size(); i++) {
        Award award = sortedAwards.get(i);
        if (award.getRecipientList() == null)
            continue;
        for (IAwardRecipient winner : award.getRecipientList()) {
            if (winner != null && winner.getTeamKey() != null) {
                String teamKey = winner.getTeamKey();
                Team team = mDb.getTeamsTable().get(teamKey);
                teams.put(teamKey, team);
            }
        }
        AwardRenderer.RenderArgs args = new AwardRenderer.RenderArgs(teams, mTeamKey);
        mDataToBind.add(mRenderer.renderFromModel(award, args));
    }
}
Also used : IAwardRecipient(com.thebluealliance.api.model.IAwardRecipient) Award(com.thebluealliance.androidclient.models.Award) ArrayList(java.util.ArrayList) Team(com.thebluealliance.androidclient.models.Team) AwardRenderer(com.thebluealliance.androidclient.renderers.AwardRenderer)

Example 5 with Team

use of com.thebluealliance.androidclient.models.Team in project the-blue-alliance-android by the-blue-alliance.

the class RankingsListSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    if (mAPIData == null || mAPIData.getRankings() == null || mAPIData.getRankings().isEmpty()) {
        return;
    }
    List<IRankingItem> rankings = mAPIData.getRankings();
    List<IRankingSortOrder> sortOrders = mAPIData.getSortOrderInfo();
    List<IRankingSortOrder> extraStats = mAPIData.getExtraStatsInfo();
    IRankingSortOrder firstSortInfo = sortOrders.remove(0);
    for (int i = 0; i < rankings.size(); i++) {
        IRankingItem row = rankings.get(i);
        /* Assume that the list of lists has rank first and team # second, always */
        String teamKey = row.getTeamKey();
        String rankingString;
        String rankingSummary;
        String record;
        @Nullable ITeamRecord teamRecord = row.getRecord();
        if (teamRecord != null) {
            record = "(" + RankingItem.TeamRecord.buildRecordString(teamRecord) + ")";
        } else {
            record = "";
        }
        // Remove the first sort item so we don't show duplicates
        Double firstSort = row.getSortOrders().remove(0);
        rankingSummary = mResources.getString(R.string.rank_item_summary, firstSortInfo.getName(), formatSortOrder(firstSortInfo, firstSort));
        rankingString = buildRankingString(row, sortOrders, extraStats, mResources, BOLD_TITLES | LINE_BREAKS);
        Team team = mDb.getTeamsTable().get(teamKey);
        String nickname;
        if (team != null) {
            nickname = team.getNickname();
        } else {
            nickname = "Team " + teamKey.substring(3);
        }
        mDataToBind.add(new TeamRankingViewModel(teamKey, nickname, // team number
        teamKey.substring(3), // rank
        row.getRank(), record, rankingSummary, rankingString));
    }
    mEventBus.post(new EventRankingsEvent(generateTopRanksString(mAPIData)));
}
Also used : ITeamRecord(com.thebluealliance.api.model.ITeamRecord) IRankingItem(com.thebluealliance.api.model.IRankingItem) EventRankingsEvent(com.thebluealliance.androidclient.eventbus.EventRankingsEvent) IRankingSortOrder(com.thebluealliance.api.model.IRankingSortOrder) Team(com.thebluealliance.androidclient.models.Team) RankingFormatter.buildRankingString(com.thebluealliance.androidclient.helpers.RankingFormatter.buildRankingString) TeamRankingViewModel(com.thebluealliance.androidclient.viewmodels.TeamRankingViewModel) Nullable(javax.annotation.Nullable)

Aggregations

Team (com.thebluealliance.androidclient.models.Team)28 ArrayList (java.util.ArrayList)7 Event (com.thebluealliance.androidclient.models.Event)6 EventTeam (com.thebluealliance.androidclient.models.EventTeam)5 Test (org.junit.Test)4 JsonObject (com.google.gson.JsonObject)3 ListItem (com.thebluealliance.androidclient.listitems.ListItem)3 Cursor (android.database.Cursor)2 WorkerThread (androidx.annotation.WorkerThread)2 JsonElement (com.google.gson.JsonElement)2 RankingFormatter.buildRankingString (com.thebluealliance.androidclient.helpers.RankingFormatter.buildRankingString)2 ModelListElement (com.thebluealliance.androidclient.listitems.ModelListElement)2 Match (com.thebluealliance.androidclient.models.Match)2 TeamRenderer (com.thebluealliance.androidclient.renderers.TeamRenderer)2 IAwardRecipient (com.thebluealliance.api.model.IAwardRecipient)2 Date (java.util.Date)2 Before (org.junit.Before)2 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1