Search in sources :

Example 1 with ContributorListElement

use of com.thebluealliance.androidclient.listitems.ContributorListElement in project the-blue-alliance-android by the-blue-alliance.

the class ContributorListSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    JsonArray data = mAPIData.getAsJsonArray();
    for (JsonElement e : data) {
        JsonObject user = e.getAsJsonObject();
        String username = user.get("login").getAsString();
        int contributionCount = user.get("contributions").getAsInt();
        String avatarUrl = user.get("avatar_url").getAsString();
        mDataToBind.add(new ContributorListElement(username, contributionCount, avatarUrl));
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ContributorListElement(com.thebluealliance.androidclient.listitems.ContributorListElement) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject)

Example 2 with ContributorListElement

use of com.thebluealliance.androidclient.listitems.ContributorListElement in project the-blue-alliance-android by the-blue-alliance.

the class ContributorListSubscriberTest method testParsedData.

@Test
public void testParsedData() {
    List<ListItem> parsed = DatafeedTestDriver.getParsedData(mSubscriber, mData);
    assertEquals(1, parsed.size());
    assertTrue(parsed.get(0) instanceof ContributorListElement);
    ContributorListElement element = (ContributorListElement) parsed.get(0);
    assertEquals("phil-lopreiato", element.username);
    assertEquals(1266, element.contributionCount);
    assertEquals("https://avatars.githubusercontent.com/u/2754863?v=3", element.avatarUrl);
}
Also used : ContributorListElement(com.thebluealliance.androidclient.listitems.ContributorListElement) ListItem(com.thebluealliance.androidclient.listitems.ListItem) Test(org.junit.Test)

Aggregations

ContributorListElement (com.thebluealliance.androidclient.listitems.ContributorListElement)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 ListItem (com.thebluealliance.androidclient.listitems.ListItem)1 Test (org.junit.Test)1