Back to project page Joetz-Android-V2.
The source code is released under:
GNU General Public License
If you think the Android project Joetz-Android-V2 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.example.jens.myapplication.home; /*from ww w .j a v a2 s . co m*/ import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.example.jens.myapplication.R; import com.example.jens.myapplication.apimanager.ApiConnection; import com.example.jens.myapplication.domain.Camp; import com.example.jens.myapplication.util.DateTimeStringConverter; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; import java.util.List; /** * Created by Jens on 15/12/2014. */ public class AanbevolenAdapter extends RecyclerView.Adapter<AanbevolenAdapter.ViewHolder> { private List<Camp> items; private int rowLayout; private Context mContext; private Long mLastDate; private DisplayImageOptions imageLoaderOptions; public AanbevolenAdapter(List<Camp> items, int rowLayout, Context context){ this.items = items; this.rowLayout = rowLayout; this.mContext = context; this.mLastDate = new Long(0); imageLoaderOptions = new DisplayImageOptions.Builder() .showImageOnLoading(R.drawable.stub) // .showImageForEmptyUri(R.drawable.ic_empty) // .showImageOnFail(R.drawable.ic_error) //.cacheInMemory(true) .cacheOnDisk(true) .considerExifParams(true) .build(); } @Override public AanbevolenAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View v = LayoutInflater.from(viewGroup.getContext()).inflate(rowLayout, viewGroup, false); ViewHolder holder = new ViewHolder(v); return holder; } @Override public void onBindViewHolder(AanbevolenAdapter.ViewHolder holder, int position) { final Camp camp = items.get(position); holder.title.setText(camp.getTitle()); holder.location.setText(camp.getLocation()); holder.age.setText(camp.getMinimumAge() + " - " + camp.getMaximumAge() + " " + "j"); // holder.price.setText("\u20ac " + camp.getPrice().toString()); holder.campDate.setText(DateTimeStringConverter.getSimpleDate(camp.getStartDate()) + " - " + DateTimeStringConverter.getSimpleDate(camp.getEndDate())); String url = ApiConnection.URL + "api/images/" +camp.getFirstImageId(); ImageLoader.getInstance().displayImage(url,holder.image, imageLoaderOptions); } @Override public int getItemCount() { return items == null ? 0 : items.size(); } public Camp getItem(int position){ return items.get(position); } public static class ViewHolder extends RecyclerView.ViewHolder { public View container; public ImageView image; public TextView title; public TextView location; public TextView campDate; // public TextView price; public TextView age; public ViewHolder(View itemView) { super(itemView); image = (ImageView) itemView.findViewById(R.id.imageAanbevolen); title= (TextView) itemView.findViewById(R.id.titleAanbevolen); location = (TextView) itemView.findViewById(R.id.lbl_dest); campDate = (TextView) itemView.findViewById(R.id.lbl_date); // price = (TextView) itemView.findViewById(R.id.lbl_price); age= (TextView) itemView.findViewById(R.id.lbl_age); } } }