Android Open Source - Joetz-Android-V2 Kalender 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.calendar;
/*from w w w . ja va 2 s  . c o  m*/
import android.content.Context;
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);

    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;

    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.title.setText(k.getTitle());, endDate));

        mLastDate = k.getDate();

    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) {
            container = itemView.findViewById(;
            date = (TextView) itemView.findViewById(;
            title = (TextView) itemView.findViewById(;
            dag =  (TextView) itemView.findViewById(;
            maand =  (TextView) itemView.findViewById(;
            cv = (CardView) itemView.findViewById(;


Java Source Code List