Android Open Source - BrokenDisplay Picture_ Grid Adapter






From Project

Back to project page BrokenDisplay.

License

The source code is released under:

Apache License

If you think the Android project BrokenDisplay 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.foolish.brokendisplay.picturedialog;
// ww w  .j a  v  a  2 s . c o  m
import java.lang.ref.WeakReference;
import java.util.List;

import com.foolish.brokendisplay.R;

import android.app.Service;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Picture_GridAdapter extends ArrayAdapter<Integer> {

  /**
   * 
   * 
   * @param context
   *            {@link Context}
   * @param textViewResourceId
   * 
   * @param objects
   * 
   */
  public Picture_GridAdapter(Context context, int textViewResourceId,
      List<Integer> objects) {
    super(context, textViewResourceId, objects);
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    int resId = getItem(position);

    ViewHolder holder;
    if (convertView == null) {
      LayoutInflater inflater = (LayoutInflater) getContext()
          .getSystemService(Service.LAYOUT_INFLATER_SERVICE);
      convertView = inflater.inflate(R.layout.fragment_picture_main,
          parent, false);
      holder = new ViewHolder();
      holder.name = (TextView) convertView
          .findViewById(R.id.name);
      holder.picture=(ImageView)convertView.findViewById(R.id.picture);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    holder.name.setText(getContext().getResources().getResourceEntryName(resId));
    loadBitmap(resId, holder.picture);
    return convertView;
  }

  public void loadBitmap(int resId, ImageView imageView) {
    BitmapWorkerTask task = new BitmapWorkerTask(imageView, getContext());
    task.execute(resId);
  }

  /**
   * ViewHolder. Similar to model of Database
   */
  private class ViewHolder {

    /** Name */
    public TextView name;

    public ImageView picture;

  }

}




Java Source Code List

com.foolish.brokendisplay.BrokenDisplayActivity.java
com.foolish.brokendisplay.BrokenGlassService.java
com.foolish.brokendisplay.ItemDetailActivity.java
com.foolish.brokendisplay.ItemDetailFragment.java
com.foolish.brokendisplay.ItemListActivity.java
com.foolish.brokendisplay.ItemListFragment.java
com.foolish.brokendisplay.MyImageView.java
com.foolish.brokendisplay.OnSwipeTouchListener.java
com.foolish.brokendisplay.OverlayEditorActivity.java
com.foolish.brokendisplay.OverlayEditorFragment.java
com.foolish.brokendisplay.OverviewFragment.java
com.foolish.brokendisplay.dummy.DummyContent.java
com.foolish.brokendisplay.picturedialog.BitmapWorkerTask.java
com.foolish.brokendisplay.picturedialog.IOnSelectPictureDialog.java
com.foolish.brokendisplay.picturedialog.Picture_GridAdapter.java
com.foolish.brokendisplay.picturedialog.SelectPictureDialog.java