package de.fau.cs.mad.kwikshop.android.view;

import java.util.ArrayList;


import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;


import butterknife.ButterKnife;
import butterknife.InjectView;
import de.fau.cs.mad.kwikshop.android.R;
import de.fau.cs.mad.kwikshop.android.common.Setting;


public class SettingAdapter extends ArrayAdapter<Setting> {

    private ArrayList<Setting> settingsList;
    private int row;
    private Activity activity;

    @InjectView(R.id.tvsetname)
    TextView tvSetname;

    @InjectView(R.id.tvsetdesc)
    TextView tvSetdesc;

    @InjectView(R.id.setcheckbox)
    CheckBox checkbox;

    public SettingAdapter(Activity act, int resource, ArrayList<Setting> settingsList) {
        super(act, resource, settingsList);
        this.activity = act;
        this.row = resource;
        this.settingsList = settingsList;

    }

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


        //if view is null, inflate a new one
        if (view == null) {
            LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = inflater.inflate(row, null);
        }
        ButterKnife.inject(this, view);

        tvSetname.setText(settingsList.get(position).getName());
        tvSetdesc.setText(settingsList.get(position).getCaption());
        checkbox.setVisibility(View.INVISIBLE);

        return view;
    }

}
@@ -1566,55 +1566,409 @@
 ));%0A
-        checkbox.setVisibility(View.INVISIBLE);
+%0A        // setup checkbox%0A        if(settingsList.get(position).getViewVisibility() == View.INVISIBLE)%7B%0A            checkbox.setVisibility(View.INVISIBLE);%0A        %7D else %7B%0A            checkbox.setVisibility(View.VISIBLE);%0A            checkbox.setChecked(settingsList.get(position).isChecked());%0A            checkbox.setFocusable(false);%0A            checkbox.setFocusableInTouchMode(false);%0A        %7D
 %0A%0A  
@@ -1993,9 +1993,11 @@
 %0A    %7D%0A%0A
+%0A%0A
 %7D

add setting to enable / disable location tracking