Android Open Source - PhotoPicker Albums Adapter






From Project

Back to project page PhotoPicker.

License

The source code is released under:

GNU General Public License

If you think the Android project PhotoPicker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.thuytrinh.photopicker.controller.adapter;
//from   w ww .  j a  va2s.c o  m
import android.content.Context;
import android.database.Cursor;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;

import com.squareup.picasso.Picasso;
import com.thuytrinh.photopicker.R;
import com.thuytrinh.photopicker.controller.ImageCursorMapper;
import com.thuytrinh.photopicker.view.AlbumView;

import java.io.File;

import javax.inject.Inject;

public class AlbumsAdapter extends CursorAdapter {
  private ImageCursorMapper imageCursorMapper;
  private Picasso picasso;

  @Inject
  public AlbumsAdapter(Context context,
                       ImageCursorMapper imageCursorMapper,
                       Picasso picasso) {
    super(context, null, 0);

    this.imageCursorMapper = imageCursorMapper;
    this.picasso = picasso;
  }

  @Override
  public long getItemId(int position) {
    getItem(position);
    return imageCursorMapper.getBucketId();
  }

  @Override
  public View newView(Context context, Cursor cursor, ViewGroup parent) {
    return new AlbumView(context);
  }

  @Override
  public void bindView(View view, Context context, Cursor cursor) {
    AlbumView albumView = (AlbumView) view;

    String albumName = imageCursorMapper.getBucketDisplayName();
    albumView.getNameView().setText(albumName);

    File photoFile = imageCursorMapper.getDataFile();
    picasso.load(photoFile)
        .resize(200, 200)
        .placeholder(R.color.placeholder)
        .centerCrop()
        .into(albumView.getThumbnailView());
  }

  @Override
  public Cursor swapCursor(Cursor newCursor) {
    imageCursorMapper.setCursor(newCursor);
    return super.swapCursor(newCursor);
  }
}




Java Source Code List

com.thuytrinh.photopicker.controller.GroupByBucketIdFunc.java
com.thuytrinh.photopicker.controller.ImageCursorMapperTest.java
com.thuytrinh.photopicker.controller.ImageCursorMapper.java
com.thuytrinh.photopicker.controller.SimpleLoaderListenerTest.java
com.thuytrinh.photopicker.controller.SimpleLoaderListener.java
com.thuytrinh.photopicker.controller.activity.PhotoChooserActivityTest.java
com.thuytrinh.photopicker.controller.activity.PhotoChooserActivity.java
com.thuytrinh.photopicker.controller.adapter.AlbumsAdapter.java
com.thuytrinh.photopicker.controller.adapter.PhotosAdapter.java
com.thuytrinh.photopicker.controller.fragment.AlbumsFragment.java
com.thuytrinh.photopicker.controller.fragment.PhotosFragment.java
com.thuytrinh.photopicker.controller.loader.AlbumsLoaderTest.java
com.thuytrinh.photopicker.controller.loader.AlbumsLoader.java
com.thuytrinh.photopicker.controller.loader.PhotosLoaderTest.java
com.thuytrinh.photopicker.controller.loader.PhotosLoader.java
com.thuytrinh.photopicker.model.PhotoTest.java
com.thuytrinh.photopicker.model.Photo.java
com.thuytrinh.photopicker.module.AppModule.java
com.thuytrinh.photopicker.module.ObjectLocator.java
com.thuytrinh.photopicker.view.AlbumView.java
com.thuytrinh.photopicker.view.PhotoItemLayoutTest.java
com.thuytrinh.photopicker.view.PhotoItemLayout.java