Created
October 28, 2013 18:23
-
-
Save ajamaica/7201923 to your computer and use it in GitHub Desktop.
Adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mx.com.estrategiatec.TDU.Adapters; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
import android.widget.ImageView; | |
import android.widget.TextView; | |
import com.nostra13.universalimageloader.core.DisplayImageOptions; | |
import com.nostra13.universalimageloader.core.ImageLoader; | |
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; | |
import com.parse.ParseFile; | |
import com.parse.ParseObject; | |
import mx.com.estrategiatec.TDU.R; | |
/** | |
* Created with IntelliJ IDEA. | |
* User: arturojamaicagarcia | |
* Date: 23/09/13 | |
* Time: 23:14 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
public class HotDealsAdapter extends ArrayAdapter<ParseObject> { | |
ImageLoader imageLoader = ImageLoader.getInstance(); | |
DisplayImageOptions options; | |
Context context; | |
int layoutResourceId; | |
ParseObject data[] = null; | |
public HotDealsAdapter(Context context, int layoutResourceId, ParseObject[] data) { | |
super(context, layoutResourceId, data); | |
this.layoutResourceId = layoutResourceId; | |
this.context = context; | |
this.data = data; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
View row = convertView; | |
HotDealHolder holder = null; | |
if(row == null) | |
{ | |
LayoutInflater inflater = ((Activity)context).getLayoutInflater(); | |
row = inflater.inflate(layoutResourceId, parent, false); | |
holder = new HotDealHolder(); | |
holder.nombre = (TextView)row.findViewById(R.id.nombre); | |
holder.image = (ImageView) row.findViewById(R.id.imgdeal); | |
row.setTag(holder); | |
} | |
else | |
{ | |
holder = (HotDealHolder) row.getTag(); | |
} | |
ParseObject hotdeal = data[position]; | |
ParseFile file = hotdeal.getParseFile("Foto"); | |
holder.nombre.setText(hotdeal.getString("Nombre")); | |
imageLoader = ImageLoader.getInstance(); | |
ImageLoaderConfiguration img = ImageLoaderConfiguration.createDefault(context); | |
imageLoader.init(img); | |
options = new DisplayImageOptions.Builder() | |
.build(); | |
imageLoader.displayImage(file.getUrl(), holder.image,options); | |
return row; | |
} | |
static class HotDealHolder | |
{ | |
TextView nombre; | |
ImageView image; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment