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

package com.ntels.kneet.v3.view.rules;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.ntels.kneet.v3.common.AppConfig;
import com.ntels.kneet.v3.common.Constants;
import com.ntels.kneet.v3.common.db.SQLManager;
import com.ntels.kneet.v3.common.http.HttpSend;
import com.ntels.kneet.v3.common.http.Response;
import com.ntels.kneet.v3.common.c_interface.Main_Interface;
import com.ntels.kneet.v3.common.c_interface.OnDataSendToReslut;
import com.ntels.kneet.v3.common.util.Dlog;
import com.ntels.kneet.v3.common.util.Util;
import com.ntels.kneet.v3.common.widget.CustomActionBarActivity;
import com.ntels.kneet.v3.R;
import com.ntels.kneet.v3.view.dialog.CustomDialog;
import com.ntels.kneet.v3.view.dialog.Dialog_Custom_List;

import org.json.JSONObject;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;

public class Rules_Detail extends CustomActionBarActivity implements View.OnClickListener,
                                                                     CustomDialog.OnMsgAlterToResult {

    private Boolean       bDeviceDelYn  = false;
    private DecimalFormat decimalFormat = new DecimalFormat("00");
    LinearLayoutManager mLayoutManager;
    int                 firstVisibleItem, visibleItemCount, totalItemCount;
    private String                             sHTTP_homegrp_rule_id = "";
    private String                             sHTTP_pred_rule_id    = "";
    private String                             sRuleUse_Yn           = "N";
    private String                             sRuleUse_Yn_Text      = "";
    private String                             sHTTP_rule_name       = "";
    private String                             sTempText1            = "ON";
    private String                             sTempText2            = "OFF";
    private Boolean                            bSend                 = false;
    private ArrayList<HashMap<String, Object>> alList_Conditions     = new ArrayList<HashMap<String, Object>>();
    private ArrayList<HashMap<String, Object>> alList_Actions        = new ArrayList<HashMap<String, Object>>();
    private ArrayList<HashMap<String, Object>> alList_Triggers       = new ArrayList<HashMap<String, Object>>();
    private ArrayList<HashMap<String, Object>> alList_Triggers1      = new ArrayList<HashMap<String, Object>>();
    private Dialog_Custom_List.Builder dialog_list_builder;
    //    private String                             sCallType         = "";
    String sTRIGGERS;
    String sACTIONS;
    String sCONDITIONS;
    String sCustomJason        = "";
    String sRules_Detail_Jason = "";
    private SwipeRefreshLayout swipeRefreshLayout;
    private boolean loading     = false;
    private Boolean bReloadFlag = false;

    private View callChildView;

    private TextView tvTempBody;

    /*툴바 관련*/
    private Toolbar toolbar;

    /*통신 관련*/
    private              ArrayList<HashMap<String, Object>> alTotalList                     = new ArrayList<HashMap<String, Object>>();
    private              int                                iType                           = 0;
    private static final int                                MSG_COM_G_RULES_HOMEGRP_RULE_ID = 1;
    private static final int                                MSG_COM_D_RULES_HOMEGRP_RULE_ID = 2;
    private static final int                                MSG_COM_P_RULES_HOMEGRP_RULE_ID_STATUS = 3;

    /*공통*/
    private Activity       act;
    private AppConfig      appConfig;
    private Main_Interface mCallback;
    private Intent         intent;
    private              Util         util                        = new Util();
    private              CustomDialog customDialog                = new CustomDialog();
    private              String       sCallType                   = "";
    private              SQLManager   sqlManager                  = new SQLManager();
    private              Boolean      bAutoLogin                  = false;
    private              Boolean      bSaveId                     = false;
    private              String       sFileName                   = "";
    private              String       sHTTP_push_type_mode_chg_yn = "";
    private              String       sHTTP_push_type_rule_exc_yn = "";
    private              int          iAlram_Type                 = 0;
    private static final int          ALRAM_MODE_ON               = 1;
    private static final int          ALRAM_MODE_OFF              = 2;
    private static final int          ALRAM_RULE_ON               = 3;
    private static final int          ALRAM_RULE_OFF              = 4;

    /**
     * <PRE>
     * 1. MethodName: onCreate
     * 2. ClassName :
     * 3. Comment   : onCreate
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    @Override public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        act = Rules_Detail.this;
        appConfig = (AppConfig) act.getApplicationContext();
        customDialog.setOnMsgAlterToResultEvent(this);

        View viewToLoad = LayoutInflater.from(act).inflate(R.layout.rules_detail, null);
        this.setContentView(viewToLoad);

        if ( savedInstanceState != null ) {
            // sTitle =
            // savedInstanceState.getString(Constants.EXTRA_SPINNER_TITLE);
            // aList1 =
            // savedInstanceState.getStringArrayList(Constants.EXTRA_SPINNER_LIST1);
            // aList2 =
            // savedInstanceState.getStringArrayList(Constants.EXTRA_SPINNER_LIST2);
            // // 0: 세로 한개 선택, 1: 가로 한개선택
            // iType = savedInstanceState.getInt(Constants.EXTRA_SPINNER_TYPE,
            // 0);
            // sBtn1 =
            // savedInstanceState.getString(Constants.EXTRA_SPINNER_BTN1);
            // sBtn2 =
            // savedInstanceState.getString(Constants.EXTRA_SPINNER_BTN2);
            // iPosition =
            // savedInstanceState.getInt(Constants.EXTRA_SPINNER_POSITION, 0);
        } else {
            Intent intent = getIntent();
            sHTTP_homegrp_rule_id = intent.getStringExtra(Constants.EXTRA_MEMBER_RULE_ID);
        }

        setToolbar();
        setDisp();
    }

    private void setToolbar() {

        toolbar = (Toolbar) act.findViewById(R.id.toolbar);
        util.setKeyboardHide(act, toolbar);
        util.getTextView(toolbar, R.id.tvToolbarTitle1).setVisibility(View.VISIBLE);
        util.getTextView(toolbar, R.id.tvToolbarTitle2).setVisibility(View.GONE);
        util.getTextView(toolbar, R.id.tvToolbarTitleDivider).setVisibility(View.GONE);
        util.getTextView(toolbar, R.id.tvToolbarTitle3).setVisibility(View.GONE);
        util.getTextView(toolbar, R.id.tvToolbarTitle4).setVisibility(View.GONE);
        util.getTextView(toolbar, R.id.btnToolbarDel).setVisibility(View.GONE);
        util.getTextView(toolbar, R.id.btnToolbarClose).setVisibility(View.GONE);
        util.getTextView(toolbar, R.id.btnToolbarMore).setVisibility(View.VISIBLE);

        util.getTextView(toolbar, R.id.tvToolbarTitle1).setText(util.getString(act, R.string.layout_rules_detail_01));

        util.getView(toolbar, R.id.btnToolbarMore).setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View v) {

                ArrayList<HashMap<String, Object>> alMenuList = new ArrayList<HashMap<String, Object>>();
                alMenuList.add(util.getPopMenu(6));

                //                if ( appConfig.getSelect_Homegrp_Homehub_Online_State().equals("ON") && appConfig.getSelect_Homegrp_Grade_Code().equals("MAS") ) {
                if ( appConfig.getSelect_Homegrp_Grade_Code().equals("MAS") ) {
                    alMenuList.add(util.getPopMenu(19));
                    alMenuList.add(util.getPopMenu(18));
                }
                MsgAlertList(alMenuList);
            }
        });
    }

    private void setDisp() {

        util.getView(act, R.id.btnOnOff).setOnClickListener(this);
        util.getView(act, R.id.llBtn1).setOnClickListener(this);

        swipeRefreshLayout = (SwipeRefreshLayout) act.findViewById(R.id.swiperefreshlayou);
        swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_red_light, android.R.color.holo_green_light, android.R.color.holo_blue_bright, android.R.color.holo_orange_light);
        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override public void onRefresh() {

                if ( !loading ) {
                    loading = true;
                    ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_RULES_HOMEGRP_RULE_ID), 10);
                }
            }
        });
        if ( appConfig.getSelect_Homegrp_Grade_Code().equals("MAS") ) {
            util.getView(act, R.id.llState).setVisibility(View.VISIBLE);
        } else {
            util.getView(act, R.id.llState).setVisibility(View.GONE);
        }
        ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_RULES_HOMEGRP_RULE_ID), 10);
    }

    @Override public void onConfigurationChanged(Configuration newConfig) {

        super.onConfigurationChanged(newConfig);
    }

    @Override public void onClick(View v) {

        switch (v.getId()) {
            case R.id.llBtn1:
                onBackPressed();
                break;

            case R.id.btnOnOff:
                if (sRuleUse_Yn.equals("Y")) {
                    util.setShowToast(act, util.getString(act, R.string.MSG808), Toast.LENGTH_SHORT);
                    ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_P_RULES_HOMEGRP_RULE_ID_STATUS), 10);
                } else if (sRuleUse_Yn.equals("N")){
                    util.setShowToast(act, util.getString(act, R.string.MSG809), Toast.LENGTH_SHORT);
                    ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_P_RULES_HOMEGRP_RULE_ID_STATUS), 10);
                } else if (sRuleUse_Yn.equals("X")) {
                    customDialog.MsgAlert(act, Constants.MSG818, R.string.MSG_TITLE_000, util.getString(act, R.string.MSG_BTN_EDIT), util.getString(act, R.string.MSG_BTN_CANCEL));
                }
                break;
            default:
                break;
        }
    }

    Handler ComHandler = new Handler(new IncomingHandlerCallBack());

    class IncomingHandlerCallBack implements Handler.Callback {

        @Override public boolean handleMessage(Message msg) {

            iType = msg.what;
            switch (msg.what) {
                case MSG_COM_G_RULES_HOMEGRP_RULE_ID:
                    //dialog_show();
                    send_G_rules_homegrp_rule_id();
                    break;
                case MSG_COM_D_RULES_HOMEGRP_RULE_ID:
                    //dialog_show();
                    send_D_rules_homegrp_rule_id();
                    break;
                case MSG_COM_P_RULES_HOMEGRP_RULE_ID_STATUS:
                    //dialog_show();
                    send_P_rules_homegrp_rule_id_status();
                    break;
                default:
                    break;
            }
            return true;
        }
    }

    /**
     * <PRE>
     * 1. MethodName: send_P_rules_homegrp_rule_id_status
     * 2. ClassName :
     * 3. Comment   : [Send][POST]홈 규칙 상태 변경(해당 규칙의 상태를 변경한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void  send_P_rules_homegrp_rule_id_status(){
        try {
            HttpSend httpSend;

            httpSend = new HttpSend(act, !swipeRefreshLayout.isRefreshing());
            //httpSend = new HttpSend(act);

            httpSend.setOnDataSendToReslutEvent(new OnDataSendToReslut() {
                @Override public void resultResponse(Response result) {
                    result_P_rules_homegrp_rule_id_status(result);
                }
            });

            if ( sRuleUse_Yn.equals("Y") ) {
                bDeviceDelYn = false;
                util.getButton(act, R.id.btnOnOff).setSelected(true);
                util.getView(act, R.id.tvNotice).setVisibility(View.GONE);
            } else if ( sRuleUse_Yn.equals("N") ) {
                bDeviceDelYn = false;
                util.getView(act, R.id.tvNotice).setVisibility(View.GONE);
            }
            String sHTTP_status_code = "";

            if (sRuleUse_Yn.equals("Y")) {
                sHTTP_status_code = "03";
            } else if (sRuleUse_Yn.equals("N")){
                sHTTP_status_code = "02";
            }
            httpSend.P_rules_homegrp_rule_id_status(sHTTP_homegrp_rule_id, sHTTP_status_code);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * <PRE>
     * 1. MethodName: result_P_rules_homegrp_rule_id_status
     * 2. ClassName :
     * 3. Comment   : [Result][POST]홈 규칙 상태 변경(해당 규칙의 상태를 변경한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void  result_P_rules_homegrp_rule_id_status(Response rpResult){
        try {
            if ( rpResult.getStatusCode() == 200 ) {
                bReloadFlag=true;
                ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_RULES_HOMEGRP_RULE_ID), 10);
            } else {
                JSONObject joResult = new JSONObject(rpResult.getContent());
                Dlog.v(joResult.toString());
                String sERR_CODE = util.null2string(joResult.get(Constants.HTTP_err_code));
                String sERR_MSG = util.null2string(joResult.get(Constants.HTTP_err_msg));

                if ( sERR_CODE.equals("401")) {
                    customDialog.MsgAlert(act, Constants.MSG998, sERR_MSG);
                } else {
                    customDialog.MsgAlert(act, Constants.MSG000, sERR_MSG);
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            customDialog.MsgAlert(act, Constants.MSG807);
        }
    }
    /**
     * <PRE>
     * 1. MethodName: send_G_rules_homegrp_rule_id
     * 2. ClassName :
     * 3. Comment   : [Send][GET]홈 규칙 상세 조회(해당 규칙의 정보를 상세 조회한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void send_G_rules_homegrp_rule_id() {

        try {
            HttpSend httpSend;

            httpSend = new HttpSend(act, !swipeRefreshLayout.isRefreshing());
            //            httpSend = new HttpSend(act);

            httpSend.setOnDataSendToReslutEvent(new OnDataSendToReslut() {
                @Override public void resultResponse(Response result) {

                    result_G_rules_homegrp_rule_id(result);
                }
            });
            httpSend.G_rules_homegrp_rule_id(sHTTP_homegrp_rule_id);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * <PRE>
     * 1. MethodName: result_G_rules_homegrp_rule_id
     * 2. ClassName :
     * 3. Comment   : [Result][GET]홈 규칙 상세 조회(해당 규칙의 정보를 상세 조회한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void result_G_rules_homegrp_rule_id(Response rpResult) {

        try {
            if ( rpResult.getStatusCode() == 200 ) {
                sRules_Detail_Jason = rpResult.getContent();

                setRulesJason_init(rpResult.getContent());
                loading = false;
                swipeRefreshLayout.setRefreshing(false);
            } else {
                JSONObject joResult = new JSONObject(rpResult.getContent());
                Dlog.v(joResult.toString());
                String sERR_CODE = util.null2string(joResult.get(Constants.HTTP_err_code));
                String sERR_MSG = util.null2string(joResult.get(Constants.HTTP_err_msg));

                if ( sERR_CODE.equals("401") ) {
                    customDialog.MsgAlert(act, Constants.MSG998, sERR_MSG);
                } else if ( sERR_CODE.equals("401-106") ) {
                    customDialog.MsgAlert(act, Constants.MSG997, sERR_MSG);
                } else {
                    customDialog.MsgAlert(act, Constants.MSG000, sERR_MSG);
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            customDialog.MsgAlert(act, Constants.MSG807);
        }
    }
    /**
     * <PRE>
     * 1. MethodName: send_D_rules_homegrp_rule_id
     * 2. ClassName :
     * 3. Comment   : [Send][DELETE]홈 규칙 삭제(해당 규칙을 삭제한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void send_D_rules_homegrp_rule_id() {

        try {
            HttpSend httpSend;

            httpSend = new HttpSend(act, !swipeRefreshLayout.isRefreshing());
            //            httpSend = new HttpSend(act);

            httpSend.setOnDataSendToReslutEvent(new OnDataSendToReslut() {
                @Override public void resultResponse(Response result) {

                    result_D_rules_homegrp_rule_id(result);
                }
            });
            httpSend.D_rules_homegrp_rule_id(sHTTP_homegrp_rule_id);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * <PRE>
     * 1. MethodName: result_D_rules_homegrp_rule_id
     * 2. ClassName :
     * 3. Comment   : [Result][DELETE]홈 규칙 삭제(해당 규칙을 삭제한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void result_D_rules_homegrp_rule_id(Response rpResult) {

        try {
            if ( rpResult.getStatusCode() == 200 ) {
                //                JSONObject joResult = new JSONObject(rpResult.getContent());
                bReloadFlag = true;
                util.setShowToast(act, util.getString(act, R.string.MSG857), Toast.LENGTH_SHORT);
                intent = new Intent();
                intent.putExtra(Constants.EXTRA_RELOAD_FLAG, bReloadFlag);
                act.setResult(RESULT_OK, intent);
                finish();
            } else {
                JSONObject joResult = new JSONObject(rpResult.getContent());
                Dlog.v(joResult.toString());
                String sERR_CODE = util.null2string(joResult.get(Constants.HTTP_err_code));
                String sERR_MSG = util.null2string(joResult.get(Constants.HTTP_err_msg));

                if ( sERR_CODE.equals("401") ) {
                    customDialog.MsgAlert(act, Constants.MSG998, sERR_MSG);
                } else if ( sERR_CODE.equals("401-106") ) {
                    customDialog.MsgAlert(act, Constants.MSG997, sERR_MSG);
                } else {
                    customDialog.MsgAlert(act, Constants.MSG000, sERR_MSG);
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            customDialog.MsgAlert(act, Constants.MSG807);
        }
    }

    /**
     * <PRE>
     * 1. MethodName: onBackPressed
     * 2. ClassName :
     * 3. Comment   : 뒤로가기 버튼
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    @Override public void onBackPressed() {

        intent = new Intent();
        intent.putExtra(Constants.EXTRA_RELOAD_FLAG, bReloadFlag);
        act.setResult(RESULT_CANCELED, intent);
        finish();
        return;
    }

    /**
     * <PRE>
     * 1. MethodName: onResume
     * 2. ClassName :
     * 3. Comment   : onResume
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    @Override public void onResume() {

        super.onResume();
    }

    private void MsgAlertList(ArrayList<HashMap<String, Object>> alList) {

        try {
            dialog_list_builder = new Dialog_Custom_List.Builder(act);
            dialog_list_builder.setList(alList);
            dialog_list_builder.setPositiveButton(new AlertDialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    dialog.dismiss();
                    Dlog.v("which = " + which);
                    switch (which) {
                        case 1:
                            break;
                        case 2:
                            break;
                        case 3:
                            break;
                        case 4:
                            break;
                        case 5:
                            break;
                        case 6:
                            ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_RULES_HOMEGRP_RULE_ID), 10);
                            break;
                        case 7:
                            break;
                        case 8:
                            break;
                        case 9:
                            break;
                        case 10:
                            break;
                        case 11:
                            break;
                        case 12:
                            break;
                        case 15:
                            break;
                        case 16:
                            break;
                        case 17:
                            break;
                        case 18:
                            customDialog.MsgAlert(act, Constants.MSG810, R.string.MSG_TITLE_003, util.getString(act, R.string.layout_delete), util.getString(act, R.string.layout_cancel));
                            break;
                        case 19:
                            Intent intent = new Intent(act, Rules_Edit.class);
                            intent.putExtra(Constants.EXTRA_CALL_TYPE, "2");
                            intent.putExtra(Constants.EXTRA_MEMBER_RULE_ID, sHTTP_homegrp_rule_id);
                            util.callActivityForResult(act, intent, Constants.ACT_RULES_EDIT);
                            break;
                    }
                }
            });
            dialog_list_builder.setNegativeButton(new AlertDialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    Dlog.v("which = " + which);
                    dialog.dismiss();
                }
            });
            dialog_list_builder.create().show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override public void resultCustomDialogResponse(int iMsgID, int iBtnResult) {

        switch (iMsgID) {

            case Constants.MSG998:
                util.callApp_Start(act, "LOGOUT");
                break;
            case Constants.MSG997:
                util.callApp_Start(act, "HOME_RELOAD");
                break;
            case Constants.MSG807:
                if ( iBtnResult == 1 ) {
                    ComHandler.sendMessageDelayed(ComHandler.obtainMessage(iType), 10);
                }
                break;
            case Constants.MSG810:
                if ( iBtnResult == 1 ) {
                    ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_D_RULES_HOMEGRP_RULE_ID), 10);
                }
                break;
            case Constants.MSG818:
                if ( iBtnResult == 1 ) {
                    Intent intent = new Intent(act, Rules_Edit.class);
                    intent.putExtra(Constants.EXTRA_CALL_TYPE, "2");
                    intent.putExtra(Constants.EXTRA_MEMBER_RULE_ID, sHTTP_homegrp_rule_id);
                    util.callActivityForResult(act, intent, Constants.ACT_RULES_EDIT);
                }
                break;
            default:
                break;
        }
    }

    @Override public void onActivityResult(int requestCode, int resultCode, Intent data) {

        super.onActivityResult(requestCode, resultCode, data);
        if ( resultCode == act.RESULT_OK ) {
            switch (requestCode) {
                case Constants.ACT_RULES_EDIT:
                    if ( data == null ) {
                        return;
                    }
                    bReloadFlag = data.getBooleanExtra(Constants.EXTRA_RELOAD_FLAG, false);
                    if ( bReloadFlag ) {
                        ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_RULES_HOMEGRP_RULE_ID), 10);
                    }
                    break;
            }
        } else {
            switch (requestCode) {
                case Constants.ACT_RULES_EDIT:
                    if ( data == null ) {
                        return;
                    }
                    bReloadFlag = data.getBooleanExtra(Constants.EXTRA_RELOAD_FLAG, false);
                    if ( bReloadFlag ) {
                        ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_RULES_HOMEGRP_RULE_ID), 10);
                    }
                    break;
                default:
                    break;
            }
        }
    }

    void setRulesJason_init(String sContent) {

        try {
            JSONObject joResult = new JSONObject(sContent);

            sHTTP_homegrp_rule_id = util.null2string(joResult.get(Constants.HTTP_homegrp_rule_id));
            sHTTP_rule_name = util.null2string(joResult.get(Constants.HTTP_rule_name));
            util.getTextView(act, R.id.tvRulesName).setText(sHTTP_rule_name);

            if ( joResult.has(Constants.HTTP_latest_execution_datetime) ) {
                util.getView(act, R.id.llLastActionTime).setVisibility(View.VISIBLE);
                String sHTTP_latest_execution_datetime = util.null2string(joResult.get(Constants.HTTP_latest_execution_datetime));
                util.getTextView(act, R.id.tvLastActionTime).setText(util.UTCtoLocal5(sHTTP_latest_execution_datetime));
            } else {
                util.getView(act, R.id.llLastActionTime).setVisibility(View.GONE);
                util.getTextView(act, R.id.tvLastActionTime).setText("");
            }

            sRuleUse_Yn = util.null2string(joResult.get(Constants.HTTP_use_yn));

            util.getButton(act, R.id.btnOnOff).setSelected(false);
            if ( sRuleUse_Yn.equals("Y") ) {
                bDeviceDelYn = false;
                util.getButton(act, R.id.btnOnOff).setSelected(true);
                util.getView(act, R.id.tvNotice).setVisibility(View.GONE);
            } else if ( sRuleUse_Yn.equals("N") ) {
                bDeviceDelYn = false;
                util.getView(act, R.id.tvNotice).setVisibility(View.GONE);
            } else if ( sRuleUse_Yn.equals("X") ) {
                bDeviceDelYn = true;
                util.getView(act, R.id.tvNotice).setVisibility(View.VISIBLE);
            }

            sCONDITIONS = util.null2empty(joResult.get(Constants.HTTP_conditions)).toString();
            sTRIGGERS = util.null2empty(joResult.get(Constants.HTTP_triggers)).toString();
            sACTIONS = util.null2empty(joResult.get(Constants.HTTP_actions)).toString();

            setDispConditions_init();
            setDispTriggers_init();
            setDispActions_init();
        } catch (Exception ex) {
            ex.printStackTrace();
            customDialog.MsgAlert(act, Constants.MSG807);
        }
    }

    void setDispTriggers_init() {

        Dlog.v("sTRIGGERS=", sTRIGGERS);
        alList_Triggers.clear();
        alList_Triggers = util.jsonToArrayListMap(sTRIGGERS);
        setDispTriggers();
    }

    void setDispTriggers() {

        Dlog.v("alList_Triggers1 = ", alList_Triggers.toString());
        if ( alList_Triggers.size() > 0 ) {
            util.getLinearLayout(act, R.id.llTrigger).setVisibility(View.VISIBLE);
            util.getLinearLayout(act, R.id.llTriggerBody).removeAllViews();

            //현재로써는 트리거는 단일임 나중에 멀티일때 풀어야 함
            //            for ( int iRow = 0; iRow < alList_Triggers.size(); iRow++ ) {
            int iRow = 0;
            HashMap<String, Object> hmTemp = new HashMap<String, Object>();
            hmTemp = alList_Triggers.get(iRow);
            LinearLayout childView = (LinearLayout) View.inflate(this, R.layout.row_rules_triggers_list, null);
            util.getView(childView, R.id.btnRowDelete).setVisibility(View.GONE);

            String sHTTP_item_name = util.null2string(hmTemp.get(Constants.HTTP_item_name));
            String sHTTP_item_sub_type_code = util.null2string(hmTemp.get(Constants.HTTP_item_sub_type_code));

            util.getTextView(act, R.id.tvTriggerTitle).setText(sHTTP_item_name);
            ArrayList<HashMap<String, Object>> alList_Item_Sub = new ArrayList<HashMap<String, Object>>();
            if ( !util.null2string(hmTemp.get(Constants.HTTP_item_sub)).equals("") ) {
                alList_Item_Sub = (ArrayList<HashMap<String, Object>>) hmTemp.get(Constants.HTTP_item_sub);
            }
            if ( alList_Item_Sub != null ) {
                int iRow1 = 0;
                callChildView = childView;
                if ( sHTTP_item_sub_type_code.equals("05") ) {
                    //time
                    String sHTTP_hour = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_hour));
                    String sHTTP_minute = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_minute));
                    String sAMPM = (util.str2int(sHTTP_hour) >= 12 ? util.getString(act, R.string.layout_pm) : util.getString(act, R.string.layout_am));
                    String sHour = (util.str2int(sHTTP_hour) >= 12 ? decimalFormat.format((util.str2int(sHTTP_hour) - 12)) : sHTTP_hour);
                    String sDayofweek = getAlList_Conditions(1);

                    //                    String sHTTP_delete_yn = util.null2string(alList_Item_Sub.get(iRow).get(Constants.HTTP_delete_yn));

                    if ( appConfig.getLanguage_Id().equals("ko") ) {
                        util.getTextView(childView, R.id.tvRowTitle).setText(sAMPM + " " + sHour + util.getString(act, R.string.layout_hour) + " " + sHTTP_minute + util.getString(act,
                                                                                                                                                                                   R.string.layout_minute));
                    } else {
                        util.getTextView(childView, R.id.tvRowTitle).setText(sHour
                                                                             + util.getString(act, R.string.layout_hour)
                                                                             + sHTTP_minute
                                                                             + util.getString(act, R.string.layout_minute)
                                                                             + " "
                                                                             + sAMPM);
                    }

                    util.getTextView(childView, R.id.tvRowBody).setText(sDayofweek);
                    util.getTextView(childView, R.id.tvRowState).setVisibility(View.GONE);

                    util.setImage(act, R.drawable.img_rule_trigger_icon_time, util.getImageView(childView, R.id.ivRowIcon));
                } else if ( sHTTP_item_sub_type_code.equals("32") ) {
                    //sun
                    String sHTTP_source_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_name));
                    String sHTTP_source_sub_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_sub_name));
                    String sDayofweek = getAlList_Conditions(1);

                    //                    String sHTTP_delete_yn = util.null2string(alList_Item_Sub.get(iRow).get(Constants.HTTP_delete_yn));

                    util.getTextView(childView, R.id.tvRowTitle).setText(sHTTP_source_sub_name);

                    util.getTextView(childView, R.id.tvRowBody).setText(sHTTP_source_name + "/" + sDayofweek);
                    util.getTextView(childView, R.id.tvRowState).setVisibility(View.GONE);

                    util.setImage(act, R.drawable.img_rule_trigger_icon_sunset, util.getImageView(childView, R.id.ivRowIcon));
                } else if ( sHTTP_item_sub_type_code.equals("31") ) {
                    //더울 때 /추울때
                    String sHTTP_source_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_name));
                    String sHTTP_condition_type_code = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_condition_type_code));
                    String sHTTP_cmdcls_value = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value));
                    String sDayofweek = getAlList_Conditions(1);

                    //                    String sHTTP_delete_yn = util.null2string(alList_Item_Sub.get(iRow).get(Constants.HTTP_delete_yn));

                    String sTempMsg = "";
                    if ( sHTTP_condition_type_code.equals("02") ) {
                        sTempMsg = util.getString(act, R.string.layout_rules_triggers_hot_03);
                    } else if ( sHTTP_condition_type_code.equals("04") ) {
                        sTempMsg = util.getString(act, R.string.layout_rules_triggers_hot_02);
                    }

                    util.getTextView(childView, R.id.tvRowTitle).setText(sTempMsg);

                    util.getTextView(childView, R.id.tvRowBody).setText(sHTTP_source_name + "/" + sHTTP_cmdcls_value + util.getString(act, R.string.layout_temperature1) + "/" + sDayofweek);
                    util.getTextView(childView, R.id.tvRowState).setVisibility(View.GONE);

                    util.setImage(act, R.drawable.img_rule_trigger_icon_temperature, util.getImageView(childView, R.id.ivRowIcon));
                } else if ( sHTTP_item_sub_type_code.equals("01") ) {
                    //상태가 변할때
                    String sHTTP_source_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_name));
                    String sHTTP_source_sub_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_sub_name));
                    String sHTTP_condition_type_code = util.null2string(alList_Item_Sub.get(iRow).get(Constants.HTTP_condition_type_code));
                    String sHTTP_condition_type_code_name = util.null2string(alList_Item_Sub.get(iRow).get(Constants.HTTP_condition_type_code_name));
                    String sHTTP_cmdcls_value = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value));
                    String sHTTP_cmdcls_value_msg = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value_msg));
                    String sHTTP_image_file_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_image_file_name));
                    String sHTTP_unit = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_unit));
                    //                    String sDayofweek = getAlList_Conditions(1);

                    String sHTTP_available_yn = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_available_yn));

                    if ( sHTTP_available_yn.equals("N") ) {
                        util.getTextView(childView, R.id.tvRowTitle).setText(util.setSpCenterLine(act, sHTTP_source_name));
                    } else {
                        util.getTextView(childView, R.id.tvRowTitle).setText(sHTTP_source_name);
                    }
                    util.getTextView(childView, R.id.tvRowBody).setText(sHTTP_source_sub_name);
                    util.getTextView(childView, R.id.tvRowState).setVisibility(View.VISIBLE);
                    util.getTextView(childView, R.id.tvRowState).setText((sHTTP_cmdcls_value_msg.equals("") ? sHTTP_cmdcls_value : sHTTP_cmdcls_value_msg) + sHTTP_unit + (
                            sHTTP_condition_type_code.equals("01")
                            ? ""
                            : sHTTP_condition_type_code_name));

                    util.setImage(act, sHTTP_image_file_name, util.getImageView(childView, R.id.ivRowIcon));
                }
            }
            util.getLinearLayout(act, R.id.llTriggerBody).addView(childView);
            //            }
        } else {
            util.getLinearLayout(act, R.id.llTrigger).setVisibility(View.GONE);
        }
    }

    void setDispActions_init() {

        Dlog.v("sACTIONS=", sACTIONS);
        alList_Actions.clear();
        alList_Actions = util.jsonToArrayListMap(sACTIONS);
        setDispActions();
    }

    void setDispActions() {

        Dlog.v("alList_Actions1 = ", alList_Actions.toString());
        if ( alList_Actions.size() > 0 ) {

            util.getLinearLayout(act, R.id.llAction).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llActionBody).removeAllViews();

            util.getLinearLayout(act, R.id.llAlram).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llAlramBody).removeAllViews();
            for ( int iRow = 0; iRow < alList_Actions.size(); iRow++ ) {
                HashMap<String, Object> hmTemp = new HashMap<String, Object>();
                hmTemp = alList_Actions.get(iRow);

                String sHTTP_item_sub_type_code = util.null2string(hmTemp.get(Constants.HTTP_item_sub_type_code));

                ArrayList<HashMap<String, Object>> alList_Item_Sub = new ArrayList<HashMap<String, Object>>();
                if ( !util.null2string(hmTemp.get(Constants.HTTP_item_sub)).equals("") ) {
                    alList_Item_Sub = (ArrayList<HashMap<String, Object>>) hmTemp.get(Constants.HTTP_item_sub);
                }
                if ( alList_Item_Sub != null ) {
                    if ( sHTTP_item_sub_type_code.equals("01") ) {
                        util.getLinearLayout(act, R.id.llAction).setVisibility(View.VISIBLE);
                        for ( int iRow1 = 0; iRow1 < alList_Item_Sub.size(); iRow1++ ) {
                            LinearLayout childView = (LinearLayout) View.inflate(this, R.layout.row_rules_actions_list, null);
                            util.getView(childView, R.id.btnRowDelete).setVisibility(View.GONE);

                            callChildView = childView;
                            String sHTTP_source_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_name));
                            String sHTTP_source_sub_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_sub_name));
                            String sHTTP_condition_type_code = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_condition_type_code));
                            String sHTTP_condition_type_code_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_condition_type_code_name));
                            String sHTTP_cmdcls_value = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value));
                            String sHTTP_unit = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_unit));
                            String sHTTP_cmdcls_value_msg = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value_msg));
                            String sHTTP_image_file_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_image_file_name));
                            //                    String sDayofweek = getAlList_Conditions(1);

                            String sHTTP_available_yn = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_available_yn));

                            if ( sHTTP_available_yn.equals("N") ) {
                                util.getTextView(childView, R.id.tvRowTitle).setText(util.setSpCenterLine(act, sHTTP_source_name));
                            } else {
                                util.getTextView(childView, R.id.tvRowTitle).setText(sHTTP_source_name);
                            }
                            util.getTextView(childView, R.id.tvRowBody).setText(sHTTP_source_sub_name);
                            util.getTextView(childView, R.id.tvRowState).setVisibility(View.VISIBLE);
                            util.getTextView(childView, R.id.tvRowState).setText((sHTTP_cmdcls_value_msg.equals("") ? sHTTP_cmdcls_value : sHTTP_cmdcls_value_msg) + sHTTP_unit + (
                                    sHTTP_condition_type_code.equals("01")
                                    ? ""
                                    : sHTTP_condition_type_code_name));

                            util.setImage(act, sHTTP_image_file_name, util.getImageView(childView, R.id.ivRowIcon));
                            util.getLinearLayout(act, R.id.llActionBody).addView(childView);
                        }
                    } else if ( sHTTP_item_sub_type_code.equals("03") ) {
                        util.getLinearLayout(act, R.id.llAlram).setVisibility(View.VISIBLE);
                        //                        for ( int iRow1 = 0; iRow1 < alList_Item_Sub.size(); iRow1++ ) {
                        int iRow1 = 0;
                        LinearLayout childView = (LinearLayout) View.inflate(this, R.layout.row_rules_actions_alram_list, null);

                        callChildView = childView;
                        String sHTTP_cmdcls_value = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value));

//                        util.getView(childView, R.id.ivRowIcon).setVisibility(View.VISIBLE);
//                        util.getView(childView, R.id.edtRowTitle).setVisibility(View.GONE);
//                        util.getView(childView, R.id.tvRowTitle).setVisibility(View.VISIBLE);
                        util.getTextView(childView, R.id.tvRowTitle).setText(sHTTP_cmdcls_value);

                        //                        util.setImage(act, R.drawable.img_rule_trigger_icon_temperature, util.getImageView(childView, R.id.ivRowIcon));
                        util.getLinearLayout(act, R.id.llAlramBody).addView(childView);
                        //                        }
                    }
                }
            }
        } else {
            util.getLinearLayout(act, R.id.llAction).setVisibility(View.GONE);
        }
    }

    void setDispConditions_init() {

        Dlog.v("sACTIONS=", sACTIONS);
        alList_Conditions.clear();
        alList_Conditions = util.jsonToArrayListMap(sCONDITIONS);
        getAlList_Conditions(0);
    }
    private String getAlList_Conditions(int iType) {
        //        iType   = 1: 요일 담아주기
        String sReturn = "";
        if ( iType == 1 ) {
            if ( alList_Conditions.size() > 0 ) {
                for ( int iRow = 0; iRow < alList_Conditions.size(); iRow++ ) {
                    HashMap<String, Object> hmTemp = new HashMap<String, Object>();
                    hmTemp = alList_Conditions.get(iRow);

                    String sHTTP_item_sub_type_code = util.null2string(hmTemp.get(Constants.HTTP_item_sub_type_code));
                    if ( sHTTP_item_sub_type_code.equals("22") ) {
                        //요일
                        ArrayList<HashMap<String, Object>> alList_Item_Sub = new ArrayList<HashMap<String, Object>>();
                        if ( !util.null2string(hmTemp.get(Constants.HTTP_item_sub)).equals("") ) {
                            alList_Item_Sub = (ArrayList<HashMap<String, Object>>) hmTemp.get(Constants.HTTP_item_sub);
                            if ( alList_Item_Sub.size() > 0 ) {
                                HashMap<String, Object> hmTempItem_sub = new HashMap<String, Object>();
                                hmTempItem_sub = alList_Item_Sub.get(0);

                                String sHTTP_cmdcls_value_msg = util.null2string(hmTempItem_sub.get(Constants.HTTP_cmdcls_value_msg));
                                sReturn = sHTTP_cmdcls_value_msg;
                            }
                        }
                        break;
                    }
                }
            }
        } else {
//            util.getView(act, R.id.llCondition).setVisibility(View.GONE);
//            util.getView(act, R.id.llConditionTitle).setSelected(false);
//            util.getView(act, R.id.llConditionBody).setVisibility(View.GONE);
//            util.getLinearLayout(act, R.id.llConditionBody1).removeAllViews();
//            util.getLinearLayout(act, R.id.llConditionBody2).removeAllViews();
//            util.getLinearLayout(act, R.id.llConditionBody3).removeAllViews();

            util.getLinearLayout(act, R.id.llCondition).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llConditionBody1Title).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llConditionBody2Title).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llConditionBody3Title).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llConditionBody1).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llConditionBody2).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llConditionBody3).setVisibility(View.GONE);
            util.getLinearLayout(act, R.id.llConditionBody1).removeAllViews();
            util.getLinearLayout(act, R.id.llConditionBody2).removeAllViews();
            util.getLinearLayout(act, R.id.llConditionBody3).removeAllViews();


            if ( alList_Conditions.size() > 0 ) {
                for ( int iRow = 0; iRow < alList_Conditions.size(); iRow++ ) {
                    HashMap<String, Object> hmTemp = new HashMap<String, Object>();
                    hmTemp = alList_Conditions.get(iRow);

                    String sHTTP_item_sub_type_code = util.null2string(hmTemp.get(Constants.HTTP_item_sub_type_code));

                    if ( !sHTTP_item_sub_type_code.equals("22") ) {
                        ArrayList<HashMap<String, Object>> alList_Item_Sub = new ArrayList<HashMap<String, Object>>();
                        if ( !util.null2string(hmTemp.get(Constants.HTTP_item_sub)).equals("") ) {
                            alList_Item_Sub = (ArrayList<HashMap<String, Object>>) hmTemp.get(Constants.HTTP_item_sub);
                            if ( alList_Item_Sub.size() > 0 ) {
                                util.getView(act, R.id.llCondition).setVisibility(View.VISIBLE);
                                for ( int iRow1 = 0; iRow1 < alList_Item_Sub.size(); iRow1++ ) {
                                    HashMap<String, Object> hmTempItem_sub = new HashMap<String, Object>();
                                    hmTempItem_sub = alList_Item_Sub.get(0);

                                    LinearLayout childView = (LinearLayout) View.inflate(this, R.layout.row_rules_conditions_list, null);
                                    util.getView(childView, R.id.btnRowDelete).setVisibility(View.GONE);
                                    util.getView(childView, R.id.llRowBody_Body).setVisibility(View.GONE);
                                    util.getView(childView, R.id.tvRowState).setVisibility(View.VISIBLE);

                                    String sTempTitle = "";
                                    if ( sHTTP_item_sub_type_code.equals("02") ) {
                                        //모드
                                        util.getLinearLayout(act, R.id.llConditionBody1Title).setVisibility(View.VISIBLE);
                                        util.getLinearLayout(act, R.id.llConditionBody1).setVisibility(View.VISIBLE);
                                        String sHTTP_cmdcls_value = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value));
                                        String sHTTP_cmdcls_value_msg = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value_msg));

                                        util.getTextView(childView, R.id.tvRowState).setText(sHTTP_cmdcls_value_msg);
                                        util.setImage(act, R.drawable.img_rule_icon_homemode, util.getImageView(childView, R.id.ivRowIcon));
                                        util.getLinearLayout(act, R.id.llConditionBody1).addView(childView);
                                    } else if ( sHTTP_item_sub_type_code.equals("21") ) {
                                        //기간
                                        util.getLinearLayout(act, R.id.llConditionBody2Title).setVisibility(View.VISIBLE);
                                        util.getLinearLayout(act, R.id.llConditionBody2).setVisibility(View.VISIBLE);
                                        String sHTTP_cmdcls_value = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value));
                                        String sHTTP_cmdcls_value_msg = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value_msg));

                                        util.getTextView(childView, R.id.tvRowState).setText(sHTTP_cmdcls_value);

                                        util.setImage(act, R.drawable.img_rule_icon_calendar, util.getImageView(childView, R.id.ivRowIcon));
                                        util.getLinearLayout(act, R.id.llConditionBody2).addView(childView);
                                    } else if ( sHTTP_item_sub_type_code.equals("01") ) {
                                        //장치
                                        util.getLinearLayout(act, R.id.llConditionBody3Title).setVisibility(View.VISIBLE);
                                        util.getLinearLayout(act, R.id.llConditionBody3).setVisibility(View.VISIBLE);
                                        util.getView(childView, R.id.llRowBody_Body).setVisibility(View.VISIBLE);

                                        String sHTTP_source_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_name));
                                        String sHTTP_source_sub_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_source_sub_name));
                                        String sHTTP_condition_type_code = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_condition_type_code));
                                        String sHTTP_condition_type_code_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_condition_type_code_name));
                                        String sHTTP_cmdcls_value = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value));
                                        String sHTTP_cmdcls_value_msg = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_cmdcls_value_msg));
                                        String sHTTP_image_file_name = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_image_file_name));
                                        String sHTTP_unit = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_unit));
                                        //                    String sDayofweek = getAlList_Conditions(1);

                                        String sHTTP_available_yn = util.null2string(alList_Item_Sub.get(iRow1).get(Constants.HTTP_available_yn));

                                        if ( sHTTP_available_yn.equals("N") ) {
                                            util.getTextView(childView, R.id.tvRowTitle).setText(util.setSpCenterLine(act, sHTTP_source_name));
                                        } else {
                                            util.getTextView(childView, R.id.tvRowTitle).setText(sHTTP_source_name);
                                        }
                                        util.getTextView(childView, R.id.tvRowBody).setText(sHTTP_source_sub_name);
                                        util.getTextView(childView, R.id.tvRowState).setVisibility(View.VISIBLE);
                                        util.getTextView(childView, R.id.tvRowState).setText((sHTTP_cmdcls_value_msg.equals("") ? sHTTP_cmdcls_value : sHTTP_cmdcls_value_msg)
                                                                                             + sHTTP_unit
                                                                                             + (sHTTP_condition_type_code.equals("01") ? "" : sHTTP_condition_type_code_name));

                                        util.setImage(act, sHTTP_image_file_name, util.getImageView(childView, R.id.ivRowIcon));
                                        util.getLinearLayout(act, R.id.llConditionBody3).addView(childView);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return sReturn;
    }
}
