// Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/Members.java
// public static class Member {
//     private final long id;
//     private final String name;
// 
//     Member(long memberId, String memberName) {
//         this.id = memberId;
//         this.name = memberName;
//     }
// }
// 
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java
// public class MemberCursorWrapper extends CursorWrapper {
//     private final HashMap<String, Integer> mColumnIndexes = new HashMap<>();
// 
//     public MemberCursorWrapper(Cursor cursor) {
//         super(cursor);
//     }
// 
//     public Long getId() {
//         Integer index = getColumnIndex(MemberColumns._ID);
//         if (isNull(index)) return null;
//         return getLong(index);
//     }
// 
//     public String getName() {
//         Integer index = getIndex(MemberColumns.NAME);
//         return getString(index);
//     }
// 
//     public Integer getAverageDuration() {
//         Integer index = getIndex(MemberStatsColumns.AVG_DURATION);
//         return getInt(index);
//     }
// 
//     public Integer getSumDuration() {
//         Integer index = getIndex(MemberStatsColumns.SUM_DURATION);
//         return getInt(index);
//     }
// 
//     private Integer getIndex(String columnName) {
//         Integer index = mColumnIndexes.get(columnName);
//         if (index == null) {
//             index = getColumnIndexOrThrow(columnName);
//             mColumnIndexes.put(columnName, index);
//         }
//         return index;
//     }
// }
// 
// Path: app/src/main/java/ca/rmen/android/scrumchatter/widget/ScrumChatterCursorAdapter.java
// public abstract class ScrumChatterCursorAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<T> {
// 
//     private Cursor mCursor;
// 
//     protected ScrumChatterCursorAdapter() {
//         setHasStableIds(true);
//     }
//     public void changeCursor(Cursor cursor) {
//         if (mCursor == cursor) return;
//         mCursor = cursor;
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public long getItemId(int position) {
//         if (mCursor == null || !mCursor.moveToPosition(position)) {
//             return RecyclerView.NO_ID;
//         }
//         return mCursor.getLong(mCursor.getColumnIndex(BaseColumns._ID));
//     }
// 
//     @Override
//     public int getItemCount() {
//         if (mCursor == null) return 0;
//         else return mCursor.getCount();
//     }
// 
//     protected Cursor getCursor() {
//         return mCursor;
//     }
// }


import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import ca.rmen.android.scrumchatter.R;
import ca.rmen.android.scrumchatter.databinding.MemberListItemBinding;
import ca.rmen.android.scrumchatter.member.list.Members.Member;
import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper;
import ca.rmen.android.scrumchatter.widget.ScrumChatterCursorAdapter;
/*
 * Copyright 2013-2016 Carmen Alvarez
 *
 * This file is part of Scrum Chatter.
 *
 * Scrum Chatter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Scrum Chatter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>.
 */
package ca.rmen.android.scrumchatter.member.list;


/**
 * Adapter for the list of team members.
 */
public class MembersCursorAdapter extends ScrumChatterCursorAdapter<MembersCursorAdapter.MemberViewHolder> {
    private final MemberListener mMemberListener;

    MembersCursorAdapter(MemberListener memberListener) {
        super();
        mMemberListener = memberListener;
    }

    public interface MemberListener {
        void onMemberEdit(Member member);
        void onMemberDelete(Member member);
    }

    @Override
    public MemberViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MemberListItemBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.member_list_item, parent, false);
        binding.getRoot().setTag(binding);
        binding.setMemberListener(mMemberListener);
        return new MemberViewHolder(binding);
    }

    /**
     * Set up the view with the data from the given team member
     */
    @Override
    public void onBindViewHolder(MemberViewHolder holder, int position) {

        // Get the data from the cursor
        @SuppressWarnings("resource")
// Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/Members.java
// public static class Member {
//     private final long id;
//     private final String name;
// 
//     Member(long memberId, String memberName) {
//         this.id = memberId;
//         this.name = memberName;
//     }
// }
// 
// Path: app/src/main/java/ca/rmen/android/scrumchatter/provider/MemberCursorWrapper.java
// public class MemberCursorWrapper extends CursorWrapper {
//     private final HashMap<String, Integer> mColumnIndexes = new HashMap<>();
// 
//     public MemberCursorWrapper(Cursor cursor) {
//         super(cursor);
//     }
// 
//     public Long getId() {
//         Integer index = getColumnIndex(MemberColumns._ID);
//         if (isNull(index)) return null;
//         return getLong(index);
//     }
// 
//     public String getName() {
//         Integer index = getIndex(MemberColumns.NAME);
//         return getString(index);
//     }
// 
//     public Integer getAverageDuration() {
//         Integer index = getIndex(MemberStatsColumns.AVG_DURATION);
//         return getInt(index);
//     }
// 
//     public Integer getSumDuration() {
//         Integer index = getIndex(MemberStatsColumns.SUM_DURATION);
//         return getInt(index);
//     }
// 
//     private Integer getIndex(String columnName) {
//         Integer index = mColumnIndexes.get(columnName);
//         if (index == null) {
//             index = getColumnIndexOrThrow(columnName);
//             mColumnIndexes.put(columnName, index);
//         }
//         return index;
//     }
// }
// 
// Path: app/src/main/java/ca/rmen/android/scrumchatter/widget/ScrumChatterCursorAdapter.java
// public abstract class ScrumChatterCursorAdapter<T extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<T> {
// 
//     private Cursor mCursor;
// 
//     protected ScrumChatterCursorAdapter() {
//         setHasStableIds(true);
//     }
//     public void changeCursor(Cursor cursor) {
//         if (mCursor == cursor) return;
//         mCursor = cursor;
//         notifyDataSetChanged();
//     }
// 
//     @Override
//     public long getItemId(int position) {
//         if (mCursor == null || !mCursor.moveToPosition(position)) {
//             return RecyclerView.NO_ID;
//         }
//         return mCursor.getLong(mCursor.getColumnIndex(BaseColumns._ID));
//     }
// 
//     @Override
//     public int getItemCount() {
//         if (mCursor == null) return 0;
//         else return mCursor.getCount();
//     }
// 
//     protected Cursor getCursor() {
//         return mCursor;
//     }
// }


// Path: app/src/main/java/ca/rmen/android/scrumchatter/member/list/MembersCursorAdapter.java
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import ca.rmen.android.scrumchatter.R;
import ca.rmen.android.scrumchatter.databinding.MemberListItemBinding;
import ca.rmen.android.scrumchatter.member.list.Members.Member;
import ca.rmen.android.scrumchatter.provider.MemberCursorWrapper;
import ca.rmen.android.scrumchatter.widget.ScrumChatterCursorAdapter;

/*
 * Copyright 2013-2016 Carmen Alvarez
 *
 * This file is part of Scrum Chatter.
 *
 * Scrum Chatter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Scrum Chatter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Scrum Chatter. If not, see <http://www.gnu.org/licenses/>.
 */
package ca.rmen.android.scrumchatter.member.list;


/**
 * Adapter for the list of team members.
 */
public class MembersCursorAdapter extends ScrumChatterCursorAdapter<MembersCursorAdapter.MemberViewHolder> {
    private final MemberListener mMemberListener;

    MembersCursorAdapter(MemberListener memberListener) {
        super();
        mMemberListener = memberListener;
    }

    public interface MemberListener {
        void onMemberEdit(Member member);
        void onMemberDelete(Member member);
    }

    @Override
    public MemberViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MemberListItemBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.member_list_item, parent, false);
        binding.getRoot().setTag(binding);
        binding.setMemberListener(mMemberListener);
        return new MemberViewHolder(binding);
    }

    /**
     * Set up the view with the data from the given team member
     */
    @Override
    public void onBindViewHolder(MemberViewHolder holder, int position) {

        // Get the data from the cursor
        @SuppressWarnings("resource")
        MemberCursorWrapper memberCursorWrapper = new MemberCursorWrapper(getCursor());