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.calendar; /*from w w w . ja va 2 s . c o m*/ import android.content.Context; import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.example.jens.myapplication.R; import com.example.jens.myapplication.util.DateTimeStringConverter; import org.joda.time.DateTime; import java.util.List; /** * Created by Jens on 7/12/2014. */ public class KalenderAdapter extends RecyclerView.Adapter<KalenderAdapter.ViewHolder> { private List<KalenderItem> items; private int rowLayout; private Context mContext; private Long mLastDate; public KalenderAdapter(List<KalenderItem> items, int rowLayout, Context context){ this.items = items; this.rowLayout = rowLayout; this.mContext = context; this.mLastDate = new Long(0); } @Override public KalenderAdapter.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(KalenderAdapter.ViewHolder holder, int position) { final KalenderItem k = items.get(position); DateTime date= new DateTime(k.getDate() * 1000L); DateTime endDate = new DateTime(k.getEndDate()*1000L); if(mLastDate == k.getDate()){ holder.maand.setText(""); holder.dag.setText(""); } else { holder.maand.setText(DateTimeStringConverter.getMonthShort(date)); holder.dag.setText(String.format(String.valueOf(date.getDayOfMonth()))); } holder.title.setText(k.getTitle()); holder.date.setText(DateTimeStringConverter.getSimpleDateRange(date, endDate)); mLastDate = k.getDate(); } @Override public int getItemCount() { return items == null ? 0 : items.size(); } public KalenderItem getItem(int position){ return items.get(position); } public static class ViewHolder extends RecyclerView.ViewHolder { public View container; public TextView dag; public TextView maand; public TextView title; public TextView date; public CardView cv; public ViewHolder(View itemView) { super(itemView); container = itemView.findViewById(R.id.container); date = (TextView) itemView.findViewById(R.id.lblDate); title = (TextView) itemView.findViewById(R.id.lblTitle); dag = (TextView) itemView.findViewById(R.id.txtDag); maand = (TextView) itemView.findViewById(R.id.txtMaand); cv = (CardView) itemView.findViewById(R.id.CvCalItem); } } }