Search in sources :

Example 1 with EventsTable

use of com.thebluealliance.androidclient.database.tables.EventsTable in project the-blue-alliance-android by the-blue-alliance.

the class TeamAtDistrictSummarySubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    EventsTable eventsTable = mDb.getEventsTable();
    mDataToBind.add(new LabelValueListItem(mResources.getString(R.string.district_point_rank), mAPIData.getRank() + Utilities.getOrdinalFor(mAPIData.getRank())));
    @Nullable IDistrictEventPoints event1Points = getEventPoints(mAPIData, 0);
    if (event1Points != null) {
        mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), event1Points, eventsTable, mResources));
    }
    @Nullable IDistrictEventPoints event2Points = getEventPoints(mAPIData, 1);
    if (event2Points != null) {
        mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), event2Points, eventsTable, mResources));
    }
    @Nullable IDistrictEventPoints cmpPoints = getEventPoints(mAPIData, 2);
    if (cmpPoints != null) {
        mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), cmpPoints, eventsTable, mResources));
    }
    if (mAPIData.getPointTotal() != null) {
        mDataToBind.add(new LabelValueListItem(mResources.getString(R.string.total_district_points), String.format(mResources.getString(R.string.district_points_format), mAPIData.getPointTotal())));
    }
    String actionBarTitle = String.format(mResources.getString(R.string.team_actionbar_title), mTeamKey.substring(3));
    String actionBarSubtitle = String.format("@ %1$s %2$s", mDistrictKey.substring(0, 4), mDistrictKey.substring(4).toUpperCase());
    mEventBus.post(new ActionBarTitleEvent(actionBarTitle, actionBarSubtitle));
}
Also used : LabelValueListItem(com.thebluealliance.androidclient.listitems.LabelValueListItem) IDistrictEventPoints(com.thebluealliance.api.model.IDistrictEventPoints) ActionBarTitleEvent(com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent) EventsTable(com.thebluealliance.androidclient.database.tables.EventsTable) Nullable(javax.annotation.Nullable)

Example 2 with EventsTable

use of com.thebluealliance.androidclient.database.tables.EventsTable in project the-blue-alliance-android by the-blue-alliance.

the class DatabaseMocker method mockEventsTable.

public static EventsTable mockEventsTable(Database database) {
    SQLiteDatabase db = mock(SQLiteDatabase.class);
    DistrictsTable districtsTable = new DistrictsTable(db, TBAAndroidModule.getGson());
    EventsTable table = new EventsTable(db, TBAAndroidModule.getGson(), districtsTable);
    when(database.getEventsTable()).thenReturn(table);
    when(database.getWritableDatabase()).thenReturn(db);
    return table;
}
Also used : DistrictsTable(com.thebluealliance.androidclient.database.tables.DistrictsTable) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) EventsTable(com.thebluealliance.androidclient.database.tables.EventsTable)

Aggregations

EventsTable (com.thebluealliance.androidclient.database.tables.EventsTable)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 DistrictsTable (com.thebluealliance.androidclient.database.tables.DistrictsTable)1 ActionBarTitleEvent (com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent)1 LabelValueListItem (com.thebluealliance.androidclient.listitems.LabelValueListItem)1 IDistrictEventPoints (com.thebluealliance.api.model.IDistrictEventPoints)1 Nullable (javax.annotation.Nullable)1