use of com.bourke.glimmr.tasks.LoadPhotoInfoTask in project glimmr by brk3.
the class MainActivity method startViewerForActivityItem.
private void startViewerForActivityItem(int itemPos) {
setProgressBarIndeterminateVisibility(Boolean.TRUE);
List<Item> items = ActivityNotificationHandler.loadItemList(MainActivity.this);
Item item = items.get(itemPos);
new LoadPhotoInfoTask(new IPhotoInfoReadyListener() {
@Override
public void onPhotoInfoReady(final Photo photo, Exception e) {
setProgressBarIndeterminateVisibility(Boolean.FALSE);
if (FlickrHelper.getInstance().handleFlickrUnavailable(MainActivity.this, e)) {
return;
}
if (photo == null) {
Log.e(TAG, "onPhotoInfoReady: photo is null, " + "can't start viewer");
return;
}
List<Photo> photos = new ArrayList<Photo>();
photos.add(photo);
setProgressBarIndeterminateVisibility(Boolean.FALSE);
PhotoViewerActivity.startPhotoViewer(MainActivity.this, photos, 0);
}
}, item.getId(), item.getSecret()).execute(mOAuth);
}
use of com.bourke.glimmr.tasks.LoadPhotoInfoTask in project glimmr by brk3.
the class PhotoViewerFragment method startTask.
@Override
protected void startTask() {
super.startTask();
mActivity.setProgressBarIndeterminateVisibility(Boolean.FALSE);
/* Start a task to fetch more detailed info about the photo if we don't
* already have it (required for favorite status) */
if (mPhotoExtendedInfo == null) {
mTask = new LoadPhotoInfoTask(this, mBasePhoto.getId(), mBasePhoto.getSecret());
mTask.execute(mOAuth);
} else {
onPhotoInfoReady(mPhotoExtendedInfo, null);
}
}
use of com.bourke.glimmr.tasks.LoadPhotoInfoTask 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.bourke.glimmr.tasks.LoadPhotoInfoTask in project glimmr by brk3.
the class PhotoViewerActivity method handleIntent.
private void handleIntent(Intent intent) {
if (intent.getBooleanExtra(KEY_INTENT_CONSUMED, false)) {
/* prevent the intent getting executed twice on rotate */
if (BuildConfig.DEBUG)
Log.d(TAG, "KEY_INTENT_CONSUMED true");
return;
}
final int startIndex = intent.getIntExtra(KEY_START_INDEX, 0);
if (intent.getAction().equals(ACTION_VIEW_PHOTO_BY_ID)) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Received ACTION_VIEW_PHOTO_BY_ID intent");
intent.putExtra(KEY_INTENT_CONSUMED, true);
String photoId = intent.getStringExtra(KEY_PHOTO_ID);
new LoadPhotoInfoTask(this, photoId).execute(mOAuth);
} else if (intent.getAction().equals(ACTION_VIEW_PHOTOLIST)) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Received ACTION_VIEW_PHOTOLIST intent");
intent.putExtra(KEY_INTENT_CONSUMED, true);
String photoListFile = intent.getStringExtra(KEY_PHOTO_LIST_FILE);
GsonHelper gsonHelper = new GsonHelper(this);
String json = gsonHelper.loadJson(photoListFile);
if (json.length() > 0) {
Type collectionType = new TypeToken<Collection<Photo>>() {
}.getType();
mPhotos = new Gson().fromJson(json, collectionType);
initViewPager(startIndex, true);
} else {
Log.e(TAG, String.format("Error reading '%s'", photoListFile));
}
} else {
Log.e(TAG, "Unknown intent action: " + intent.getAction());
}
}
Aggregations