use of com.bourke.glimmr.tasks.DownloadPhotoTask in project glimmr by brk3.
the class PhotoViewerFragment method onWallpaperButtonClick.
private void onWallpaperButtonClick() {
Toast.makeText(mActivity, mActivity.getString(R.string.setting_wallpaper), Toast.LENGTH_SHORT).show();
if (mBasePhoto != null) {
String url = getLargestUrlAvailable(mBasePhoto);
new DownloadPhotoTask(mActivity, new Events.IPhotoDownloadedListener() {
@Override
public void onPhotoDownloaded(Bitmap bitmap, Exception e) {
if (e == null) {
WallpaperManager wallpaperManager = WallpaperManager.getInstance(mActivity);
try {
wallpaperManager.setBitmap(bitmap);
} catch (IOException e1) {
e1.printStackTrace();
}
} else {
Log.e(TAG, "Error setting wallpaper");
e.printStackTrace();
}
}
}, url).execute();
}
}
use of com.bourke.glimmr.tasks.DownloadPhotoTask in project glimmr by brk3.
the class PhotoViewerFragment method saveImageToExternalStorage.
private void saveImageToExternalStorage() {
String url = getLargestUrlAvailable(mBasePhoto);
new DownloadPhotoTask(mActivity, new Events.IPhotoDownloadedListener() {
@Override
public void onPhotoDownloaded(Bitmap bitmap, Exception e) {
String filename = mBasePhoto.getTitle() + ".jpg";
if (e == null && createExternalStoragePublicPicture(bitmap, filename) != null) {
Toast.makeText(mActivity, getString(R.string.image_saved), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(mActivity, getString(R.string.storage_error), Toast.LENGTH_SHORT).show();
}
}
}, url).execute();
}
use of com.bourke.glimmr.tasks.DownloadPhotoTask 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);
}
Aggregations