Back to project page BrokenDisplay.
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.
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; } }