use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class PhotoGridFragment method checkForNewPhotos.
/**
* If we have a most recent id stored, see if it exists in the photo
* list we just fetched. If so, all photos before that id in the list
* are said to be new.
*/
protected void checkForNewPhotos(List<Photo> photos) {
if (photos == null || photos.isEmpty()) {
if (BuildConfig.DEBUG)
Log.d(getLogTag(), "checkForNewPhotos: photos null or empty");
return;
}
mNewPhotos = new ArrayList<Photo>();
String newestId = getNewestPhotoId();
if (newestId != null) {
for (int i = 0; i < photos.size(); i++) {
Photo p = photos.get(i);
if (p.getId().equals(newestId)) {
mNewPhotos = photos.subList(0, i);
if (BuildConfig.DEBUG)
Log.d(getLogTag(), String.format("Found %d new photos", mNewPhotos.size()));
break;
}
}
}
if (mNewPhotos != null && !mNewPhotos.isEmpty()) {
storeNewestPhotoId(mNewPhotos.get(0));
} else {
if (BuildConfig.DEBUG)
Log.d(getLogTag(), "mNewPhotos null or empty, using most " + "recent fetched photo as newest");
storeNewestPhotoId(photos.get(0));
}
}
use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class ActivityNotificationHandler method showNotification.
private void showNotification(final Item item, final int eventOffset) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "showNotification for " + item.getTitle() + ", starting ajax task to fetch the item image");
}
/* fetch the photo the item refers to */
new LoadPhotoInfoTask(new IPhotoInfoReadyListener() {
@Override
public void onPhotoInfoReady(final Photo photo, Exception e) {
/* fetch the photo bitmap to be shown in the notification */
String url = photo.getMediumUrl();
new DownloadPhotoTask(mContext, new Events.IPhotoDownloadedListener() {
@Override
public void onPhotoDownloaded(Bitmap bitmap, Exception e) {
onItemPhotoReady(item, photo, bitmap, eventOffset);
}
}, url).execute();
}
}, item.getId(), item.getSecret()).execute(mOAuth);
}
use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.
the class ContactsPhotosNotificationHandler method onPhotosReady.
/**
* Once photos are ready check for new ones and notify the user.
*
* There are two conditions that must be satisfied for a notification to be
* shown:
* 1) The id must be newer than ones previously shown in the main app.
* 2) The id must not equal the one previously notified about, to avoid
* duplicate notifications.
*/
@Override
public void onPhotosReady(List<Photo> photos, Exception e) {
if (BuildConfig.DEBUG)
Log.d(TAG, "onPhotosReady");
if (photos != null) {
List<Photo> newPhotos = checkForNewPhotos(photos);
if (newPhotos != null && !newPhotos.isEmpty()) {
String latestIdNotifiedAbout = getLatestIdNotifiedAbout();
Photo latestPhoto = newPhotos.get(0);
if (!latestIdNotifiedAbout.equals(latestPhoto.getId())) {
showNewPhotosNotification(newPhotos);
storeLatestIdNotifiedAbout(latestPhoto);
}
}
} else {
Log.e(TAG, "onPhotosReady: null photolist received");
}
}
Aggregations