Search in sources :

Example 1 with Match

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

the class MatchBreakdownView2016Test method getView.

private MatchBreakdownView2016 getView(String matchJsonFile) {
    Match match = ModelMaker.getModel(Match.class, matchJsonFile);
    LayoutInflater inflater = LayoutInflater.from(InstrumentationRegistry.getTargetContext());
    View view = inflater.inflate(R.layout.fragment_match_breakdown, null, false);
    FrameLayout matchView = (FrameLayout) view.findViewById(R.id.match_breakdown);
    assertEquals(1, matchView.getChildCount());
    assertTrue(matchView.getChildAt(0) instanceof MatchBreakdownView2016);
    MatchBreakdownView2016 view2016 = (MatchBreakdownView2016) matchView.getChildAt(0);
    MatchType matchType = MatchType.fromKey(match.getKey());
    view2016.initWithData(matchType, match.getWinningAlliance(), match.getAlliances(), mGson.fromJson(match.getScoreBreakdown(), JsonObject.class));
    view2016.setVisibility(View.VISIBLE);
    // hide progress bar
    view.findViewById(R.id.progress).setVisibility(View.GONE);
    return view2016;
}
Also used : MatchType(com.thebluealliance.androidclient.types.MatchType) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) JsonObject(com.google.gson.JsonObject) View(android.view.View) Match(com.thebluealliance.androidclient.models.Match)

Example 2 with Match

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

the class MatchBreakdownView2018Test method getView.

private MatchBreakdownView2018 getView(String matchJsonFile) {
    Match match = ModelMaker.getModel(Match.class, matchJsonFile);
    LayoutInflater inflater = LayoutInflater.from(InstrumentationRegistry.getTargetContext());
    View view = inflater.inflate(R.layout.fragment_match_breakdown, null, false);
    FrameLayout matchView = (FrameLayout) view.findViewById(R.id.match_breakdown);
    assertEquals(1, matchView.getChildCount());
    assertTrue(matchView.getChildAt(0) instanceof MatchBreakdownView2018);
    MatchBreakdownView2018 view2018 = (MatchBreakdownView2018) matchView.getChildAt(0);
    MatchType matchType = MatchType.fromKey(match.getKey());
    view2018.initWithData(matchType, match.getWinningAlliance(), match.getAlliances(), mGson.fromJson(match.getScoreBreakdown(), JsonObject.class));
    view2018.setVisibility(View.VISIBLE);
    // hide progress bar
    view.findViewById(R.id.progress).setVisibility(View.GONE);
    return view2018;
}
Also used : MatchType(com.thebluealliance.androidclient.types.MatchType) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) JsonObject(com.google.gson.JsonObject) View(android.view.View) Match(com.thebluealliance.androidclient.models.Match)

Example 3 with Match

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

the class MatchesTableTest method testUpdate.

@Test
public void testUpdate() {
    Match result = DbTableTestDriver.testUpdate(mTable, mMatches.get(0), match -> match.setSetNumber(2), mGson);
    assertNotNull(result);
    assertEquals(2, result.getSetNumber().intValue());
}
Also used : Match(com.thebluealliance.androidclient.models.Match) Test(org.junit.Test)

Example 4 with Match

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

the class MatchListWriterTest method testMatchListWriter.

@Test
public void testMatchListWriter() {
    mWriter.write(mMatches, 0L);
    SQLiteDatabase db = mDb.getWritableDatabase();
    for (Match match : mMatches) {
        verify(db).insert(Database.TABLE_MATCHES, null, match.getParams(mGson));
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Match(com.thebluealliance.androidclient.models.Match) Test(org.junit.Test)

Example 5 with Match

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

the class APICache method fetchMatch.

public Observable<Match> fetchMatch(String matchKey) {
    return Observable.create((observer) -> {
        try {
            Match match = mDb.getMatchesTable().get(matchKey);
            observer.onNext(match);
            observer.onCompleted();
        } catch (Exception e) {
            observer.onError(e);
        }
    });
}
Also used : Match(com.thebluealliance.androidclient.models.Match)

Aggregations

Match (com.thebluealliance.androidclient.models.Match)23 JsonObject (com.google.gson.JsonObject)8 MatchType (com.thebluealliance.androidclient.types.MatchType)6 Test (org.junit.Test)6 LayoutInflater (android.view.LayoutInflater)5 View (android.view.View)5 FrameLayout (android.widget.FrameLayout)5 ArrayList (java.util.ArrayList)4 Event (com.thebluealliance.androidclient.models.Event)3 Nullable (androidx.annotation.Nullable)2 JsonParseException (com.google.gson.JsonParseException)2 MatchSortByPlayOrderComparator (com.thebluealliance.androidclient.comparators.MatchSortByPlayOrderComparator)2 EventMatchesEvent (com.thebluealliance.androidclient.eventbus.EventMatchesEvent)2 MatchAlliancesContainer (com.thebluealliance.androidclient.models.MatchAlliancesContainer)2 Team (com.thebluealliance.androidclient.models.Team)2 List (java.util.List)2 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 WorkerThread (androidx.annotation.WorkerThread)1 MatchSortByDisplayOrderComparator (com.thebluealliance.androidclient.comparators.MatchSortByDisplayOrderComparator)1