Android Open Source - Joetz-Android-V2 Aanbevolen Adapter

From Project

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.

Java Source Code

package com.example.jens.myapplication.home;
/*from  ww  w  .j a v a2  s . co  m*/
import android.content.Context;
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()
                        // .showImageForEmptyUri(R.drawable.ic_empty)
                        // .showImageOnFail(R.drawable.ic_error)

    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;

    public void onBindViewHolder(AanbevolenAdapter.ViewHolder holder, int position) {
        final Camp camp = items.get(position);


        holder.age.setText(camp.getMinimumAge() + " - " + camp.getMaximumAge() + " " + "j");
    //    holder.price.setText("\u20ac " + camp.getPrice().toString());
                + " - " + DateTimeStringConverter.getSimpleDate(camp.getEndDate()));

        String url = ApiConnection.URL + "api/images/" +camp.getFirstImageId();

        ImageLoader.getInstance().displayImage(url,holder.image, imageLoaderOptions);


    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) {
            image =  (ImageView) itemView.findViewById(;
            title=  (TextView) itemView.findViewById(;
            location =  (TextView) itemView.findViewById(;
            campDate = (TextView) itemView.findViewById(;
         //   price = (TextView) itemView.findViewById(;
            age= (TextView) itemView.findViewById(;

Java Source Code List