// Path: app/src/main/java/org/clintonhealthaccess/lmis/app/adapters/reports/MonthlyVaccineUtilizationReportAdapter.java
// public class MonthlyVaccineUtilizationReportAdapter extends ArrayAdapter<UtilizationItem> {
//     private int resource;
//     private boolean isNamesListView;
//     public LinearLayout.LayoutParams PARAMS = getLayoutParams();
// 
//     public MonthlyVaccineUtilizationReportAdapter(Context context, int resource,
//                                                   List<UtilizationItem> items, boolean isNamesListView) {
//         super(context, resource, items);
//         this.resource = resource;
//         this.isNamesListView = isNamesListView;
//     }
// 
//     private static LinearLayout.LayoutParams getLayoutParams() {
//         LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(50,
//                 ViewGroup.LayoutParams.WRAP_CONTENT, 1);
//         params.setMargins(0, 0, 5, 0);
//         return params;
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         LayoutInflater inflater = (LayoutInflater) getContext()
//                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//         LinearLayout linearLayout = (LinearLayout) inflater.inflate(resource, parent, false);
//         UtilizationItem item = getItem(position);
// 
// 
//         if (isNamesListView) {
//             TextView textView = new TextView(getContext());
//             textView.setText(item.getName());
//             textView.setMaxLines(1);
//             textView.setSingleLine();
//             textView.setEllipsize(TextUtils.TruncateAt.END);
//             textView.setTextColor(getContext().getResources().getColor(R.color.black));
//             setBold(position, textView);
//             linearLayout.addView(textView);
//         } else {
//             for (UtilizationValue value : item.getUtilizationValues()) {
//                 TextView textView = new TextView(getContext());
//                 textView.setText(String.valueOf(value.getValue()));
//                 textView.setLayoutParams(PARAMS);
//                 textView.setGravity(1);
//                 textView.setTextColor(getContext().getResources().getColor(R.color.black));
// 
//                 setBold(position, textView);
//                 linearLayout.addView(textView);
//             }
//         }
// 
//         return linearLayout;
//     }
// 
//     private void setBold(int position, TextView textView) {
//         if (position == 0) {
//             textView.setTypeface(null, Typeface.BOLD);
//         }
//     }
// }
// 
// Path: app/src/main/java/org/clintonhealthaccess/lmis/app/views/NonScrollListView.java
// public class NonScrollListView extends ListView {
// 
//     public NonScrollListView(Context context) {
//         super(context);
//     }
//     public NonScrollListView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//     }
//     public NonScrollListView(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//     }
//     @Override
//     public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//         int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
//                 Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
//         super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
//         ViewGroup.LayoutParams params = getLayoutParams();
//         params.height = getMeasuredHeight();
//     }
// }


import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.inject.Inject;
import org.clintonhealthaccess.lmis.app.R;
import org.clintonhealthaccess.lmis.app.activities.BaseActivity;
import org.clintonhealthaccess.lmis.app.activities.ReportsActivity;
import org.clintonhealthaccess.lmis.app.adapters.reports.MonthlyVaccineUtilizationReportAdapter;
import org.clintonhealthaccess.lmis.app.models.Category;
import org.clintonhealthaccess.lmis.app.models.ReportType;
import org.clintonhealthaccess.lmis.app.models.reports.MonthlyVaccineUtilizationReportItem;
import org.clintonhealthaccess.lmis.app.services.ReportsService;
import org.clintonhealthaccess.lmis.app.utils.DateUtil;
import org.clintonhealthaccess.lmis.app.views.LmisProgressDialog;
import org.clintonhealthaccess.lmis.app.views.NonScrollListView;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import roboguice.inject.InjectView;

    protected ArrayList<String> getLastNYears(int numberOfYears) {
        ArrayList<String> years = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        int currentYear = calendar.get(Calendar.YEAR);
        for (int i = 0; i < numberOfYears; i++) {
            years.add(String.valueOf(currentYear - i));
        }
        return years;
    }

    void setItems() {
        new LoadReportAsyncTask().execute();
    }

    private void reloadReport(List<MonthlyVaccineUtilizationReportItem> reportItems) {
        clearReportItems();

        for (MonthlyVaccineUtilizationReportItem reportItem : reportItems) {
            LinearLayout outerLayout = new LinearLayout(context);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            outerLayout.setLayoutParams(params);
            outerLayout.setOrientation(LinearLayout.HORIZONTAL);

            TextView textView = new TextView(context);
            textView.setWidth(150);
            textView.setText(reportItem.getCommodityName());
            textView.setTextColor(getResources().getColor(R.color.black));
            outerLayout.addView(textView);

// Path: app/src/main/java/org/clintonhealthaccess/lmis/app/adapters/reports/MonthlyVaccineUtilizationReportAdapter.java
// public class MonthlyVaccineUtilizationReportAdapter extends ArrayAdapter<UtilizationItem> {
//     private int resource;
//     private boolean isNamesListView;
//     public LinearLayout.LayoutParams PARAMS = getLayoutParams();
// 
//     public MonthlyVaccineUtilizationReportAdapter(Context context, int resource,
//                                                   List<UtilizationItem> items, boolean isNamesListView) {
//         super(context, resource, items);
//         this.resource = resource;
//         this.isNamesListView = isNamesListView;
//     }
// 
//     private static LinearLayout.LayoutParams getLayoutParams() {
//         LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(50,
//                 ViewGroup.LayoutParams.WRAP_CONTENT, 1);
//         params.setMargins(0, 0, 5, 0);
//         return params;
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         LayoutInflater inflater = (LayoutInflater) getContext()
//                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//         LinearLayout linearLayout = (LinearLayout) inflater.inflate(resource, parent, false);
//         UtilizationItem item = getItem(position);
// 
// 
//         if (isNamesListView) {
//             TextView textView = new TextView(getContext());
//             textView.setText(item.getName());
//             textView.setMaxLines(1);
//             textView.setSingleLine();
//             textView.setEllipsize(TextUtils.TruncateAt.END);
//             textView.setTextColor(getContext().getResources().getColor(R.color.black));
//             setBold(position, textView);
//             linearLayout.addView(textView);
//         } else {
//             for (UtilizationValue value : item.getUtilizationValues()) {
//                 TextView textView = new TextView(getContext());
//                 textView.setText(String.valueOf(value.getValue()));
//                 textView.setLayoutParams(PARAMS);
//                 textView.setGravity(1);
//                 textView.setTextColor(getContext().getResources().getColor(R.color.black));
// 
//                 setBold(position, textView);
//                 linearLayout.addView(textView);
//             }
//         }
// 
//         return linearLayout;
//     }
// 
//     private void setBold(int position, TextView textView) {
//         if (position == 0) {
//             textView.setTypeface(null, Typeface.BOLD);
//         }
//     }
// }
// 
// Path: app/src/main/java/org/clintonhealthaccess/lmis/app/views/NonScrollListView.java
// public class NonScrollListView extends ListView {
// 
//     public NonScrollListView(Context context) {
//         super(context);
//     }
//     public NonScrollListView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//     }
//     public NonScrollListView(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//     }
//     @Override
//     public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
//         int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
//                 Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
//         super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
//         ViewGroup.LayoutParams params = getLayoutParams();
//         params.height = getMeasuredHeight();
//     }
// }


// Path: app/src/main/java/org/clintonhealthaccess/lmis/app/activities/reports/MonthlyVaccineUtilizationReportActivity.java
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.inject.Inject;
import org.clintonhealthaccess.lmis.app.R;
import org.clintonhealthaccess.lmis.app.activities.BaseActivity;
import org.clintonhealthaccess.lmis.app.activities.ReportsActivity;
import org.clintonhealthaccess.lmis.app.adapters.reports.MonthlyVaccineUtilizationReportAdapter;
import org.clintonhealthaccess.lmis.app.models.Category;
import org.clintonhealthaccess.lmis.app.models.ReportType;
import org.clintonhealthaccess.lmis.app.models.reports.MonthlyVaccineUtilizationReportItem;
import org.clintonhealthaccess.lmis.app.services.ReportsService;
import org.clintonhealthaccess.lmis.app.utils.DateUtil;
import org.clintonhealthaccess.lmis.app.views.LmisProgressDialog;
import org.clintonhealthaccess.lmis.app.views.NonScrollListView;
import java.text.DateFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import roboguice.inject.InjectView;


    protected ArrayList<String> getLastNYears(int numberOfYears) {
        ArrayList<String> years = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        int currentYear = calendar.get(Calendar.YEAR);
        for (int i = 0; i < numberOfYears; i++) {
            years.add(String.valueOf(currentYear - i));
        }
        return years;
    }

    void setItems() {
        new LoadReportAsyncTask().execute();
    }

    private void reloadReport(List<MonthlyVaccineUtilizationReportItem> reportItems) {
        clearReportItems();

        for (MonthlyVaccineUtilizationReportItem reportItem : reportItems) {
            LinearLayout outerLayout = new LinearLayout(context);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            outerLayout.setLayoutParams(params);
            outerLayout.setOrientation(LinearLayout.HORIZONTAL);

            TextView textView = new TextView(context);
            textView.setWidth(150);
            textView.setText(reportItem.getCommodityName());
            textView.setTextColor(getResources().getColor(R.color.black));
            outerLayout.addView(textView);

            NonScrollListView listViewItemNames = new NonScrollListView(context);