// Path: app/src/main/java/org/noorganization/instalist/view/touchlistener/IOnShoppingListClickListenerEvents.java
// public interface IOnShoppingListClickListenerEvents {
// 
//     /**
//      * Called when a ShoppingList was clicked.
//      * @param _ShoppingList the ShoppingList object that was clicked.
//      */
//     void onShoppingListClicked(ShoppingList _ShoppingList);
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/touchlistener/OnShoppingListClickListener.java
// public class OnShoppingListClickListener implements View.OnClickListener {
// 
//     private ShoppingList mShoppingList;
//     private IOnShoppingListClickListenerEvents mOnShoppingListClickEvent;
// 
//     /**
//      * Constructor of OnShoppingListClickListener.
//      * @param _IOnShoppingListClickEvent The interface for handling ShoppingList clicks.
//      * @param _ShoppingList The ShoppingList that is handled when a click on it occurs.
//      */
//     public OnShoppingListClickListener(IOnShoppingListClickListenerEvents _IOnShoppingListClickEvent, ShoppingList _ShoppingList){
//         mShoppingList = _ShoppingList;
//         mOnShoppingListClickEvent = _IOnShoppingListClickEvent;
//     }
// 
//     @Override
//     public void onClick(View v) {
//         mOnShoppingListClickEvent.onShoppingListClicked(mShoppingList);
//         //EventBus.getDefault().post(new ShoppingListSelectedMessage(mShoppingList));
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/interfaces/IShoppingListAdapter.java
// public interface IShoppingListAdapter {
//     /**
//      * Adds the given ShoppingList to the adapter.
//      * @param _ShoppingList the ShoppingList to be added.
//      */
//     void addList(ShoppingList _ShoppingList);
// 
//     /**
//      * Updates the given ShoppingList in Adapter.
//      * @param _ShoppingList the ShoppingList to be updated.
//      */
//     void updateList(ShoppingList _ShoppingList);
// 
//     /**
//      * Removes the given ShoppingList from the adapter.
//      * @param _ShoppingList The ShoppingList to remove.
//      */
//     void removeList(ShoppingList _ShoppingList);
// }


import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import org.noorganization.instalist.R;
import org.noorganization.instalist.presenter.IListController;
import org.noorganization.instalist.presenter.implementation.ControllerFactory;
import org.noorganization.instalist.model.ShoppingList;
import org.noorganization.instalist.view.touchlistener.IOnShoppingListClickListenerEvents;
import org.noorganization.instalist.view.touchlistener.OnShoppingListClickListener;
import org.noorganization.instalist.view.interfaces.IShoppingListAdapter;
    private static class ViewHolder {
        TextView mtvListName;
        TextView mtvListItemCount;
    }

    @Override
    public View getView(int _Position, View _ConvertView, ViewGroup _Parent) {
        View shoppingListNamesView = null;

        if (_ConvertView == null) {
            ViewHolder holder = new ViewHolder();
            LayoutInflater shoppingListNamesInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            shoppingListNamesView = shoppingListNamesInflater.inflate(R.layout.expandable_list_view_list_entry, null);
            holder.mtvListName      = (TextView) shoppingListNamesView.findViewById(R.id.expandable_list_view_list_name);
            holder.mtvListItemCount = (TextView) shoppingListNamesView.findViewById(R.id.expandable_list_view_list_entries);
            shoppingListNamesView.setLongClickable(true);
            shoppingListNamesView.setTag(holder);
        } else {
            shoppingListNamesView = _ConvertView;
        }

        ViewHolder holder = (ViewHolder) shoppingListNamesView.getTag();
        ShoppingList shoppingList = getItem(_Position);
        String listName = shoppingList.mName;
        holder.mtvListName.setText(listName);

        holder.mtvListName.setSelected(true);
        holder.mtvListItemCount.setText(String.valueOf(mListController.getEntryCount(shoppingList)));

        shoppingListNamesView.setOnClickListener(
// Path: app/src/main/java/org/noorganization/instalist/view/touchlistener/IOnShoppingListClickListenerEvents.java
// public interface IOnShoppingListClickListenerEvents {
// 
//     /**
//      * Called when a ShoppingList was clicked.
//      * @param _ShoppingList the ShoppingList object that was clicked.
//      */
//     void onShoppingListClicked(ShoppingList _ShoppingList);
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/touchlistener/OnShoppingListClickListener.java
// public class OnShoppingListClickListener implements View.OnClickListener {
// 
//     private ShoppingList mShoppingList;
//     private IOnShoppingListClickListenerEvents mOnShoppingListClickEvent;
// 
//     /**
//      * Constructor of OnShoppingListClickListener.
//      * @param _IOnShoppingListClickEvent The interface for handling ShoppingList clicks.
//      * @param _ShoppingList The ShoppingList that is handled when a click on it occurs.
//      */
//     public OnShoppingListClickListener(IOnShoppingListClickListenerEvents _IOnShoppingListClickEvent, ShoppingList _ShoppingList){
//         mShoppingList = _ShoppingList;
//         mOnShoppingListClickEvent = _IOnShoppingListClickEvent;
//     }
// 
//     @Override
//     public void onClick(View v) {
//         mOnShoppingListClickEvent.onShoppingListClicked(mShoppingList);
//         //EventBus.getDefault().post(new ShoppingListSelectedMessage(mShoppingList));
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/interfaces/IShoppingListAdapter.java
// public interface IShoppingListAdapter {
//     /**
//      * Adds the given ShoppingList to the adapter.
//      * @param _ShoppingList the ShoppingList to be added.
//      */
//     void addList(ShoppingList _ShoppingList);
// 
//     /**
//      * Updates the given ShoppingList in Adapter.
//      * @param _ShoppingList the ShoppingList to be updated.
//      */
//     void updateList(ShoppingList _ShoppingList);
// 
//     /**
//      * Removes the given ShoppingList from the adapter.
//      * @param _ShoppingList The ShoppingList to remove.
//      */
//     void removeList(ShoppingList _ShoppingList);
// }


// Path: app/src/main/java/org/noorganization/instalist/view/listadapter/PlainShoppingListOverviewAdapter.java
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import org.noorganization.instalist.R;
import org.noorganization.instalist.presenter.IListController;
import org.noorganization.instalist.presenter.implementation.ControllerFactory;
import org.noorganization.instalist.model.ShoppingList;
import org.noorganization.instalist.view.touchlistener.IOnShoppingListClickListenerEvents;
import org.noorganization.instalist.view.touchlistener.OnShoppingListClickListener;
import org.noorganization.instalist.view.interfaces.IShoppingListAdapter;

    private static class ViewHolder {
        TextView mtvListName;
        TextView mtvListItemCount;
    }

    @Override
    public View getView(int _Position, View _ConvertView, ViewGroup _Parent) {
        View shoppingListNamesView = null;

        if (_ConvertView == null) {
            ViewHolder holder = new ViewHolder();
            LayoutInflater shoppingListNamesInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            shoppingListNamesView = shoppingListNamesInflater.inflate(R.layout.expandable_list_view_list_entry, null);
            holder.mtvListName      = (TextView) shoppingListNamesView.findViewById(R.id.expandable_list_view_list_name);
            holder.mtvListItemCount = (TextView) shoppingListNamesView.findViewById(R.id.expandable_list_view_list_entries);
            shoppingListNamesView.setLongClickable(true);
            shoppingListNamesView.setTag(holder);
        } else {
            shoppingListNamesView = _ConvertView;
        }

        ViewHolder holder = (ViewHolder) shoppingListNamesView.getTag();
        ShoppingList shoppingList = getItem(_Position);
        String listName = shoppingList.mName;
        holder.mtvListName.setText(listName);

        holder.mtvListName.setSelected(true);
        holder.mtvListItemCount.setText(String.valueOf(mListController.getEntryCount(shoppingList)));

        shoppingListNamesView.setOnClickListener(
                new OnShoppingListClickListener(mIOnShoppingListClickEvents, mShoppingLists.get(_Position)));