package org.openhab.habclient.rule;

import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;

import org.openhab.domain.IOpenHABWidgetProvider;
import org.openhab.domain.model.OpenHABWidget;
import org.openhab.domain.rule.IRuleOperationProvider;
import org.openhab.domain.rule.operators.RuleOperator;
import org.openhab.domain.rule.RuleOperatorType;
import org.openhab.domain.rule.UnitEntityDataType;
import org.openhab.habdroid.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Tony Alpskog in 2014.
 */
public class AdapterProvider {
    public static List<String> getRuleOperatorList(Context context, String openHABItemName, boolean includeNonSelectionValue, IRuleOperationProvider ruleOperationProvider, IOpenHABWidgetProvider widgetProvider) {
        HashMap<RuleOperatorType, RuleOperator<?>> operatorHash = ruleOperationProvider.getUnitRuleOperator(widgetProvider.getWidgetByItemName(openHABItemName));
        List<String> adapterList = new ArrayList<String>();
        if(includeNonSelectionValue) adapterList.add(context.getString(R.string.no_value));
        for(RuleOperatorType operatorType : operatorHash.keySet())
            adapterList.add(operatorType.getName());
        return adapterList;
    }

    public static BaseAdapter getRuleOperatorAdapter(Context context, String openHABItemName, IRuleOperationProvider ruleOperationProvider, IOpenHABWidgetProvider widgetProvider) {
        return new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, getRuleOperatorList(context, openHABItemName, true, ruleOperationProvider, widgetProvider));
    }

    public static BaseAdapter getStaticUnitValueAdapter(Context context, String openHABItemName, IOpenHABWidgetProvider widgetProvider) {
        OpenHABWidget openHABWidget = widgetProvider.getWidgetByItemName(openHABItemName);
        UnitEntityDataType unitEntityDataType = UnitEntityDataType.getUnitEntityDataType(openHABWidget);
        Map<String, ?> staticValueHash = unitEntityDataType.getStaticValues();
        if(staticValueHash == null)
            return null;
        List<String> toList = new ArrayList<String>();
        toList.add(context.getString(R.string.no_value));
        toList.addAll(staticValueHash.keySet());
        return new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, toList);
    }
}

@@ -1334,375 +1334,8 @@
  %7D%0A%0A
-    public static BaseAdapter getRuleOperatorAdapter(Context context, String openHABItemName, IRuleOperationProvider ruleOperationProvider, IOpenHABWidgetProvider widgetProvider) %7B%0A        return new ArrayAdapter%3CString%3E(context, android.R.layout.simple_list_item_1, getRuleOperatorList(context, openHABItemName, true, ruleOperationProvider, widgetProvider));%0A    %7D%0A%0A
     

Remove unused static method