use of com.google.api.services.plus.model.Activity.PlusObject.Attachments.Thumbnails in project data-transfer-project by google.
the class GooglePlusExporter method postToActivityModel.
private SocialActivityModel postToActivityModel(Activity activity) {
String contentString = activity.getObject().getOriginalContent();
List<SocialActivityAttachment> activityAttachments = new ArrayList<>();
switch(activity.getVerb()) {
case "post":
for (Attachments attachment : activity.getObject().getAttachments()) {
if (attachment.getObjectType().equals("article")) {
activityAttachments.add(new SocialActivityAttachment(SocialActivityAttachmentType.LINK, attachment.getUrl(), attachment.getDisplayName(), attachment.getContent()));
} else if (attachment.getObjectType().equals("photo")) {
activityAttachments.add(new SocialActivityAttachment(SocialActivityAttachmentType.IMAGE, attachment.getFullImage().getUrl(), attachment.getDisplayName(), attachment.getContent()));
} else if (attachment.getObjectType().equals("album")) {
// all the images.
for (Thumbnails image : attachment.getThumbnails()) {
activityAttachments.add(new SocialActivityAttachment(SocialActivityAttachmentType.IMAGE, // This is just a thumbnail image
image.getImage().getUrl(), image.getDescription(), // but instead a hosted page of the image.
"Original G+ Image: " + image.getUrl() + " from album: " + attachment.getUrl()));
}
} else {
throw new IllegalArgumentException("Don't know how to export attachment " + attachment.getObjectType());
}
}
return new SocialActivityModel(activity.getId(), Instant.ofEpochMilli(activity.getPublished().getValue()), SocialActivityType.POST, activityAttachments, null, activity.getTitle(), contentString, activity.getUrl());
case "checkin":
Place location = activity.getLocation();
return new SocialActivityModel(activity.getId(), Instant.ofEpochMilli(activity.getPublished().getValue()), SocialActivityType.CHECKIN, null, new SocialActivityLocation(location.getDisplayName(), location.getPosition().getLongitude(), location.getPosition().getLatitude()), activity.getPlaceName(), contentString, null);
default:
throw new IllegalArgumentException("Don't know how to export " + activity);
}
}
Aggregations