use of com.thebluealliance.androidclient.types.MediaType in project the-blue-alliance-android by the-blue-alliance.
the class TeamInfoSubscriber method parseData.
@Override
public void parseData() {
mDataToBind = new TeamInfoBinder.Model();
Map<MediaType, String> socialMediaByType = Utilities.getMapForPlatform(MediaType.class, String.class);
Team team = mAPIData.team;
List<Media> socialMedia = mAPIData.socialMedia;
mDataToBind.teamKey = team.getKey();
mDataToBind.fullName = team.getName();
mDataToBind.nickname = team.getNickname();
mDataToBind.teamNumber = team.getTeamNumber();
mDataToBind.location = team.getLocation();
if (team.getWebsite() != null) {
mDataToBind.website = team.getWebsite();
} else {
mDataToBind.website = "";
}
if (team.getMotto() != null) {
mDataToBind.motto = team.getMotto();
} else {
mDataToBind.motto = "";
}
// Separate social medias by type
mDataToBind.socialMedia = socialMediaByType;
for (int i = 0; socialMedia != null && i < socialMedia.size(); i++) {
Media media = socialMedia.get(i);
MediaType mediaType = MediaType.fromString(media.getType());
socialMediaByType.put(mediaType, media.getForeignKey());
}
// CMP Pit Location Stuff
mDataToBind.showPitLocation = PitLocationHelper.shouldShowPitLocation(mAppConfig);
mDataToBind.pitLocation = PitLocationHelper.getPitLocation(mContext, team.getKey());
}
use of com.thebluealliance.androidclient.types.MediaType 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));
}
use of com.thebluealliance.androidclient.types.MediaType in project the-blue-alliance-android by the-blue-alliance.
the class MediaRenderer method renderFromModel.
@Override
@Nullable
public ImageListElement renderFromModel(Media media, Void aVoid) {
String imageUrl;
MediaType mediaType = MediaType.fromString(media.getType());
String foreignKey = media.getForeignKey();
String keyForUrl = foreignKey;
/* Build the link of the remote image based on foreign key */
switch(mediaType) {
case CD_PHOTO_THREAD:
JsonObject details = media.getDetailsJson();
imageUrl = String.format(mediaType.getImageUrlPattern(), details.get("image_partial").getAsString().replace("_l.jpg", "_m.jpg"));
break;
case YOUTUBE:
/* Need to account for timestamps in youtube foreign key
* Can be like <key>?start=1h15m3s or <key>?t=time or <key>#t=time
* Since foreign key is first param in yt.com/watch?v=blah, others need to be &
*/
keyForUrl = foreignKey.replace('?', '&').replace('#', '&');
Matcher m = YOUTUBE_KEY_PATTERN.matcher(foreignKey);
String cleanKey = m.find() ? m.group(1) : foreignKey;
imageUrl = String.format(mediaType.getImageUrlPattern(), cleanKey);
break;
case IMGUR:
imageUrl = String.format(mediaType.getImageUrlPattern(), foreignKey);
break;
default:
imageUrl = "";
}
Boolean isVideo = mediaType == MediaType.YOUTUBE;
String linkUrl = String.format(mediaType.getLinkUrlPattern(), keyForUrl);
return new ImageListElement(imageUrl, linkUrl, isVideo);
}
Aggregations