/*
 * Copyright (c) 2015 Justin White <jw@justinwhite.net>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its
 * contributors may be used to endorse or promote products derived from this
 * software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */

package net.justinwhite.score_it;

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 net.justinwhite.score_model.phase_10.Phase10PlayerModel;

import java.util.List;

public class Phase10PlayerAdapter extends ArrayAdapter<Phase10PlayerModel> {

    private final List<Phase10PlayerModel> players;
    private final int layoutID;
    private final Context context;
    LayoutInflater layoutInflater;

    public Phase10PlayerAdapter(Context _context, int _layoutID, List<Phase10PlayerModel> _players) {
        super(_context, _layoutID, _players);
        context = _context;
        layoutID = _layoutID;
        players = _players;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return players.size();
    }

    @Override
    public Phase10PlayerModel getItem(int position) {
        return players.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        if (view == null) {
            view = layoutInflater.inflate(layoutID, null);
        }

        Phase10PlayerModel p = players.get(position);

        TextView textPlayerName = (TextView) view.findViewById(R.id.textPlayerName);
//        TextView textPlayerScore = (TextView) view.findViewById(R.id.textPlayerScore);
//        TextView textPlayerPhase = (TextView) view.findViewById(R.id.textPlayerPhase);

        textPlayerName.setText(p.getName());
//        textPlayerScore.setText(p.getScore());
//        textPlayerPhase.setText(p.getPhase());

        return view;
    }
}

@@ -1904,16 +1904,74 @@
 .List;%0A%0A
+import butterknife.Bind;%0Aimport butterknife.ButterKnife;%0A%0A
 public c
@@ -2844,24 +2844,52 @@
 p parent) %7B%0A
+        ViewHolder holder;%0A%0A
         if (
@@ -2956,20 +2956,171 @@
 youtID, 
-null
+parent, false);%0A            holder = new ViewHolder(view);%0A            view.setTag(holder);%0A        %7D else %7B%0A            holder = (ViewHolder) view.getTag(
 );%0A     
@@ -3184,33 +3184,31 @@
 );%0A%0A        
-TextView 
+holder.
 textPlayerNa
@@ -3213,59 +3213,28 @@
 Name
- = (TextView) view.findViewById(R.id.textPlayer
+.setText(p.get
 Name
+()
 );%0A/
@@ -3238,33 +3238,24 @@
 ;%0A//        
-TextView 
 textPlayerSc
@@ -3261,60 +3261,29 @@
 core
- = (TextView) view.findViewById(R.id.textPlayer
+.setText(p.get
 Score
+()
 );%0A/
@@ -3295,17 +3295,8 @@
     
-TextView 
 text
@@ -3310,38 +3310,103 @@
 hase
- = (TextView) view.findViewByI
+.setText(p.getPhase());%0A%0A        return view;%0A    %7D%0A%0A    static class ViewHolder %7B%0A        @Bin
 d(R.
@@ -3422,16 +3422,13 @@
 ayer
-Phase);%0A
+Name)
 %0A   
@@ -3424,32 +3424,41 @@
 erName)%0A        
+TextView 
 textPlayerName.s
@@ -3459,127 +3459,148 @@
 Name
-.setText(p.getName());%0A//        textPlayerScore.setText(p.getScore());%0A//        textPlayerPhase.setText(p.get
+;%0A        @Bind(R.id.textPlayerScore)%0A        TextView textPlayerScore;%0A        @Bind(R.id.textPlayerPhase)%0A        TextView textPlayer
 Phase
-())
 ;%0A%0A 
@@ -3606,29 +3606,100 @@
         
-return
+public ViewHolder(View view) %7B%0A            ButterKnife.bind(this,
  view
+)
 ;%0A    
+  
-%7D
+  %7D%0A    %7D%0A
 %0A%7D%0A

Use Butterknife and a ViewHolder in the adapter.