package com.example.android.miwok;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Miwok Created by Muir on 03/05/2017.
 */

public class WordAdapter extends ArrayAdapter<Word>{

    private static final String LOG_TAG = WordAdapter.class.getSimpleName();

    public WordAdapter(Activity context, ArrayList<Word> words){
        super(context, 0, words);
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View listItemView = convertView;

        if (listItemView == null){
            listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
        }

        Word currentWord = getItem(position);

        TextView miwokWordTextView = (TextView) listItemView.findViewById(R.id.miwok_text_view);
        miwokWordTextView.setText(currentWord.getMiwokTranslation());

        TextView defaultWordTextview = (TextView) listItemView.findViewById(R.id.default_text_view);
        defaultWordTextview.setText(currentWord.getDefaultTranslation());

        //ImageView iconView = (ImageView) listItemView.findViewById(R.id.list_item_icon);
        //iconView.setImageResource(currentWord.getImageResourceId());
        return listItemView;
    }
}

@@ -743,16 +743,99 @@
 arent) %7B
+%0A%0A        // Check if the existing view is being reused, otherwise inflate the view
 %0A       
@@ -1032,46 +1032,210 @@
     
-Word currentWord = getItem(position);%0A
+// Get the @link WordAdapter object located at this position in the list.%0A        Word currentWord = getItem(position);%0A%0A        // Find the TextView in the list_item.xml layout with the ID version name
 %0A   
@@ -1249,28 +1249,24 @@
 xtView miwok
-Word
 TextView = (
@@ -1324,24 +1324,25 @@
 _view);%0A
+%0A
         
 miwokWor
@@ -1337,70 +1337,246 @@
     
-miwokWordTextView.setText(currentWord.getMiwokTranslation());%0A
+// Get the Miwok word from the current Word object and set this text on the Word TextView%0A        miwokTextView.setText(currentWord.getMiwokTranslation());%0A%0A        // Find the TextView in the list_item.xml layout with the ID version name
 %0A   
@@ -1596,25 +1596,21 @@
  default
-Word
 Text
-v
+V
 iew = (T
@@ -1669,24 +1669,25 @@
 _view);%0A
+%0A
         
 defaultW
@@ -1682,24 +1682,120 @@
     
-defaultWordTextv
+// Get the default word from the current Word object and set this text on the Word TextView%0A        defaultTextV
 iew.
@@ -2002,16 +2002,110 @@
 ceId());
+%0A%0A        // Return the whole list item layout (contains 2 TextViews) so that it can be shown.
 %0A       

Add comments to WordAdapter.java