Search in sources :

Example 16 with Photo

use of com.googlecode.flickrjandroid.photos.Photo in project GestureViews by alexvasilkov.

the class PhotoListAdapter method onClick.

@Override
public void onClick(@NonNull View view) {
    Photo photo = (Photo) view.getTag(R.id.tag_item);
    int pos = photos.indexOf(photo);
    listener.onPhotoClick(pos);
}
Also used : Photo(com.googlecode.flickrjandroid.photos.Photo)

Example 17 with Photo

use of com.googlecode.flickrjandroid.photos.Photo in project GestureViews by alexvasilkov.

the class PhotoPagerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
    if (setupListener != null) {
        setupListener.onSetupGestureView(holder.image);
    }
    // Temporary disabling touch controls
    if (!holder.gesturesDisabled) {
        holder.image.getController().getSettings().disableGestures();
        holder.gesturesDisabled = true;
    }
    holder.progress.animate().setStartDelay(PROGRESS_DELAY).alpha(1f);
    Photo photo = photos.get(position);
    // Loading image
    GlideHelper.loadFlickrFull(photo, holder.image, new GlideHelper.ImageLoadingListener() {

        @Override
        public void onLoaded() {
            holder.progress.animate().cancel();
            holder.progress.animate().alpha(0f);
            // Re-enabling touch controls
            if (holder.gesturesDisabled) {
                holder.image.getController().getSettings().enableGestures();
                holder.gesturesDisabled = false;
            }
        }

        @Override
        public void onFailed() {
            holder.progress.animate().alpha(0f);
        }
    });
}
Also used : GlideHelper(com.alexvasilkov.gestures.sample.utils.glide.GlideHelper) Photo(com.googlecode.flickrjandroid.photos.Photo)

Example 18 with Photo

use of com.googlecode.flickrjandroid.photos.Photo in project GestureViews by alexvasilkov.

the class FlickrApi method loadImages.

@Background(singleThread = true)
@Subscribe(LOAD_IMAGES_EVENT)
private static synchronized EventResult loadImages(int count) throws Exception {
    SearchParameters params = new SearchParameters();
    params.setText(SEARCH_QUERY);
    params.setSafeSearch(Flickr.SAFETYLEVEL_SAFE);
    params.setSort(SearchParameters.RELEVANCE);
    params.setLicense(LICENCE_ID);
    params.setExtras(photoParams);
    boolean hasNext = hasNext();
    while (photos.size() < count && hasNext) {
        PhotoList loaded = new Flickr(API_KEY).getPhotosInterface().search(params, PER_PAGE, pages.size() + 1);
        pages.add(loaded);
        photos.addAll(loaded);
        hasNext = hasNext();
    }
    int resultSize;
    if (photos.size() >= count) {
        resultSize = count;
    } else {
        resultSize = photos.size();
    }
    List<Photo> result = new ArrayList<>(photos.subList(0, resultSize));
    if (!hasNext) {
        hasNext = photos.size() > count;
    }
    return EventResult.create().result(result, hasNext).build();
}
Also used : SearchParameters(com.googlecode.flickrjandroid.photos.SearchParameters) Flickr(com.googlecode.flickrjandroid.Flickr) PhotoList(com.googlecode.flickrjandroid.photos.PhotoList) ArrayList(java.util.ArrayList) Photo(com.googlecode.flickrjandroid.photos.Photo) Background(com.alexvasilkov.events.Events.Background) Subscribe(com.alexvasilkov.events.Events.Subscribe)

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