/*
 * Copyright (c) 2015. Ncomz. All Rights Reserved
 */

package com.ntels.onecable.view.things;

import com.ntels.onecable.R;
import com.ntels.onecable.common.AppConfig;
import com.ntels.onecable.common.Constants;
import com.ntels.onecable.common.c_interface.ListInterface;
import com.ntels.onecable.common.util.LogUtil;
import com.ntels.onecable.common.util.Util;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import java.util.ArrayList;
import java.util.HashMap;

import static com.ntels.onecable.common.c_interface.ListInterface.ON_CALL_ACTION_EXECUTE;

/**
 * <pre>
 * 1. ClassName :   ThingsDetailVpAdapter
 * 2. FileName  :   ThingsDetailVpAdapter.java
 * 3. Package   :   com.ntels.onecable.view.things
 * 4. Date      :   2016-11-25
 * 5. Author    :   aaron
 * 6. Comment   :   Initialize
 * </pre>
 */
class ThingsDetailVpAdapter extends PagerAdapter {

    private static final String TAG = ThingsDetailVpAdapter.class.getSimpleName();

    private ListInterface mAdapterCallback;
    private Context mContext;
    private Util mUtil = new Util();
    private AppConfig mAppConfig;
    private String mHttpValue = "";
    private int mCurrentPosition = -1;
    private boolean mIsHideDivider = false;

    private SparseArray<View> mViews = new SparseArray<>();
    private ArrayList<HashMap<String, Object>> mTotalList;


    /**
     * 생성자.
     *
     * @param context         컨텍스트
     * @param alval           data
     * @param adapterCallback 콜백 object
     */
    ThingsDetailVpAdapter(final Context context, ArrayList<HashMap<String, Object>> alval,
                          ListInterface adapterCallback) {

        this.mContext = context;
        mTotalList = alval;
        mAppConfig = (AppConfig) this.mContext.getApplicationContext();
        try {
            this.mAdapterCallback = adapterCallback;
        } catch (ClassCastException ex) {
            ex.printStackTrace();
            //            throw new ClassCastException("Activity must implement AdapterCallback.");
        }
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {

        View view = (View) object;
        ViewPager viewPager = (ViewPager) container;
        viewPager.removeView(view);
        mViews.remove(position);
    }

    @Override
    public int getItemPosition(Object object) {

        return POSITION_NONE;
    }

    @Override
    public int getCount() {

        return mTotalList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {

        return view.equals(object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        HashMap<String, Object> hmItem;
        hmItem = mTotalList.get(position);

        String httpOnlineState = mUtil.null2string(hmItem.get(Constants.KEY_ONLINE_STATE));
        String httpCmdclsName = mUtil.null2string(hmItem.get(Constants.KEY_CMDCLS_NAME));
        String httpUnit = mUtil.null2string(hmItem.get(Constants.KEY_UNIT));
        String httpCmdclsTypeId = mUtil.null2string(hmItem.get(Constants.KEY_CMDCLS_TYPE_ID));
        String httpContentValue = mUtil.null2string(hmItem.get(Constants.KEY_CONTENT_VALUE));
        LogUtil.i(TAG, "KEY_content_value1 : " + httpContentValue);

        String tempValue;
        String select = mUtil.getStringValues(mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId
                + "_BG_DEFAULT");
        if ("".equals(httpContentValue)) {
            tempValue = mUtil.getStringValues(mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId
                    + "_" + select);
            httpContentValue = select;
        } else {
            tempValue = mUtil.getStringValues(mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId + "_"
                    + httpContentValue);
        }

        LayoutInflater inflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout childView = (LinearLayout) inflater.inflate(R.layout.row_things_detail_list,
                null);

        mUtil.getView(childView, R.id.llRowBody1).setVisibility(View.VISIBLE);
        mUtil.getView(childView, R.id.llRowBody2).setVisibility(View.GONE);
        mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.GONE);
        mUtil.getView(childView, R.id.btnRowBody1_Contents_On).setVisibility(View.GONE);
        mUtil.getView(childView, R.id.btnRowBody1_Contents_Off).setVisibility(View.GONE);
        mUtil.getView(childView, R.id.btnRowBody1_Contents_Lock).setVisibility(View.GONE);
        mUtil.getView(childView, R.id.tvRowBody1_NodeName).setVisibility(View.GONE);
        mUtil.getView(childView, R.id.levelImageView).setVisibility(View.GONE);
        mUtil.getView(childView, R.id.llRowBody1_Page_Icon).setVisibility(View.GONE);

        if (getCount() > 1) {
            mUtil.getView(childView, R.id.tvRowBody1_NodeName).setVisibility(View.VISIBLE);
            mUtil.getTextView(childView, R.id.tvRowBody1_NodeName).setText(httpCmdclsName);
            mUtil.getView(childView, R.id.llRowBody1_Page_Icon).setVisibility(View.VISIBLE);
        }

        if (mIsHideDivider) {
            mUtil.getView(childView, R.id.divider_middle).setVisibility(View.GONE);
            mUtil.getView(childView, R.id.divider_last).setVisibility(View.GONE);
            mUtil.getView(childView, R.id.section_last).setVisibility(View.GONE);
        }

        final View vLoding = mUtil.getView(childView, R.id.llLoading1);
        String httpRequestTime = mUtil.null2string(hmItem.get(Constants.KEY_REQUEST_TIME));
        if (!"".equals(httpRequestTime)) {
            LogUtil.i(TAG, "httpRequestTime - " + httpRequestTime);
            vLoding.setVisibility(View.VISIBLE);
        } else {
            vLoding.setVisibility(View.GONE);
        }

        int tempType = 0;
        int cmdclsType = mUtil.null2int(hmItem.get(Constants.KEY_CMDCLS_TYPE_ID));
        switch (cmdclsType) {
            //SENSOR_BINARY
            case Constants.CMDCLS_TYPE_ID_11001:
            case Constants.CMDCLS_TYPE_ID_11002:
            case Constants.CMDCLS_TYPE_ID_11004:
            case Constants.CMDCLS_TYPE_ID_11005:
            case Constants.CMDCLS_TYPE_ID_11006:
            case Constants.CMDCLS_TYPE_ID_11008:
            case Constants.CMDCLS_TYPE_ID_11009:
            case Constants.CMDCLS_TYPE_ID_11010:
            case Constants.CMDCLS_TYPE_ID_11012:
            case Constants.CMDCLS_TYPE_ID_11014:
            case Constants.CMDCLS_TYPE_ID_11016:
            case Constants.CMDCLS_TYPE_ID_11018:
                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                //열감지
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_11003:
                //연기감지 센서
                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_09_00_smoke_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_09_01_smoke_state_none);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_09_02_smoke_state_detect);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_11007:
                //누수감지 센서
                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_10_00_waterleak_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_10_01_waterleak_state_none);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_10_02_waterleak_state_detect);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_11011:
                //문열림 센서
                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_01_00_sensor_door_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_01_01_sensor_door_close);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_01_02_sensor_door_open);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_11013:
                //모션 센서
                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_08_00_motion_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_08_01_motion_state_none);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_08_02_motion_state_detect);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_11015:
                //진동감지 센서
                LogUtil.i(TAG, "sTempValue : " + tempValue);
                LogUtil.i(TAG, "KEY_content_value2 : " + httpContentValue);
                mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                        .setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_14_00_sensor_vibration_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon).setBackgroundResource(
                                        R.drawable.img_things_detail_14_02_sensor_vibration_undetected);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon).setBackgroundResource(
                                        R.drawable.img_things_detail_14_01_sensor_vibration_detected);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_11017:
                //충격 센서
                mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                        .setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_02_00_sensor_shock_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_02_01_sensor_shock_normal);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_02_02_sensor_shock_sensing);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                break;
            //SWITCH_BINARY
            case Constants.CMDCLS_TYPE_ID_17001:
            case Constants.CMDCLS_TYPE_ID_17002:
            case Constants.CMDCLS_TYPE_ID_17005:
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On)
                        .setVisibility(View.VISIBLE);
                mUtil.getTextView(childView, R.id.btnRowBody1_Contents_On)
                        .setText(mUtil.getStringValues(
                                mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId + "_ON"));

                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off)
                        .setVisibility(View.VISIBLE);
                mUtil.getTextView(childView, R.id.btnRowBody1_Contents_Off)
                        .setText(mUtil.getStringValues(
                                mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId + "_OFF"));

                mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                        .setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_06_00_plug_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                    mUtil.getView(childView, R.id.btnRowBody1_Contents_On)
                            .setEnabled(false);
                    mUtil.getView(childView, R.id.btnRowBody1_Contents_Off)
                            .setEnabled(false);
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_06_01_plug_state_off);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_06_02_plug_state_on);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On)
                        .setTag(position);
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On)
                        .setOnClickListener(new View.OnClickListener() {
                            int tag = 0;

                            @Override
                            public void onClick(View view) {

                                tag = (int) view.getTag();
                                setHttpValue("ON");
                                vLoding.setVisibility(View.VISIBLE);
                                mAdapterCallback.onCallAction(ON_CALL_ACTION_EXECUTE, tag);
                            }
                        });
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off)
                        .setTag(position);
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off)
                        .setOnClickListener(new View.OnClickListener() {
                            int tag = 0;

                            @Override
                            public void onClick(View view) {

                                tag = (int) view.getTag();
                                setHttpValue("OFF");
                                vLoding.setVisibility(View.VISIBLE);
                                mAdapterCallback.onCallAction(ON_CALL_ACTION_EXECUTE, tag);
                            }
                        });
                break;
            case Constants.CMDCLS_TYPE_ID_17003:
            case Constants.CMDCLS_TYPE_ID_17004:
                //bulb, led
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On).setVisibility(View.VISIBLE);
                mUtil.getTextView(childView, R.id.btnRowBody1_Contents_On)
                        .setText(mUtil.getStringValues(
                                mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId + "_ON"));

                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off).setVisibility(View.VISIBLE);
                mUtil.getTextView(childView, R.id.btnRowBody1_Contents_Off)
                        .setText(mUtil.getStringValues(
                                mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId + "_OFF"));

                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_12_00_ledbulb_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                    mUtil.getView(childView, R.id.btnRowBody1_Contents_On)
                            .setEnabled(false);
                    mUtil.getView(childView, R.id.btnRowBody1_Contents_Off)
                            .setEnabled(false);
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_12_01_ledbulb_state_off);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_12_02_ledbulb_state_on);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On).setTag(position);
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On)
                        .setOnClickListener(new View.OnClickListener() {
                            int tag = 0;

                            @Override
                            public void onClick(View view) {

                                tag = (int) view.getTag();
                                setHttpValue("ON");
                                vLoding.setVisibility(View.VISIBLE);
                                mAdapterCallback.onCallAction(ON_CALL_ACTION_EXECUTE, tag);
                            }
                        });
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off).setTag(position);
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off)
                        .setOnClickListener(new View.OnClickListener() {
                            int tag = 0;

                            @Override
                            public void onClick(View view) {

                                tag = (int) view.getTag();
                                setHttpValue("OFF");
                                vLoding.setVisibility(View.VISIBLE);
                                mAdapterCallback.onCallAction(ON_CALL_ACTION_EXECUTE, tag);
                            }
                        });
                break;
            case Constants.CMDCLS_TYPE_ID_17006:
                //사이렌
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On).setVisibility(View.VISIBLE);
                mUtil.getTextView(childView, R.id.btnRowBody1_Contents_On)
                        .setText(mUtil.getStringValues(
                                mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId + "_ON"));

                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off).setVisibility(View.VISIBLE);
                mUtil.getTextView(childView, R.id.btnRowBody1_Contents_Off)
                        .setText(mUtil.getStringValues(
                                mContext, "CMDCLS_TYPE_ID_" + httpCmdclsTypeId + "_OFF"));

                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_11_00_siren_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                    mUtil.getView(childView, R.id.btnRowBody1_Contents_On).setEnabled(false);
                    mUtil.getView(childView, R.id.btnRowBody1_Contents_Off).setEnabled(false);
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_11_01_siren_state_off);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_11_02_siren_state_on);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On).setTag(position);
                mUtil.getView(childView, R.id.btnRowBody1_Contents_On)
                        .setOnClickListener(new View.OnClickListener() {
                            int tag = 0;

                            @Override
                            public void onClick(View view) {

                                tag = (int) view.getTag();
                                setHttpValue("ON");
                                vLoding.setVisibility(View.VISIBLE);
                                mAdapterCallback.onCallAction(ON_CALL_ACTION_EXECUTE, tag);
                            }
                        });
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off).setTag(position);
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Off)
                        .setOnClickListener(new View.OnClickListener() {
                            int tag = 0;

                            @Override
                            public void onClick(View view) {

                                tag = (int) view.getTag();
                                setHttpValue("OFF");
                                vLoding.setVisibility(View.VISIBLE);
                                mAdapterCallback.onCallAction(ON_CALL_ACTION_EXECUTE, tag);
                            }
                        });
                break;
            case Constants.CMDCLS_TYPE_ID_36002:
                //가스락
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Lock)
                        .setVisibility(View.VISIBLE);
                mUtil.getTextView(childView, R.id.btnRowBody1_Contents_Lock)
                        .setText(mUtil.getStringValues(mContext, "CMDCLS_TYPE_ID_"
                                + httpCmdclsTypeId + "_CLOSE"));
                mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(tempValue);
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_05_00_valve_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                    mUtil.getView(childView, R.id.btnRowBody1_Contents_Lock).setEnabled(false);
                } else {
                    if (httpContentValue.equals(select)) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_05_01_valve_state_locked);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_05_02_valve_state_unlocked);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_02));
                    }
                }
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Lock).setTag(position);
                mUtil.getView(childView, R.id.btnRowBody1_Contents_Lock)
                        .setOnClickListener(new View.OnClickListener() {
                            int tag = 0;

                            @Override
                            public void onClick(View view) {

                                tag = (int) view.getTag();
                                setHttpValue("CLOSE");
                                vLoding.setVisibility(View.VISIBLE);
                                mAdapterCallback.onCallAction(ON_CALL_ACTION_EXECUTE, tag);
                            }
                        });
                break;

            // SENSOR_MULTILEVEL
            case Constants.CMDCLS_TYPE_ID_12001:
            case Constants.CMDCLS_TYPE_ID_12003:
            case Constants.CMDCLS_TYPE_ID_12007:
            case Constants.CMDCLS_TYPE_ID_12008:
            case Constants.CMDCLS_TYPE_ID_12009:
            case Constants.CMDCLS_TYPE_ID_12010:
            case Constants.CMDCLS_TYPE_ID_12011:
            case Constants.CMDCLS_TYPE_ID_12012:
            case Constants.CMDCLS_TYPE_ID_12013:
            case Constants.CMDCLS_TYPE_ID_12014:
            case Constants.CMDCLS_TYPE_ID_12015:
            case Constants.CMDCLS_TYPE_ID_12016:
            case Constants.CMDCLS_TYPE_ID_12017:
            case Constants.CMDCLS_TYPE_ID_12019:
            case Constants.CMDCLS_TYPE_ID_12020:
            case Constants.CMDCLS_TYPE_ID_12021:
            case Constants.CMDCLS_TYPE_ID_12022:
            case Constants.CMDCLS_TYPE_ID_12023:
            case Constants.CMDCLS_TYPE_ID_12024:
            case Constants.CMDCLS_TYPE_ID_12025:
            case Constants.CMDCLS_TYPE_ID_12026:
            case Constants.CMDCLS_TYPE_ID_12027:
            case Constants.CMDCLS_TYPE_ID_12029:
            case Constants.CMDCLS_TYPE_ID_12030:
            case Constants.CMDCLS_TYPE_ID_12031:
            case Constants.CMDCLS_TYPE_ID_12032:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            case Constants.CMDCLS_TYPE_ID_12002:
                //온도센서
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-");
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_03_00_sensor_temperature_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    switch (mUtil.str2int(mUtil.getRealDateMonth())) {
                        case 12:
                        case 1:
                        case 2:
                            //겨울
                            if (mUtil.str2float(httpContentValue) < 18) {
                                tempType = 1;
                            } else if (mUtil.str2float(httpContentValue) > 20) {
                                tempType = 3;
                            } else {
                                tempType = 2;
                            }
                            break;
                        case 3:
                        case 4:
                        case 5:
                        case 10:
                        case 11:
                            //봄,가을
                            if (mUtil.str2float(httpContentValue) < 20) {
                                tempType = 1;
                            } else if (mUtil.str2float(httpContentValue) > 22) {
                                tempType = 3;
                            } else {
                                tempType = 2;
                            }
                            break;
                        case 6:
                        case 7:
                        case 8:
                        case 9:
                            //여름
                            if (mUtil.str2float(httpContentValue) < 26) {
                                tempType = 1;
                            } else if (mUtil.str2float(httpContentValue) > 28) {
                                tempType = 3;
                            } else {
                                tempType = 2;
                            }
                            break;
                        default:
                            break;
                    }
                    mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.VISIBLE);
                    if (tempType == 1) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_03_01_sensor_temperature_cool);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_cool));
                    } else if (tempType == 2) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_03_02_sensor_temperature_nice);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_nice));
                    } else if (tempType == 3) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_03_03_sensor_temperature_hot);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_hot));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_12004:
                //밝기
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-");
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_07_00_bright_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (("%".equals(httpUnit) && mUtil.str2float(httpContentValue) < 10)
                            || ("lx".equals(httpUnit) && mUtil.str2float(httpContentValue) < 30)) {
                        tempType = 1;
                    } else if (("%".equals(httpUnit) && mUtil.str2float(httpContentValue) < 50)
                            || ("lx".equals(httpUnit) && mUtil.str2float(httpContentValue) < 300)) {
                        tempType = 2;
                    } else if (("%".equals(httpUnit) && mUtil.str2float(httpContentValue) < 80)
                            || ("lx".equals(httpUnit) && mUtil.str2float(httpContentValue) < 600)) {
                        tempType = 3;
                    } else {
                        tempType = 4;
                    }
                    mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.VISIBLE);
                    if (tempType == 1) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_07_01_bright_state_dark);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_dark));
                    } else if (tempType == 2) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_07_02_bright_state_soft);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_soft));
                    } else if (tempType == 3) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_07_03_bright_state_nice);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_nice));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_07_04_bright_state_bright);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_bright));
                    }
                }
                break;
            case Constants.CMDCLS_TYPE_ID_12005:
                // 리피터
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_15_00_repeater_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_15_01_repeater_state_on);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                }
                break;
            case Constants.CMDCLS_TYPE_ID_12006:
                //습도센서
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-");
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_04_00_sensor_humidity_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    switch (mUtil.str2int(mUtil.getRealDateMonth())) {
                        case 12:
                        case 1:
                        case 2:
                            //겨울
                            if (mUtil.str2float(httpContentValue) < 60) {
                                tempType = 1;
                            } else if (mUtil.str2float(httpContentValue) > 70) {
                                tempType = 3;
                            } else {
                                tempType = 2;
                            }
                            break;
                        case 3:
                        case 4:
                        case 5:
                        case 10:
                        case 11:
                            //봄,가을
                            if (mUtil.str2float(httpContentValue) < 50) {
                                tempType = 1;
                            } else if (mUtil.str2float(httpContentValue) > 60) {
                                tempType = 3;
                            } else {
                                tempType = 2;
                            }
                            break;
                        case 6:
                        case 7:
                        case 8:
                        case 9:
                            //여름
                            if (mUtil.str2float(httpContentValue) < 30) {
                                tempType = 1;
                            } else if (mUtil.str2float(httpContentValue) > 40) {
                                tempType = 3;
                            } else {
                                tempType = 2;
                            }
                            break;
                        default:
                            break;
                    }
                    mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.VISIBLE);
                    if (tempType == 1) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_04_01_sensor_humidity_dry);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_dry));
                    } else if (tempType == 2) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_04_02_sensor_humidity_nice);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_nice));
                    } else if (tempType == 3) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_04_03_sensor_humidity_moist);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_moist));
                    }
                }
                break;

            case Constants.CMDCLS_TYPE_ID_12028:
                //자외선센서
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-");
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(R.drawable.img_things_detail_13_00_sensor_uv_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (mUtil.str2int(httpContentValue) <= 2) {
                        tempType = 1;
                    } else if (mUtil.str2int(httpContentValue) <= 5) {
                        tempType = 2;
                    } else if (mUtil.str2int(httpContentValue) <= 7) {
                        tempType = 3;
                    } else if (mUtil.str2int(httpContentValue) <= 10) {
                        tempType = 4;
                    } else if (mUtil.str2int(httpContentValue) >= 11) {
                        tempType = 5;
                    }
                    mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.VISIBLE);
                    if (tempType == 1) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_13_01_sensor_uv_low);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_low));
                    } else if (tempType == 2) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_13_02_sensor_uv_moderate);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_moderate));
                    } else if (tempType == 3) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_13_03_sensor_uv_high);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_high));
                    } else if (tempType == 4) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_13_04_sensor_uv_veryhigh);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_veryhigh));
                    } else if (tempType == 5) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_13_05_sensor_uv_extreme);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Desc)
                                .setText(mUtil.getString(mContext, R.string.layout_things_extreme));
                    }
                }
                break;

            case Constants.CMDCLS_TYPE_ID_12018:
                // 이산화탄소 센서
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Desc).setText("-");
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Desc).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(R.drawable.img_things_detail_21_04_weatherstation_co2_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (mUtil.str2int(httpContentValue) <= 450) {
                        tempType = 1;
                    } else if (mUtil.str2int(httpContentValue) <= 700) {
                        tempType = 2;
                    } else if (mUtil.str2int(httpContentValue) <= 1000) {
                        tempType = 3;
                    } else {
                        tempType = 4;
                    }
                    mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.VISIBLE);
                    if (tempType == 1) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_21_04_weatherstation_co2_good);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_good));
                    } else if (tempType == 2) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_21_03_weatherstation_co2_moderate);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_moderate2));
                    } else if (tempType == 3) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_21_02_weatherstation_co2_slightlybad);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_little_bad));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_21_01_weatherstation_co2_bad);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_bad));
                    }
                }
                // 범례
                mUtil.getImageView(childView, R.id.levelImageView).setVisibility(View.VISIBLE);
                mUtil.getImageView(childView, R.id.levelImageView)
                        .setImageResource(R.drawable.img_things_detail_21_weatherstation_co2_list_levels);
                break;

            case Constants.CMDCLS_TYPE_ID_12033:
                // 미세먼지 센서
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Desc).setText("-");
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Desc).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon).setBackgroundResource(
                            R.drawable.img_things_detail_20_04_weatherstation_finedust_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (mUtil.str2int(httpContentValue) <= 30) {
                        tempType = 1;
                    } else if (mUtil.str2int(httpContentValue) <= 80) {
                        tempType = 2;
                    } else if (mUtil.str2int(httpContentValue) <= 150) {
                        tempType = 3;
                    } else {
                        tempType = 4;
                    }
                    mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.VISIBLE);
                    if (tempType == 1) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_20_04_weatherstation_finedust_good);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_good));
                    } else if (tempType == 2) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_20_03_weatherstation_finedust_moderate);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_moderate2));
                    } else if (tempType == 3) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_20_02_weatherstation_finedust_bad);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_bad));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(
                                        R.drawable.img_things_detail_20_01_weatherstation_finedust_verybad);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_very_bad));
                    }
                }
                // 범례
                mUtil.getImageView(childView, R.id.levelImageView).setVisibility(View.VISIBLE);
                mUtil.getImageView(childView, R.id.levelImageView)
                        .setImageResource(R.drawable.img_things_detail_20_weatherstation_dust_list_levels);
                break;

            case Constants.CMDCLS_TYPE_ID_12034:
                // 휘발성유기화합물 센서
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Desc).setText("-");
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Desc).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon).setBackgroundResource(
                            R.drawable.img_things_detail_19_02_weatherstation_vocs_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    if (mUtil.str2int(httpContentValue) <= 299) {
                        tempType = 1;
                    } else {
                        tempType = 2;
                    }
                    mUtil.getView(childView, R.id.tvRowBody1_Desc).setVisibility(View.VISIBLE);
                    if (tempType == 1) {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_19_01_weatherstation_vocs_good);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_good));
                    } else {
                        mUtil.getView(childView, R.id.ivRowBody1_Icon)
                                .setBackgroundResource(R.drawable.img_things_detail_19_02_weatherstation_vocs_bad);
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                        mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                                .setText(mUtil.getString(mContext, R.string.layout_things_bad));
                    }
                }
                // 범례
                mUtil.getImageView(childView, R.id.levelImageView).setVisibility(View.VISIBLE);
                mUtil.getImageView(childView, R.id.levelImageView)
                        .setImageResource(R.drawable.img_things_detail_19_weatherstation_vocs_list_levels);
                break;

            //METER_CURRENT
            case Constants.CMDCLS_TYPE_ID_15001:
            case Constants.CMDCLS_TYPE_ID_15002:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(R.drawable.img_things_detail_02_00_sensor_shock_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            //METER_TOTAL
            case Constants.CMDCLS_TYPE_ID_16001:
            case Constants.CMDCLS_TYPE_ID_16002:
            case Constants.CMDCLS_TYPE_ID_16003:
            case Constants.CMDCLS_TYPE_ID_16004:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(R.drawable.img_things_detail_02_00_sensor_shock_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            //SWITCH_MULTILEVEL
            case Constants.CMDCLS_TYPE_ID_18001:
            case Constants.CMDCLS_TYPE_ID_18002:
            case Constants.CMDCLS_TYPE_ID_18003:
            case Constants.CMDCLS_TYPE_ID_18004:
            case Constants.CMDCLS_TYPE_ID_18005:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(R.drawable.img_things_detail_02_00_sensor_shock_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            //THERMOSTAT_SETPOINT
            case Constants.CMDCLS_TYPE_ID_19001:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(R.drawable.img_things_detail_02_00_sensor_shock_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            // METER
            case Constants.CMDCLS_TYPE_ID_29001:
            case Constants.CMDCLS_TYPE_ID_29003:
            case Constants.CMDCLS_TYPE_ID_29004:
            case Constants.CMDCLS_TYPE_ID_29005:
            case Constants.CMDCLS_TYPE_ID_29006:
            case Constants.CMDCLS_TYPE_ID_29007:
            case Constants.CMDCLS_TYPE_ID_29008:
            case Constants.CMDCLS_TYPE_ID_29009:
            case Constants.CMDCLS_TYPE_ID_29010:
            case Constants.CMDCLS_TYPE_ID_29011:
            case Constants.CMDCLS_TYPE_ID_29012:
            case Constants.CMDCLS_TYPE_ID_29013:
            case Constants.CMDCLS_TYPE_ID_29014:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            case Constants.CMDCLS_TYPE_ID_29002:
                // 에너지미터
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_13_00_meter_state_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                } else {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_13_01_meter_state_on);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                }
                break;
            //BATTERY
            case Constants.CMDCLS_TYPE_ID_30001:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(R.drawable.img_things_detail_02_00_sensor_shock_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            //SYSTEM
            case Constants.CMDCLS_TYPE_ID_34006:
            case Constants.CMDCLS_TYPE_ID_34007:
            case Constants.CMDCLS_TYPE_ID_34008:
            case Constants.CMDCLS_TYPE_ID_34009:
            case Constants.CMDCLS_TYPE_ID_34010:
            case Constants.CMDCLS_TYPE_ID_34011:
            case Constants.CMDCLS_TYPE_ID_34012:
            case Constants.CMDCLS_TYPE_ID_34013:
            case Constants.CMDCLS_TYPE_ID_34014:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getView(childView, R.id.ivRowBody1_Icon)
                            .setBackgroundResource(
                                    R.drawable.img_things_detail_02_00_sensor_shock_offline);
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
            default:
                if ("".equals(httpContentValue)) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title).setText("-" + httpUnit);
                } else {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(httpContentValue + httpUnit);
                }
                if ("OFF".equals(httpOnlineState)
                        || mAppConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF")) {
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setTextColor(Util.getColor(mContext, R.color.color_text_01));
                    mUtil.getTextView(childView, R.id.tvRowBody1_Title)
                            .setText(mUtil.getString(mContext, R.string.layout_offline));
                }
                break;
        }

        container.addView(childView);
        mViews.put(position, childView);

        /*if (position != mCurrentPosition) {
            CustomViewPager pager = (CustomViewPager) container;
            if (childView != null) {
                mCurrentPosition = position;
                pager.measureCurrentView(childView);
            }
        }*/
        return childView;
    }

    public String getHttpValue() {

        return mHttpValue;
    }

    public void setHttpValue(String val) {

        mHttpValue = val;
    }

    public boolean isHideDivider() {
        return mIsHideDivider;
    }

    public void setHideDivider(boolean hideDivider) {
        mIsHideDivider = hideDivider;
    }
}
