Search in sources :

Example 1 with TeamViewModel

use of com.thebluealliance.androidclient.viewmodels.TeamViewModel 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 2 with TeamViewModel

use of com.thebluealliance.androidclient.viewmodels.TeamViewModel in project the-blue-alliance-android by the-blue-alliance.

the class TeamListFragment method initializeAdapterCreator.

@Override
public void initializeAdapterCreator(SmartAdapter.MultiAdaptersCreator creator) {
    creator.map(TeamViewModel.class, TeamItemView.class);
    creator.listener((actionId, item, position, view) -> {
        if (actionId == Interactions.TEAM_ITEM_CLICKED && item instanceof TeamViewModel) {
            TeamViewModel team = (TeamViewModel) item;
            startActivity(ViewTeamActivity.newInstance(getActivity(), team.getTeamKey()));
        }
    });
}
Also used : TeamViewModel(com.thebluealliance.androidclient.viewmodels.TeamViewModel)

Example 3 with TeamViewModel

use of com.thebluealliance.androidclient.viewmodels.TeamViewModel in project the-blue-alliance-android by the-blue-alliance.

the class EventTeamsFragment method initializeAdapterCreator.

@Override
public void initializeAdapterCreator(SmartAdapter.MultiAdaptersCreator creator) {
    creator.map(TeamViewModel.class, TeamItemView.class);
    creator.listener((actionId, item, position, view) -> {
        if (actionId == Interactions.TEAM_ITEM_CLICKED && item instanceof TeamViewModel) {
            TeamViewModel team = (TeamViewModel) item;
            Intent intent = TeamAtEventActivity.newInstance(getActivity(), mEventKey, team.getTeamKey());
            startActivity(intent);
            // Track the call
            AnalyticsHelper.sendClickUpdate(getActivity(), "team@event_click", "EventTeamsFragment", EventTeamHelper.generateKey(mEventKey, team.getTeamKey()));
        }
    });
}
Also used : TeamViewModel(com.thebluealliance.androidclient.viewmodels.TeamViewModel) Intent(android.content.Intent)

Example 4 with TeamViewModel

use of com.thebluealliance.androidclient.viewmodels.TeamViewModel in project the-blue-alliance-android by the-blue-alliance.

the class Team method renderToViewModel.

@Nullable
@Override
public TeamViewModel renderToViewModel(Context context, @Nullable @RenderType Integer renderType) {
    int safeRenderType = renderType == null ? RENDER_BASIC : renderType;
    TeamViewModel model = new TeamViewModel(getKey(), getTeamNumber(), getNickname(), getLocation());
    model.setShowLinkToTeamDetails(false);
    model.setShowMyTbaDetails(false);
    switch(safeRenderType) {
        case RENDER_BASIC:
            break;
        case RENDER_DETAILS_BUTTON:
            model.setShowLinkToTeamDetails(true);
            break;
        case RENDER_MYTBA_DETAILS:
            model.setShowMyTbaDetails(true);
            break;
    }
    return model;
}
Also used : TeamViewModel(com.thebluealliance.androidclient.viewmodels.TeamViewModel) Nullable(javax.annotation.Nullable)

Aggregations

TeamViewModel (com.thebluealliance.androidclient.viewmodels.TeamViewModel)4 Intent (android.content.Intent)1 Team (com.thebluealliance.androidclient.models.Team)1 Nullable (javax.annotation.Nullable)1