// Path: app/src/main/java/com/gigabytedevelopersinc/app/calculator/view/HistoryLine.java
// public class HistoryLine extends LinearLayout {
//     private static final int COPY = 0;
//     private static final int COPY_BASE = 1;
//     private static final int COPY_EDITED = 2;
//     private static final int REMOVE = 3;
//     private String[] mMenuItemsStrings;
//     private HistoryEntry mHistoryEntry;
//     private History mHistory;
//     private BaseAdapter mAdapter;
// 
//     public HistoryLine(Context context, AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     @Override
//     public void onCreateContextMenu(ContextMenu menu) {
//         MenuHandler handler = new MenuHandler();
//         if(mMenuItemsStrings == null) {
//             Resources resources = getResources();
//             mMenuItemsStrings = new String[4];
//             mMenuItemsStrings[COPY] = String.format(resources.getString(R.string.copy), mHistoryEntry.getBase() + "=" + mHistoryEntry.getEdited());
//             mMenuItemsStrings[COPY_BASE] = String.format(resources.getString(R.string.copy), mHistoryEntry.getBase());
//             mMenuItemsStrings[COPY_EDITED] = String.format(resources.getString(R.string.copy), mHistoryEntry.getEdited());
//             mMenuItemsStrings[REMOVE] = resources.getString(R.string.remove_from_history);
//         }
//         for(int i = 0; i < mMenuItemsStrings.length; i++) {
//             menu.add(Menu.NONE, i, i, mMenuItemsStrings[i]).setOnMenuItemClickListener(handler);
//         }
//     }
// 
//     private class MenuHandler implements MenuItem.OnMenuItemClickListener {
//         public boolean onMenuItemClick(MenuItem item) {
//             return onTextContextMenuItem(item.getTitle());
//         }
//     }
// 
//     public boolean onTextContextMenuItem(CharSequence title) {
//         boolean handled = false;
//         if(TextUtils.equals(title, mMenuItemsStrings[COPY])) {
//             copyContent(mHistoryEntry.getBase() + "=" + mHistoryEntry.getEdited());
//             handled = true;
//         }
//         else if(TextUtils.equals(title, mMenuItemsStrings[COPY_BASE])) {
//             copyContent(mHistoryEntry.getBase());
//             handled = true;
//         }
//         else if(TextUtils.equals(title, mMenuItemsStrings[COPY_EDITED])) {
//             copyContent(mHistoryEntry.getEdited());
//             handled = true;
//         }
//         else if(TextUtils.equals(title, mMenuItemsStrings[REMOVE])) {
//             removeContent();
//             handled = true;
//         }
//         return handled;
//     }
// 
//     public void copyContent(String content) {
//         ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
//         clipboard.setPrimaryClip(ClipData.newPlainText(null, content));
//         String toastText = String.format(getResources().getString(R.string.text_copied_toast), content);
//         Toast.makeText(getContext(), toastText, Toast.LENGTH_SHORT).show();
//     }
// 
//     private void removeContent() {
//         mHistory.remove(mHistoryEntry);
//         mAdapter.notifyDataSetChanged();
//     }
// 
//     public HistoryEntry getHistoryEntry() {
//         return mHistoryEntry;
//     }
// 
//     public void setHistoryEntry(HistoryEntry historyEntry) {
//         this.mHistoryEntry = historyEntry;
//     }
// 
//     public History getHistory() {
//         return mHistory;
//     }
// 
//     public void setHistory(History history) {
//         this.mHistory = history;
//     }
// 
//     public BaseAdapter getAdapter() {
//         return mAdapter;
//     }
// 
//     public void setAdapter(BaseAdapter adapter) {
//         this.mAdapter = adapter;
//     }
// 
//     public void showMenu() {
//         showContextMenu();
//     }
// }


import java.util.Vector;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.gigabytedevelopersinc.app.calculator.view.HistoryLine;

package com.gigabytedevelopersinc.app.calculator;




class HistoryAdapter extends BaseAdapter {
    private final Vector<HistoryEntry> mEntries;
    private final LayoutInflater mInflater;
    private final EquationFormatter mEquationFormatter;
    private final History mHistory;

    HistoryAdapter(Context context, History history) {
        mEntries = history.mEntries;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mEquationFormatter = new EquationFormatter();
        mHistory = history;
    }

    @Override
    public int getCount() {
        return mEntries.size() - 1;
    }

    @Override
    public Object getItem(int position) {
        return mEntries.elementAt(position);
    }

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

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
// Path: app/src/main/java/com/gigabytedevelopersinc/app/calculator/view/HistoryLine.java
// public class HistoryLine extends LinearLayout {
//     private static final int COPY = 0;
//     private static final int COPY_BASE = 1;
//     private static final int COPY_EDITED = 2;
//     private static final int REMOVE = 3;
//     private String[] mMenuItemsStrings;
//     private HistoryEntry mHistoryEntry;
//     private History mHistory;
//     private BaseAdapter mAdapter;
// 
//     public HistoryLine(Context context, AttributeSet attrs) {
//         super(context, attrs);
//     }
// 
//     @Override
//     public void onCreateContextMenu(ContextMenu menu) {
//         MenuHandler handler = new MenuHandler();
//         if(mMenuItemsStrings == null) {
//             Resources resources = getResources();
//             mMenuItemsStrings = new String[4];
//             mMenuItemsStrings[COPY] = String.format(resources.getString(R.string.copy), mHistoryEntry.getBase() + "=" + mHistoryEntry.getEdited());
//             mMenuItemsStrings[COPY_BASE] = String.format(resources.getString(R.string.copy), mHistoryEntry.getBase());
//             mMenuItemsStrings[COPY_EDITED] = String.format(resources.getString(R.string.copy), mHistoryEntry.getEdited());
//             mMenuItemsStrings[REMOVE] = resources.getString(R.string.remove_from_history);
//         }
//         for(int i = 0; i < mMenuItemsStrings.length; i++) {
//             menu.add(Menu.NONE, i, i, mMenuItemsStrings[i]).setOnMenuItemClickListener(handler);
//         }
//     }
// 
//     private class MenuHandler implements MenuItem.OnMenuItemClickListener {
//         public boolean onMenuItemClick(MenuItem item) {
//             return onTextContextMenuItem(item.getTitle());
//         }
//     }
// 
//     public boolean onTextContextMenuItem(CharSequence title) {
//         boolean handled = false;
//         if(TextUtils.equals(title, mMenuItemsStrings[COPY])) {
//             copyContent(mHistoryEntry.getBase() + "=" + mHistoryEntry.getEdited());
//             handled = true;
//         }
//         else if(TextUtils.equals(title, mMenuItemsStrings[COPY_BASE])) {
//             copyContent(mHistoryEntry.getBase());
//             handled = true;
//         }
//         else if(TextUtils.equals(title, mMenuItemsStrings[COPY_EDITED])) {
//             copyContent(mHistoryEntry.getEdited());
//             handled = true;
//         }
//         else if(TextUtils.equals(title, mMenuItemsStrings[REMOVE])) {
//             removeContent();
//             handled = true;
//         }
//         return handled;
//     }
// 
//     public void copyContent(String content) {
//         ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
//         clipboard.setPrimaryClip(ClipData.newPlainText(null, content));
//         String toastText = String.format(getResources().getString(R.string.text_copied_toast), content);
//         Toast.makeText(getContext(), toastText, Toast.LENGTH_SHORT).show();
//     }
// 
//     private void removeContent() {
//         mHistory.remove(mHistoryEntry);
//         mAdapter.notifyDataSetChanged();
//     }
// 
//     public HistoryEntry getHistoryEntry() {
//         return mHistoryEntry;
//     }
// 
//     public void setHistoryEntry(HistoryEntry historyEntry) {
//         this.mHistoryEntry = historyEntry;
//     }
// 
//     public History getHistory() {
//         return mHistory;
//     }
// 
//     public void setHistory(History history) {
//         this.mHistory = history;
//     }
// 
//     public BaseAdapter getAdapter() {
//         return mAdapter;
//     }
// 
//     public void setAdapter(BaseAdapter adapter) {
//         this.mAdapter = adapter;
//     }
// 
//     public void showMenu() {
//         showContextMenu();
//     }
// }


// Path: app/src/main/java/com/gigabytedevelopersinc/app/calculator/HistoryAdapter.java
import java.util.Vector;
import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.gigabytedevelopersinc.app.calculator.view.HistoryLine;


package com.gigabytedevelopersinc.app.calculator;




class HistoryAdapter extends BaseAdapter {
    private final Vector<HistoryEntry> mEntries;
    private final LayoutInflater mInflater;
    private final EquationFormatter mEquationFormatter;
    private final History mHistory;

    HistoryAdapter(Context context, History history) {
        mEntries = history.mEntries;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mEquationFormatter = new EquationFormatter();
        mHistory = history;
    }

    @Override
    public int getCount() {
        return mEntries.size() - 1;
    }

    @Override
    public Object getItem(int position) {
        return mEntries.elementAt(position);
    }

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

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        HistoryLine view;