package fr.free.nrw.commons.category;


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

import java.util.ArrayList;
import java.util.TreeSet;

import fr.free.nrw.commons.R;

public class CategoriesAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<CategorizationFragment.CategoryItem> items;

    private static final int TYPE_ITEM = 0;
    private static final int TYPE_SEPARATOR = 1;
    private TreeSet<Integer> sectionHeader = new TreeSet<Integer>();

    private CategoriesAdapter(Context context, ArrayList<CategorizationFragment.CategoryItem> items) {
        this.context = context;
        this.items = items;
    }

    public int getCount() {
        return items.size();
    }

    public Object getItem(int i) {
        return items.get(i);
    }

    public ArrayList<CategorizationFragment.CategoryItem> getItems() {
        return items;
    }

    public void setItems(ArrayList<CategorizationFragment.CategoryItem> items) {
        this.items = items;
    }

    public long getItemId(int i) {
        return i;
    }

    @Override
    public int getItemViewType(int position) {
        // If type is 1, the line is a header, otherwise it is an item
        return sectionHeader.contains(position) ? TYPE_SEPARATOR : TYPE_ITEM;
    }

    @Override
    public int getViewTypeCount() {
        return 2;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        CheckedTextView checkedView;

        if(view == null) {
            checkedView = (CheckedTextView) getActivity().getLayoutInflater().inflate(R.layout.layout_categories_item, null);

        } else {
            checkedView = (CheckedTextView) view;
        }

        CategorizationFragment.CategoryItem item = (CategorizationFragment.CategoryItem) this.getItem(i);
        checkedView.setChecked(item.selected);
        checkedView.setText(item.name);
        checkedView.setTag(i);

        return checkedView;
    }

    // TODO: Separator getView reference
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        int rowType = getItemViewType(position);

        if (convertView == null) {
            holder = new ViewHolder();
            switch (rowType) {
                case TYPE_ITEM:
                    convertView = mInflater.inflate(R.layout.snippet_item1, null);
                    holder.textView = (TextView) convertView.findViewById(R.id.text);
                    break;
                case TYPE_SEPARATOR:
                    convertView = mInflater.inflate(R.layout.snippet_item2, null);
                    holder.textView = (TextView) convertView.findViewById(R.id.textSeparator);
                    break;
            }
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.textView.setText(mData.get(position));

        return convertView;
    }

    public static class ViewHolder {
        public TextView textView;
    }
}
@@ -65,16 +65,52 @@
 ontext;%0A
+import android.view.LayoutInflater;%0A
 import a
@@ -500,16 +500,55 @@
 items;%0A%0A
+    private LayoutInflater mInflater;%0A%0A
     priv
@@ -707,22 +707,21 @@
 ;%0A%0A    p
-rivate
+ublic
  Categor

Make constructor public