Search in sources :

Example 1 with LoadPhotoInfoTask

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);
}
Also used : MenuItem(android.view.MenuItem) Item(com.googlecode.flickrjandroid.activity.Item) ArrayList(java.util.ArrayList) Photo(com.googlecode.flickrjandroid.photos.Photo) LoadPhotoInfoTask(com.bourke.glimmr.tasks.LoadPhotoInfoTask) IPhotoInfoReadyListener(com.bourke.glimmr.event.Events.IPhotoInfoReadyListener)

Example 2 with LoadPhotoInfoTask

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);
    }
}
Also used : LoadPhotoInfoTask(com.bourke.glimmr.tasks.LoadPhotoInfoTask)

Example 3 with LoadPhotoInfoTask

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);
}
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)

Example 4 with LoadPhotoInfoTask

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());
    }
}
Also used : GsonHelper(com.bourke.glimmr.common.GsonHelper) Type(java.lang.reflect.Type) TypeToken(com.google.gson.reflect.TypeToken) Gson(com.google.gson.Gson) Photo(com.googlecode.flickrjandroid.photos.Photo) LoadPhotoInfoTask(com.bourke.glimmr.tasks.LoadPhotoInfoTask)

Aggregations

LoadPhotoInfoTask (com.bourke.glimmr.tasks.LoadPhotoInfoTask)4 Photo (com.googlecode.flickrjandroid.photos.Photo)3 IPhotoInfoReadyListener (com.bourke.glimmr.event.Events.IPhotoInfoReadyListener)2 Bitmap (android.graphics.Bitmap)1 MenuItem (android.view.MenuItem)1 GsonHelper (com.bourke.glimmr.common.GsonHelper)1 DownloadPhotoTask (com.bourke.glimmr.tasks.DownloadPhotoTask)1 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 Item (com.googlecode.flickrjandroid.activity.Item)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1