Search in sources :

Example 6 with Media

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

the class MatchInfoSubscriberTest method testParsedData.

@Test
public void testParsedData() {
    List<ListItem> data = DatafeedTestDriver.getParsedData(mSubscriber, mData);
    assertEquals(3, data.size());
    assertTrue(data.get(0) instanceof MatchListElement);
    assertTrue(data.get(1) instanceof ImageListElement);
    Media videoItem = ((Match.MatchVideo) mData.match.getVideos().get(0)).asMedia();
    ImageListElement video = (ImageListElement) data.get(1);
    verify(mRenderer).renderFromModel(mData.match, MatchRenderer.RENDER_MATCH_INFO);
    assertTrue(video.equals(mMediaRenderer.renderFromModel(videoItem, null)));
}
Also used : ImageListElement(com.thebluealliance.androidclient.listitems.ImageListElement) MatchListElement(com.thebluealliance.androidclient.listitems.MatchListElement) Media(com.thebluealliance.androidclient.models.Media) ListItem(com.thebluealliance.androidclient.listitems.ListItem) Test(org.junit.Test)

Example 7 with Media

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

the class TeamInfoSubscriberTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    Context context = RuntimeEnvironment.application;
    mSubscriber = new TeamInfoSubscriber(context, mAppConfig);
    Team team = ModelMaker.getModel(Team.class, "frc1124");
    List<Media> socialMedia = ModelMaker.getModelList(Media.class, "frc1124_social_media");
    mModel = new TeamInfoSubscriber.Model(team, socialMedia);
}
Also used : Context(android.content.Context) Media(com.thebluealliance.androidclient.models.Media) Team(com.thebluealliance.androidclient.models.Team) Before(org.junit.Before)

Example 8 with Media

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

the class MediaListWriterTest method testEventListWriter.

@Test
public void testEventListWriter() {
    mWriter.write(mMedias, 0L);
    SQLiteDatabase db = mDb.getWritableDatabase();
    for (Media media : mMedias) {
        verify(db).insert(Database.TABLE_MEDIAS, null, media.getParams(mGson));
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Media(com.thebluealliance.androidclient.models.Media) Test(org.junit.Test)

Example 9 with Media

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

the class MatchInfoSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    mDataToBind.add(mRenderer.renderFromModel(mAPIData.match, MatchRenderer.RENDER_MATCH_INFO));
    mMatchTitle = mAPIData.match.getTitle(mResources);
    mMatchKey = mAPIData.match.getKey();
    List<IMatchVideo> matchVideos = mAPIData.match.getVideos();
    for (int i = 0; matchVideos != null && i < matchVideos.size(); i++) {
        Match.MatchVideo video = (Match.MatchVideo) matchVideos.get(i);
        if (MediaType.fromString(video.getType()) != MediaType.NONE) {
            Media media = video.asMedia();
            mDataToBind.add(mMediaRenderer.renderFromModel(media, null));
        }
    }
    updateActionBarTitle(mAPIData.event.getShortName());
}
Also used : Media(com.thebluealliance.androidclient.models.Media) IMatchVideo(com.thebluealliance.api.model.IMatchVideo) IMatchVideo(com.thebluealliance.api.model.IMatchVideo) Match(com.thebluealliance.androidclient.models.Match)

Example 10 with Media

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

the class MediaListSubscriber method parseData.

@Override
public void parseData() {
    mDataToBind.clear();
    mPhotos.clear();
    mVideos.clear();
    String encodedAvatar = "";
    for (int i = 0; i < mAPIData.size(); i++) {
        Media media = mAPIData.get(i);
        MediaType mediaType = MediaType.fromString(media.getType());
        if (mediaType.isImage()) {
            mPhotos.children.add(media);
        } else if (mediaType.isVideo()) {
            mVideos.children.add(media);
        } else if (mediaType.isAvatar()) {
            encodedAvatar = media.getBase64Image();
        }
    }
    if (!mPhotos.children.isEmpty()) {
        mDataToBind.add(mPhotos);
    }
    if (!mVideos.children.isEmpty()) {
        mDataToBind.add(mVideos);
    }
    mEventBus.post(new TeamAvatarUpdateEvent(encodedAvatar));
}
Also used : Media(com.thebluealliance.androidclient.models.Media) MediaType(com.thebluealliance.androidclient.types.MediaType) TeamAvatarUpdateEvent(com.thebluealliance.androidclient.eventbus.TeamAvatarUpdateEvent)

Aggregations

Media (com.thebluealliance.androidclient.models.Media)10 Test (org.junit.Test)3 JsonObject (com.google.gson.JsonObject)2 Team (com.thebluealliance.androidclient.models.Team)2 MediaType (com.thebluealliance.androidclient.types.MediaType)2 Context (android.content.Context)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 TeamInfoBinder (com.thebluealliance.androidclient.binders.TeamInfoBinder)1 TeamAvatarUpdateEvent (com.thebluealliance.androidclient.eventbus.TeamAvatarUpdateEvent)1 ImageListElement (com.thebluealliance.androidclient.listitems.ImageListElement)1 ListItem (com.thebluealliance.androidclient.listitems.ListItem)1 MatchListElement (com.thebluealliance.androidclient.listitems.MatchListElement)1 Match (com.thebluealliance.androidclient.models.Match)1 IMatchVideo (com.thebluealliance.api.model.IMatchVideo)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1