Search in sources :

Example 1 with DownloadPhotoTask

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();
    }
}
Also used : Bitmap(android.graphics.Bitmap) DownloadPhotoTask(com.bourke.glimmr.tasks.DownloadPhotoTask) IOException(java.io.IOException) WallpaperManager(android.app.WallpaperManager) IOException(java.io.IOException)

Example 2 with DownloadPhotoTask

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();
}
Also used : Bitmap(android.graphics.Bitmap) DownloadPhotoTask(com.bourke.glimmr.tasks.DownloadPhotoTask) IOException(java.io.IOException)

Example 3 with DownloadPhotoTask

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);
}
Also used : Bitmap(android.graphics.Bitmap) Photo(com.googlecode.flickrjandroid.photos.Photo) DownloadPhotoTask(com.bourke.glimmr.tasks.DownloadPhotoTask) LoadPhotoInfoTask(com.bourke.glimmr.tasks.LoadPhotoInfoTask) IPhotoInfoReadyListener(com.bourke.glimmr.event.Events.IPhotoInfoReadyListener)

Aggregations

Bitmap (android.graphics.Bitmap)3 DownloadPhotoTask (com.bourke.glimmr.tasks.DownloadPhotoTask)3 IOException (java.io.IOException)2 WallpaperManager (android.app.WallpaperManager)1 IPhotoInfoReadyListener (com.bourke.glimmr.event.Events.IPhotoInfoReadyListener)1 LoadPhotoInfoTask (com.bourke.glimmr.tasks.LoadPhotoInfoTask)1 Photo (com.googlecode.flickrjandroid.photos.Photo)1