Android Open Source - rgb-tool R G B Tool Images Cursor Adapter






From Project

Back to project page rgb-tool.

License

The source code is released under:

Apache License

If you think the Android project rgb-tool 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.fastebro.androidrgbtool.adapters;
//ww  w  . jav a  2 s  .  c  om
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import com.fastebro.androidrgbtool.R;
import com.squareup.picasso.Picasso;

/**
 * Created by danielealtomare on 09/06/14.
 */
public class RGBToolImagesCursorAdapter extends CursorAdapter {
    private final LayoutInflater inflater;

    public RGBToolImagesCursorAdapter(Context context) {
        super(context, null, 0);
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return getCursor() == null ? 0 : super.getCount();
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View itemLayout = inflater.inflate(R.layout.grid_view_item, parent, false);

        ViewHolder holder = new ViewHolder();
        holder.thumbnail = (ImageView) itemLayout.findViewById(R.id.thumbnail);
        itemLayout.setTag(holder);

        return itemLayout;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        int imageID = cursor.getInt(cursor.getColumnIndex(MediaStore.Images.Media._ID));
        Uri imageUri = Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, Integer.toString(imageID));

        ViewHolder holder = (ViewHolder) view.getTag();

        Picasso.with(context)
                .load(imageUri)
                .resize(256, 256)
                .centerCrop()
                .into(holder.thumbnail);
    }

    private static class ViewHolder {
        ImageView thumbnail;
    }
}




Java Source Code List

com.fastebro.androidrgbtool.adapters.ColorListAdapter.java
com.fastebro.androidrgbtool.adapters.ImagePaletteAdapter.java
com.fastebro.androidrgbtool.adapters.RGBToolImagesCursorAdapter.java
com.fastebro.androidrgbtool.adapters.SelectPictureListAdapter.java
com.fastebro.androidrgbtool.contracts.ColorDataContract.java
com.fastebro.androidrgbtool.events.ColorDeleteEvent.java
com.fastebro.androidrgbtool.events.ColorSelectEvent.java
com.fastebro.androidrgbtool.events.PhotoScaledEvent.java
com.fastebro.androidrgbtool.events.PrintColorEvent.java
com.fastebro.androidrgbtool.events.UpdateSaveColorUIEvent.java
com.fastebro.androidrgbtool.fragments.AboutFragment.java
com.fastebro.androidrgbtool.fragments.ColorListDialogFragment.java
com.fastebro.androidrgbtool.fragments.EventBaseDialogFragment.java
com.fastebro.androidrgbtool.fragments.PrintColorDialogFragment.java
com.fastebro.androidrgbtool.fragments.SelectPictureDialogFragment.java
com.fastebro.androidrgbtool.helpers.SQLiteRGBToolHelper.java
com.fastebro.androidrgbtool.managers.RecyclerViewLinearLayoutManager.java
com.fastebro.androidrgbtool.model.PaletteSwatch.java
com.fastebro.androidrgbtool.print.RGBToolPrintDocumentAdapter.java
com.fastebro.androidrgbtool.provider.RGBToolContentProvider.java
com.fastebro.androidrgbtool.render.GLRender.java
com.fastebro.androidrgbtool.tasks.PhotoScalingTask.java
com.fastebro.androidrgbtool.ui.AboutActivity.java
com.fastebro.androidrgbtool.ui.BaseActivity.java
com.fastebro.androidrgbtool.ui.ColorPickerActivity.java
com.fastebro.androidrgbtool.ui.EventBaseActivity.java
com.fastebro.androidrgbtool.ui.ImagePaletteActivity.java
com.fastebro.androidrgbtool.ui.MainActivity.java
com.fastebro.androidrgbtool.ui.RGBToolGalleryActivity.java
com.fastebro.androidrgbtool.utils.AlbumStorageDirFactory.java
com.fastebro.androidrgbtool.utils.BaseAlbumDirFactory.java
com.fastebro.androidrgbtool.utils.UColor.java
com.fastebro.androidrgbtool.utils.UCommon.java
com.fastebro.androidrgbtool.utils.UDatabase.java
com.fastebro.androidrgbtool.utils.UImage.java
com.fastebro.androidrgbtool.utils.UPalette.java
com.fastebro.androidrgbtool.view.CheckableRelativeLayout.java
com.fastebro.androidrgbtool.view.CustomGLSurfaceView.java
com.fastebro.androidrgbtool.widgets.RGBPanelData.java