package edu.rosehulman.moviequotes;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class MovieQuoteArrayAdapter extends BaseAdapter {
    private final LayoutInflater mInflater;
    private List<MovieQuote> mMovieQuotes;
    public MovieQuoteArrayAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
        mMovieQuotes = new ArrayList<MovieQuote>();
    }

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

    public void removeItem(MovieQuote movieQuote) {
        //TODO: Remove the next line(s) and use Firebase instead
        mMovieQuotes.remove(movieQuote);
    }

    public void addItem(MovieQuote movieQuote) {
        //TODO: Remove the next line(s) and use Firebase instead
        mMovieQuotes.add(movieQuote);
        notifyDataSetChanged();


    }

    public void updateItem(MovieQuote movieQuote, String newMovie, String newQuote) {
        //TODO: Remove the next line(s) and use Firebase instead
        movieQuote.setMovie(newMovie);
        movieQuote.setQuote(newQuote);
        notifyDataSetChanged();
    }

    @Override
    public MovieQuote getItem(int position) {
        return mMovieQuotes.get(position);
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view;
        if (convertView == null) {
            view = mInflater.inflate(android.R.layout.simple_expandable_list_item_2, parent, false);
        } else {
            view = convertView;
        }
        TextView titleTextView = (TextView) view.findViewById(android.R.id.text2);
        MovieQuote movieQuote = getItem(position);
        titleTextView.setText(movieQuote.getMovie());
        TextView quoteTextView = (TextView) view.findViewById(android.R.id.text1);
        quoteTextView.setText(movieQuote.getQuote());
        return view;
    }

}
@@ -671,173 +671,8 @@
  %7D%0A%0A
-    public void removeItem(MovieQuote movieQuote) %7B%0A        //TODO: Remove the next line(s) and use Firebase instead%0A        mMovieQuotes.remove(movieQuote);%0A    %7D%0A%0A
     
@@ -708,32 +708,32 @@
 e movieQuote) %7B%0A
+
         //TODO: 
@@ -851,18 +851,16 @@
 nged();%0A
-%0A%0A
     %7D%0A%0A 
@@ -1079,32 +1079,32 @@
 uote(newQuote);%0A
-
         notifyDa
@@ -1118,32 +1118,197 @@
 anged();%0A    %7D%0A%0A
+    public void removeItem(MovieQuote movieQuote) %7B%0A        //TODO: Remove the next line(s) and use Firebase instead%0A        mMovieQuotes.remove(movieQuote);%0A    %7D%0A%0A
     @Override%0A  

Reorder add -> update -> remove