Search in sources :

Example 6 with Photo

use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.

the class AddToPhotosetDialogFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mLayout = (LinearLayout) inflater.inflate(R.layout.add_to_photoset_fragment, container, false);
    TextView titleTextView = (TextView) mLayout.findViewById(R.id.titleText);
    titleTextView.setText(R.string.add_photos);
    mTextUtils.setFont(titleTextView, TextUtils.FONT_ROBOTOBOLD);
    //ProgressBar progressBar = (ProgressBar)
    //        mLayout.findViewById(R.id.progressIndicator);
    /* Nested fragments have to be added this way, not from xml */
    FragmentTransaction ft = getChildFragmentManager().beginTransaction();
    final boolean retainInstance = false;
    final PhotoStreamGridFragment frag = PhotoStreamGridFragment.newInstance(mOAuth.getUser(), retainInstance, ListView.CHOICE_MODE_MULTIPLE);
    ft.replace(R.id.photoStreamFragment, frag);
    ft.commit();
    /* When add button is clicked, get selected ids and add to queue */
    mLayout.findViewById(R.id.buttonAddToPhotoset).setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            List<Photo> selectedPhotos = frag.getSelectedPhotos();
            for (Photo photo : selectedPhotos) {
                mQueue.add(new AddItemToPhotosetTask(mPhotoset.getId(), photo.getId(), mOAuth));
            }
            mActivity.startService(new Intent(mActivity, AddToPhotosetTaskQueueService.class));
            dismiss();
            Crouton.makeText(mActivity, R.string.photos_will_be_added, Style.CONFIRM).show();
        }
    });
    return mLayout;
}
Also used : AddItemToPhotosetTask(com.bourke.glimmr.tasks.AddItemToPhotosetTask) FragmentTransaction(android.support.v4.app.FragmentTransaction) PhotoStreamGridFragment(com.bourke.glimmr.fragments.home.PhotoStreamGridFragment) TextView(android.widget.TextView) List(java.util.List) Photo(com.googlecode.flickrjandroid.photos.Photo) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 7 with Photo

use of com.googlecode.flickrjandroid.photos.Photo in project glimmr by brk3.

the class PhotoGridFragment method getSelectedPhotos.

public List<Photo> getSelectedPhotos() {
    List<Photo> ret = new ArrayList<Photo>();
    if (mGridView.getChoiceMode() != ListView.CHOICE_MODE_MULTIPLE) {
        Log.e(TAG, "PhotoGridFragment not in CHOICE_MODE_MULTIPLE");
        return ret;
    }
    SparseBooleanArray checkArray = mGridView.getCheckedItemPositions();
    for (int i = 0; i < checkArray.size(); i++) {
        if (checkArray.valueAt(i)) {
            ret.add(mPhotos.get(checkArray.keyAt(i)));
        }
    }
    if (BuildConfig.DEBUG)
        Log.d(TAG, "getSelectedPhotos: " + ret.size());
    return ret;
}
Also used : ArrayList(java.util.ArrayList) SparseBooleanArray(android.util.SparseBooleanArray) Photo(com.googlecode.flickrjandroid.photos.Photo)

Example 8 with Photo

use of com.googlecode.flickrjandroid.photos.Photo 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 9 with Photo

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);
}
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 10 with Photo

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");
    }
}
Also used : Photo(com.googlecode.flickrjandroid.photos.Photo)

Aggregations

Photo (com.googlecode.flickrjandroid.photos.Photo)18 ArrayList (java.util.ArrayList)4 Intent (android.content.Intent)3 LoadPhotoInfoTask (com.bourke.glimmr.tasks.LoadPhotoInfoTask)3 Bitmap (android.graphics.Bitmap)2 FragmentTransaction (android.support.v4.app.FragmentTransaction)2 View (android.view.View)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 IPhotoInfoReadyListener (com.bourke.glimmr.event.Events.IPhotoInfoReadyListener)2 PhotoStreamGridFragment (com.bourke.glimmr.fragments.home.PhotoStreamGridFragment)2 List (java.util.List)2 Bundle (android.os.Bundle)1 Toolbar (android.support.v7.widget.Toolbar)1 SparseBooleanArray (android.util.SparseBooleanArray)1 MenuItem (android.view.MenuItem)1 RemoteViews (android.widget.RemoteViews)1 SpannableBuilder (com.alexvasilkov.android.commons.texts.SpannableBuilder)1 Background (com.alexvasilkov.events.Events.Background)1 Subscribe (com.alexvasilkov.events.Events.Subscribe)1