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

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

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.ntels.kneet.v3.common.AppConfig;
import com.ntels.kneet.v3.common.Constants;
import com.ntels.kneet.v3.common.http.HttpSend;
import com.ntels.kneet.v3.common.http.Response;
import com.ntels.kneet.v3.common.c_interface.List_Interface;
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.LogUtil;
import com.ntels.kneet.v3.common.util.Util;
import com.ntels.kneet.v3.common.websocket.WebSocketService;
import com.ntels.kneet.v3.common.websocket.onWebSocketResponse;
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.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

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

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

    private int firstVisibleItem, visibleItemCount, totalItemCount;
    private int iMemberCnt     = 0;
    private int iInvitationCnt = 0;

    private ArrayList<HashMap<String, Object>> alList_Item_Sub              = new ArrayList<HashMap<String, Object>>();
    private HashMap<String, Object>            hmItem_Sub                   = new HashMap<String, Object>();
    private ArrayList<HashMap<String, Object>> alList_Invitation            = new ArrayList<HashMap<String, Object>>();
    private String                             sHTTP_item_name              = "";
    private String                             sHTTP_item_sub_type_code     = "";
    private String                             sHTTP_source_id              = "";
    private String                             sHTTP_source_sub_id          = "";
    private String                             sHTTP_condition_type_code    = "";
    private String                             sHTTP_cmdcls_value           = "";
    private String                             sPASSWORD                    = "";
    private String                             sEMAIL_ID                    = "";
    private String                             sSelectItem                  = "";
    private int                                iSelectPosition              = 0;
    private String                             sHTTP_nickname               = "";
    private String                             sHTTP_homegrp_id             = "";
    private String                             sHTTP_status_code            = "";
    private String                             sHTTP_target_email           = "";
    private String                             sHTTP_authorization_reply    = "";
    private String                             sHTTP_homegrp_name           = "";
    private String                             sHTTP_authorization_question = "";
    private String                             sHTTP_error_count            = "";
    private String                             sDEVICE_ID                   = "";
    private String                             sNODE_ID                     = "";
    private String                             sSearch_Type                 = "";
    private String                             sHist_id                     = "";
    private String                             sMaxHist_id                  = "";
    private String                             sMinHist_id                  = "";
    private boolean                            bMore                        = true;

    private boolean bReloadFinishFlag = false;

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

    /*통신 관련*/
    private              ArrayList<HashMap<String, Object>> alTotalList                                        = new ArrayList<HashMap<String, Object>>();
    private              ArrayList<HashMap<String, Object>> alTotalList_M                                      = new ArrayList<HashMap<String, Object>>();
    private              int                                iType                                              = 0;
    private static final int                                MSG_COM_G_DEVICES_DEVICE_ID                        = 1;
    private static final int                                MSG_COM_G_DEVICES_NODES                            = 2;
    private static final int                                MSG_COM_WS_NODE_COMMAND                            = 3;
//    private static final int                                MSG_COM_P_DEVICES_DEVICE_ID_NODES_NODE_ID_COMMANDS = 3;

    /*리스트 관련*/
    //    private Things_Detail_Adapter      dataAdapter;
    private RecyclerView               rcvList;
    private SwipeRefreshLayout         swipeRefreshLayout;
    private GridLayoutManager          glmList;
    private LinearLayoutManager        llmList;
    private Dialog_Custom_List.Builder dialog_list_builder;
    private ScheduledFuture            scheduledFuture;
    private boolean loading            = false;
    private boolean bListHeader        = false;
    private boolean bListFooter        = false;
    private boolean bListFooterVisible = false;
    private boolean bListFooterAnd     = false;
    private int     iListColumnsCnt    = 1;

    /*공통*/
    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 String       sCall_HTTP_device_id     = "";
    private String       sCall_HTTP_node_id       = "";
    private String       sCall_HTTP_request_value = "";
    private String       sCall_HTTP_cmdcls_id     = "";
    private Boolean      bPollingPause            = false;
    private Boolean      bPollingCancel           = false;
    private Boolean      bActStop                 = false;
    private int          iThingsAction            = 0;
    private int          iIvPosition              = 0;
    private ViewPager                vpNode_M;
    private Things_Detail_Vp_Adapter pageAdapter;
    private ImageView ivMPage[] = new ImageView[50];
    private WebSocketService   webSocketService;
    private boolean            bBound             = false;

    @Override public void onStop() {

        super.onStop();
        Dlog.v("onStop()");
        bPollingPause = true;
        bActStop = true;
    }
    @Override public void onPause() {

        super.onPause();
        Dlog.v("onPause()");
        bPollingPause = true;
        bActStop = true;
    }

    @Override public void onResume() {

        super.onResume();
        Dlog.v("onResume()");
        bPollingPause = false;
        bActStop = false;
    }

    @Override public void onDestroy() {

        super.onDestroy();
        Dlog.v("onDestroy()");
        if ( scheduledFuture != null ) {
            scheduledFuture.cancel(false);
            bPollingPause = true;
        }
        if ( bBound ) {
            webSocketService.removeWebSocketResponse(webSocketResponse);
            unbindService(serviceConnection);
            bBound = false;
        }
    }

    @Override protected void onNewIntent(Intent saveIntent) {

        super.onNewIntent(saveIntent);
        //        if ( null != saveIntent ) {
        //            Boolean bTEmp = saveIntent.getBooleanExtra(KneetMessageLocalBroadCast.INTENT_ACTION_HOMEHUB_STATE_CHANGE, false);
        //            Dlog.v("bTEmp", bTEmp);
        //            setHomeHubStateAll();
        //        }
    }

    /**
     *  Service bind listener
     *
     */
    private ServiceConnection serviceConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            LogUtil.i(TAG, "");
            WebSocketService.WebSocketBinder binder = (WebSocketService.WebSocketBinder) service;
            webSocketService = binder.getService();
            webSocketService.addWebSocketResponse(webSocketResponse);
            bBound = true;
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            bBound = false;
        }
    };

    /**
     *  WebSocket listener
     *
     */
    private onWebSocketResponse webSocketResponse = new onWebSocketResponse() {
        @Override
        public void onWebSocketResponse(String result) {
            try {

                JSONObject jsonObject = new JSONObject(result);
                String messageType = util.null2string(jsonObject.get(Constants.WEBSOCKET_KEY_MESSAGE_TYPE));
                LogUtil.i(TAG, "websocket message type : " + messageType);
                String resultCode = "";
                String resultMsg = "";
                if ( jsonObject.has(Constants.WEBSOCKET_KEY_RESULT_CODE) ) {
                    resultCode = util.null2string(jsonObject.get(Constants.WEBSOCKET_KEY_RESULT_CODE));
                }
                if ( jsonObject.has(Constants.WEBSOCKET_KEY_RESULT_MSG) ) {
                    resultMsg = util.null2string(jsonObject.get(Constants.WEBSOCKET_KEY_RESULT_MSG));
                }
                if ( messageType.equals(Constants.WEBSOCKET_TYPE_NODE_COMMAND_RESULT) ) {
                    result_WS_node_command(jsonObject);
                } else if ( messageType.equals(Constants.WEBSOCKET_TYPE_NODE_CONTENT) ) {
                    notification_WS_node_content(jsonObject);
                } else {
                    /*final String finalResultMsg = resultMsg;
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            util.setShowToast(act, finalResultMsg, Toast.LENGTH_SHORT);
                        }
                    });*/
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onWebSocketError(String message) {

        }
    };

    @Override protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        act = Things_Detail.this;
        appConfig = (AppConfig) act.getApplicationContext();
        customDialog.setOnMsgAlterToResultEvent(this);

        Intent serviceIntent = new Intent(act, WebSocketService.class);
        act.bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);

        View viewToLoad = LayoutInflater.from(act).inflate(R.layout.things_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();
            sDEVICE_ID = intent.getStringExtra(Constants.EXTRA_DEVICE_ID);
            sNODE_ID = intent.getStringExtra(Constants.EXTRA_NODE_ID);
        }

        setToolbar();

        displayListView();
    }

    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.VISIBLE);
        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_things_detail_01));
        util.getTextView(toolbar, R.id.tvToolbarTitle2).setText("");

        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(2));
                }
                MsgAlertList(alMenuList);
            }
        });
    }

    public void setHomeHubStateAll() {

        setHomeHubStateTitle();
        setHomeHubStateList();
    }

    public void setHomeHubStateTitle() {

        if ( appConfig.getSelect_Homegrp_Id().equals("") ) {
            //홈그룹 없을경우
            util.getView(toolbar, R.id.llToolbar).setVisibility(View.VISIBLE);
            util.getView(toolbar, R.id.llToolbarHomeHub).setVisibility(View.GONE);
            util.getView(toolbar, R.id.btnToolbarMore).setVisibility(View.GONE);
            util.getView(toolbar, R.id.btnToolbarClose).setVisibility(View.GONE);
            if ( dialog_list_builder != null ) {
                dialog_list_builder.create().dismiss();
            }
        } else {
            //홈그룹 있을경우
            if ( appConfig.getSelect_Homegrp_Homehub_Device_Id().equals("") ) {
                //홈그룹은 있고 홈허브가 없는경우
                util.getView(toolbar, R.id.llToolbar).setVisibility(View.GONE);
                util.getView(toolbar, R.id.llToolbarHomeHub).setVisibility(View.VISIBLE);
                util.getTextView(toolbar, R.id.tvToolbarHomeHub).setText(util.getString(act, R.string.layout_homehub_delete));
                util.getView(toolbar, R.id.btnToolbarMore).setVisibility(View.GONE);
                util.getView(toolbar, R.id.btnToolbarClose).setVisibility(View.GONE);
                if ( dialog_list_builder != null ) {
                    dialog_list_builder.create().dismiss();
                }
            } else {
                //                util.getView(toolbar, R.id.btnToolbarMore).setVisibility(View.VISIBLE);
                if ( appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                    //홈그룹은 있고 홈허브가 오프라인인경우
                    util.getView(toolbar, R.id.llToolbar).setVisibility(View.GONE);
                    util.getView(toolbar, R.id.llToolbarHomeHub).setVisibility(View.VISIBLE);
                    util.getTextView(toolbar, R.id.tvToolbarHomeHub).setText(util.getString(act, R.string.layout_homehub_offline));
                    //                    util.getView(toolbar, R.id.btnToolbarClose).setVisibility(View.GONE);
                } else {
                    //홈그룹은 있고 홈허브가 온라인인 경우
                    util.getView(toolbar, R.id.llToolbar).setVisibility(View.VISIBLE);
                    util.getView(toolbar, R.id.llToolbarHomeHub).setVisibility(View.GONE);
                }
            }
        }
    }

    public boolean setHomeHubStateList() {

        //        Dlog.v("Things setHomeHubStateList()");
        Boolean bListLoad = false;
        if ( appConfig.getSelect_Homegrp_Id().equals("") ) {
            //홈그룹 없을경우
            swipeRefreshLayout.setVisibility(View.INVISIBLE);
            //            dataAdapter.setListCheck(false);
            //            dataAdapter.notifyDataSetChanged();
            callVpReLoad();
            setRefresh(false);
        } else {
            //홈그룹 있을경우
            if ( appConfig.getSelect_Homegrp_Homehub_Device_Id().equals("") ) {
                //홈그룹은 있고 홈허브가 없는경우
                if ( appConfig.getSelect_Homegrp_Grade_Code().equals("MAS") ) {
                    swipeRefreshLayout.setVisibility(View.INVISIBLE);
                    //                    dataAdapter.setListCheck(false);
                    //                    dataAdapter.notifyDataSetChanged();
                    callVpReLoad();
                    setRefresh(false);
                } else {
                    swipeRefreshLayout.setVisibility(View.INVISIBLE);
                    //                    dataAdapter.setListCheck(false);
                    //                    dataAdapter.notifyDataSetChanged();
                    callVpReLoad();
                    setRefresh(false);
                }
            } else {
                if ( alTotalList.size() > 0 ) {
                    swipeRefreshLayout.setVisibility(View.VISIBLE);
                } else {
                    swipeRefreshLayout.setVisibility(View.INVISIBLE);
                    //                    dataAdapter.setListCheck(false);
                }
                if ( appConfig.getSelect_Homegrp_Grade_Code().equals("MAS") ) {
                    //                    dataAdapter.setFooterVisible(true);
                } else {
                    //                    dataAdapter.setFooterVisible(false);
                }
                //                dataAdapter.notifyDataSetChanged();
                callVpReLoad();
                bListLoad = true;
            }
        }
        return bListLoad;
    }

    private void callVpReLoad() {

        if ( alTotalList_M.size() > 0 ) {
            //            vpNode_M.setCurrentItem(iIvPosition);
            vpNode_M.getAdapter().notifyDataSetChanged();
            util.getLinearLayout(act, R.id.llvpNode_M_Icon).setVisibility(View.GONE);

            vpNode_M.post(new Runnable() {
                @Override public void run() {

                    try {
                    if ( alTotalList_M.size() > 1 ) {
                        util.getLinearLayout(act, R.id.llvpNode_M_Icon).setVisibility(View.VISIBLE);

                        ViewGroup.LayoutParams params1 = util.getLinearLayout(act, R.id.llvpNode_M_Icon).getLayoutParams();
                        params1.height = util.getView(act, R.id.vpNode_M).getHeight();
                        util.getLinearLayout(act, R.id.llvpNode_M_Icon).setLayoutParams(params1);
                        if ( ivMPage[iIvPosition] != null ) {
                            ivMPage[iIvPosition].setSelected(true);
                        }
                    }
                    } catch (Exception ex) {
//                        ex.printStackTrace();
                        //             customDialog.MsgAlert(act,Constants.MSG807);
                    }
                }
            });
        }
    }
    private void displayListView() {

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

        alTotalList.clear();

        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 ( !pageAdapter.getListCheck() ) {
                if ( !loading ) {
                    loading = true;
                    //sSearchPlan = "U";
                    //sDateTime = sMaxDatetime;
                    ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
                }
                //                } else {
                //                    swipeRefreshLayout.setRefreshing(false);
                //                }
            }
        });
        setRefresh(true);

        vpNode_M = (ViewPager) findViewById(R.id.vpNode_M);
        alTotalList_M.clear();
        iIvPosition = 0;
        pageAdapter = new Things_Detail_Vp_Adapter(act, alTotalList_M, this);
        vpNode_M.setAdapter(pageAdapter);
        vpNode_M.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            int iLastPosition = -1;

            @Override public void onPageSelected(int position) {

                iIvPosition = position;

                if ( alTotalList_M.size() > 0 ) {
                    for ( int iRow = 0; iRow < alTotalList_M.size(); iRow++ ) {
                        if ( ivMPage[iRow] != null ) {
                            ivMPage[iRow].setSelected(false);
                        }
                    }
                    if ( ivMPage[iIvPosition] != null ) {
                        ivMPage[iIvPosition].setSelected(true);
                    }
                }
            }

            @Override public void onPageScrolled(int position, float positionOffest, int positionOffsetPixels) {

                Dlog.v("onPageScrolled position=" + position + " iPosition=" + iIvPosition + " iLastPosition=" + iLastPosition);
            }

            @Override public void onPageScrollStateChanged(int state) {

                Dlog.v("onPageScrollStateChanged state=" + state);
            }
        });

        setHomeHubStateTitle();
        if ( setHomeHubStateList() ) {
            ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
        }
    }

    private void setRefresh(boolean bVal) {

        swipeRefreshLayout.setEnabled(false);
        //        if ( bVal ) {
        //            swipeRefreshLayout.setEnabled(true);
        //        } else {
        //            swipeRefreshLayout.setEnabled(false);
        //        }
    }

    @Override public void onClick(View v) {

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

    private void setThingsPolling() {

        Dlog.v("Things setThingsPolling");
        ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();

        scheduledFuture = scheduler.scheduleAtFixedRate(runnable, 3, 3, TimeUnit.SECONDS);
    }

    Runnable runnable = new Runnable() {
        public void run() {

            Dlog.v("Things bPollingCancel", bPollingCancel);
            Dlog.v("Things bPollingPause", bPollingPause);

            if ( bPollingCancel ) {
                scheduledFuture.cancel(false);
            }
            if ( !bPollingPause ) {
                Dlog.v("Things setThingsPolling");
                if ( appConfig.getSelect_Homegrp_Homehub_Online_State().equals("ON") ) {
                    if ( alTotalList.size() > 0 ) {
                        Dlog.v("Things jino");
                        send_G_devices_nodes();
                    }
                }
            }
        }
    };

    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_DEVICES_DEVICE_ID:
                    //dialog_show();
                    send_G_devices_device_id();
                    break;

                case MSG_COM_G_DEVICES_NODES:
                    //dialog_show();
                    send_G_devices_nodes();
                    break;
                case MSG_COM_WS_NODE_COMMAND:
                    //dialog_show();
//                    send_P_devices_device_id_nodes_node_id_commands();
                    send_WS_node_command();
                    break;
                default:
                    break;
            }
            return true;
        }
    }

    /**
     * <PRE>
     * 1. MethodName: send_G_devices_nodes
     * 2. ClassName :
     * 3. Comment   : [Send][GET]복수 - 노드(커맨드클래스) 마지막 상태 값 조회(복수 노드(커맨드클래스)의 마지막 상태 값을 조회한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void send_G_devices_nodes() {

        try {
            HttpSend httpSend;

            httpSend = new HttpSend(act, false);
            //httpSend = new HttpSend(act);

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

                    result_G_devices_nodes(result);
                }
            });

            String sTemp = "";
            for ( int iRow = 0; iRow < alTotalList.size(); iRow++ ) {
                String sTempHTTP_device_id = util.null2string(alTotalList.get(iRow).get(Constants.HTTP_device_id));
                String sTempHTTP_node_id = util.null2string(alTotalList.get(iRow).get(Constants.HTTP_node_id));
                //                String sTempHTTP_collect_time = util.null2string(alTotalList.get(iRow).get(Constants.HTTP_collect_time));

                //                sTemp += (sTemp.equals("") ? "" : ",") + sTempHTTP_device_id + "_" + sTempHTTP_node_id + "_" + sTempHTTP_collect_time;
                sTemp += (sTemp.equals("") ? "" : ",") + sTempHTTP_device_id + "_" + sTempHTTP_node_id;
            }

            bPollingPause = true;
            httpSend.G_devices_nodes(sTemp);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * <PRE>
     * 1. MethodName: result_G_devices_nodes
     * 2. ClassName :
     * 3. Comment   : [Result][GET]복수 - 노드(커맨드클래스) 마지막 상태 값 조회(복수 노드(커맨드클래스)의 마지막 상태 값을 조회한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void result_G_devices_nodes(Response rpResult) {

        try {
            if ( rpResult.getStatusCode() == 200 ) {
                if ( !rpResult.getContent().equals("") ) {
                    ArrayList<HashMap<String, Object>> alList = util.jsonToArrayListMap(rpResult.getContent());
                    for ( int iRow = 0; iRow < alList.size(); iRow++ ) {
                        String sTempHTTP_device_id1 = util.null2string(alList.get(iRow).get(Constants.HTTP_device_id));
                        String sTempHTTP_node_id1 = util.null2string(alList.get(iRow).get(Constants.HTTP_node_id));
                        //                        String sTempHTTP_content_id1 = util.null2string(alList.get(iRow).get(Constants.HTTP_content_id));
                        String sTempHTTP_content_value1 = util.null2string(alList.get(iRow).get(Constants.HTTP_content_value));
                        String sTempHTTP_collect_time1 = util.null2string(alList.get(iRow).get(Constants.HTTP_collect_time));
                        String sTempHTTP_online_state1 = util.null2string(alList.get(iRow).get(Constants.HTTP_online_state));

                        for ( int iRow1 = 0; iRow1 < alTotalList.size(); iRow1++ ) {
                            String sTempHTTP_device_id2 = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_device_id));
                            String sTempHTTP_node_id2 = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_node_id));
                            String sTempHTTP_request_time2 = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_request_time));
                            if ( sTempHTTP_device_id1.equals(sTempHTTP_device_id2) && sTempHTTP_node_id1.equals(sTempHTTP_node_id2) ) {
                                alTotalList.get(iRow1).put(Constants.HTTP_content_value, sTempHTTP_content_value1);
                                alTotalList.get(iRow1).put(Constants.HTTP_collect_time, sTempHTTP_collect_time1);
                                alTotalList.get(iRow1).put(Constants.HTTP_online_state, sTempHTTP_online_state1);
                                if ( !sTempHTTP_request_time2.equals("") ) {
                                    if ( !sTempHTTP_collect_time1.equals("") ) {
                                        if ( util.str2long(util.UTCtoLocal4(sTempHTTP_collect_time1.replaceAll("Z", ""))) > util.str2long(util.UTCtoLocal4(sTempHTTP_request_time2.replaceAll(
                                                "Z", ""))) ) {
                                            iThingsAction = 0;
                                            alTotalList.get(iRow1).put(Constants.HTTP_request_time, "");
                                            Dlog.v("Things jino1");
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                    for ( int iRow1 = 0; iRow1 < alTotalList.size(); iRow1++ ) {
                        String sHTTP_request_time = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_request_time));
                        if ( !sHTTP_request_time.equals("") ) {
                            Dlog.v("Things jino5");
                            Dlog.v("Things jino5 sHTTP_request_time=" + sHTTP_request_time);
                            Dlog.v("Things jino5 util.getRealTime1()=" + util.getRealTime1());
                            Dlog.v("Things jino5 10초후=" + util.stringDateAddTime(util.UTCtoLocal4(sHTTP_request_time.replaceAll("Z", "")), 10000));
                            if ( util.str2long(util.getRealTime1()) > util.str2long(util.stringDateAddTime(util.UTCtoLocal4(sHTTP_request_time.replaceAll("Z", "")), 10000)) ) {
                                iThingsAction++;
                                alTotalList.get(iRow1).put(Constants.HTTP_request_time, "");
                            }
                        }
                    }
                    if ( iThingsAction == 3 ) {
                        util.setShowToast(act, util.getString(act, R.string.MSG867), Toast.LENGTH_SHORT);
                    }
                    setNode_Disp();
                    setHomeHubStateList();
                }
            } 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") ) {
                    if ( scheduledFuture != null ) {
                        scheduledFuture.cancel(false);
                    }
                    customDialog.MsgAlert(act, Constants.MSG998, sERR_MSG);
                } else if ( sERR_CODE.equals("401-106") ) {
                    if ( scheduledFuture != null ) {
                        scheduledFuture.cancel(false);
                    }
                    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);
        }

        bPollingPause = bActStop;
    }

    /**
     * <PRE>
     * 1. MethodName: send_G_devices_device_id
     * 2. ClassName :
     * 3. Comment   : [Send][GET]장치 상세 조회(해당 장치의 상세 정보를 조회한다. (장치가 보유한 모든 커맨드 클래스 리스트를 보여준다.))
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void send_G_devices_device_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_devices_device_id(result);
                }
            });
            if ( scheduledFuture != null ) {
                scheduledFuture.cancel(false);
            }
            alTotalList.clear();
            swipeRefreshLayout.setVisibility(View.INVISIBLE);
            httpSend.G_devices_device_id(sDEVICE_ID, sNODE_ID);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * <PRE>
     * 1. MethodName: result_G_devices_device_id
     * 2. ClassName :
     * 3. Comment   : [Result][GET]장치 상세 조회(해당 장치의 상세 정보를 조회한다. (장치가 보유한 모든 커맨드 클래스 리스트를 보여준다.))
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void result_G_devices_device_id(Response rpResult) {

        try {
            if ( rpResult.getStatusCode() == 200 ) {
                JSONObject joResult = new JSONObject(rpResult.getContent());
                Dlog.v(joResult.toString());
                String sHTTP_device_id = util.null2string(joResult.get(Constants.HTTP_device_id));
//                String sHTTP_device_key = util.null2string(joResult.get(Constants.HTTP_device_key));
                String sHTTP_device_name = "";
                String sHTTP_deviceclass_type_id = util.null2string(joResult.get(Constants.HTTP_deviceclass_type_id));
                String sHTTP_image_file_name = util.null2string(joResult.get(Constants.HTTP_image_file_name));
                String sHTTP_group_name = "";
                String sHTTP_prd_name = "";
                String sHTTP_device_model_id = "";
                String sHTTP_device_mf_id = "";
                String sHTTP_firmware_version = "";
                String sHTTP_create_datetime = "";
                String sHTTP_device_protocol_type = "";
                String sHTTP_removable_yn = "";
                String sHTTP_activation_code = "";
                String sHTTP_online_state = "";
                String sHTTP_node_id = "";
                String sHTTP_cmdcls_id = "";

                if ( joResult.has(Constants.HTTP_device_name) ) {
                    sHTTP_device_name = util.null2string(joResult.get(Constants.HTTP_device_name));
                }
                if ( joResult.has(Constants.HTTP_node_id) ) {
                    sHTTP_node_id = util.null2string(joResult.get(Constants.HTTP_node_id));
                }
                if ( joResult.has(Constants.HTTP_group_name) ) {
                    sHTTP_group_name = util.null2string(joResult.get(Constants.HTTP_group_name));
                }
                if ( joResult.has(Constants.HTTP_prd_name) ) {
                    sHTTP_prd_name = util.null2string(joResult.get(Constants.HTTP_prd_name));
                }
                if ( joResult.has(Constants.HTTP_device_model_id) ) {
                    sHTTP_device_model_id = util.null2string(joResult.get(Constants.HTTP_device_model_id));
                }
                if ( joResult.has(Constants.HTTP_device_mf_id) ) {
                    sHTTP_device_mf_id = util.null2string(joResult.get(Constants.HTTP_device_mf_id));
                }
                if ( joResult.has(Constants.HTTP_firmware_version) ) {
                    sHTTP_firmware_version = util.null2string(joResult.get(Constants.HTTP_firmware_version));
                }
                if ( joResult.has(Constants.HTTP_create_datetime) ) {
                    sHTTP_create_datetime = util.null2string(joResult.get(Constants.HTTP_create_datetime));
                }
                if ( joResult.has(Constants.HTTP_device_protocol_type) ) {
                    sHTTP_device_protocol_type = util.null2string(joResult.get(Constants.HTTP_device_protocol_type));
                }

                if ( joResult.has(Constants.HTTP_removable_yn) ) {
                    sHTTP_removable_yn = util.null2string(joResult.get(Constants.HTTP_removable_yn));
                }

                if ( joResult.has(Constants.HTTP_online_state) ) {
                    sHTTP_online_state = util.null2string(joResult.get(Constants.HTTP_online_state));
                }

                String sCmdclsList = util.null2string(joResult.get(Constants.HTTP_cmdcls_list));

                //                HashMap<String, Object> hmTempHead = new HashMap<String, Object>();
                //                hmTempHead.put(Constants.HTTP_device_id, sHTTP_device_id);
                //                hmTempHead.put(Constants.HTTP_device_name, sHTTP_device_name);
                //                hmTempHead.put(Constants.HTTP_image_file_name, sHTTP_image_file_name);
                //                hmTempHead.put(Constants.HTTP_device_mf_id, sHTTP_device_mf_id);
                //                hmTempHead.put(Constants.HTTP_online_state, sHTTP_online_state);
                //                alTotalList.add(hmTempHead);

                util.setImage(act, sHTTP_image_file_name, R.id.ivThingsIcon);
                util.getTextView(act, R.id.tvThingsName).setText(sHTTP_device_name);

                ArrayList<HashMap<String, Object>> alList = util.jsonToArrayListMap(sCmdclsList);
                LogUtil.i(TAG, "alList : " + alList.toString());
                if ( alList.size() > 0 ) {
                    for ( int iRow = 0; iRow < alList.size(); iRow++ ) {
                        HashMap<String, Object> hmTemp = new HashMap<String, Object>();
                        hmTemp = alList.get(iRow);
                        hmTemp.put(Constants.HTTP_device_id, sHTTP_device_id);
                        hmTemp.put(Constants.HTTP_node_id, sHTTP_node_id);
                        hmTemp.put(Constants.HTTP_device_mf_id, sHTTP_device_mf_id);
                        hmTemp.put(Constants.HTTP_online_state, sHTTP_online_state);
                        LogUtil.i(TAG, "hmTemp : " + hmTemp.toString());
                        alTotalList.add(hmTemp);
                    }
                }

                //disp node
                setNode_Disp();
                loading = false;
                setHomeHubStateAll();
                bPollingPause = bActStop;
                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_P_devices_device_id_nodes_node_id_commands
     * 2. ClassName :
     * 3. Comment   : [Send][POST]노드(커맨드클래스) 제어 명령 실행(노드(커맨드클래스) 제어 명령을 실행한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void send_P_devices_device_id_nodes_node_id_commands() {

        try {
            HttpSend httpSend;

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

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

                    result_P_devices_device_id_nodes_node_id_commands(result);
                }
            });
            httpSend.P_devices_device_id_nodes_node_id_commands(sCall_HTTP_device_id, sCall_HTTP_node_id, sCall_HTTP_request_value);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    /**
     * <PRE>
     * 1. MethodName: result_P_devices_device_id_nodes_node_id_commands
     * 2. ClassName :
     * 3. Comment   : [Result][POST]노드(커맨드클래스) 제어 명령 실행(노드(커맨드클래스) 제어 명령을 실행한다.)
     * 4. Developer : 최진오
     * 5. Created   : 2015. 10.
     * </PRE>
     */
    private void result_P_devices_device_id_nodes_node_id_commands(Response rpResult) {

        try {
            if ( rpResult.getStatusCode() == 200 ) {
                JSONObject joResult = new JSONObject(rpResult.getContent());
                String sResultHTTP_device_id = util.null2string(joResult.get(Constants.HTTP_device_id));
                String sResultHTTP_node_id = util.null2string(joResult.get(Constants.HTTP_node_id));
                String sResultHTTP_request_time = util.null2string(joResult.get(Constants.HTTP_request_time));
                for ( int iRow = 0; iRow < alTotalList.size(); iRow++ ) {

                    String sHTTP_device_id = util.null2string(alTotalList.get(iRow).get(Constants.HTTP_device_id));
                    String sHTTP_node_id = util.null2string(alTotalList.get(iRow).get(Constants.HTTP_node_id));
                    if ( sResultHTTP_device_id.equals(sHTTP_device_id) && sResultHTTP_node_id.equals(sHTTP_node_id) ) {
                        alTotalList.get(iRow).put(Constants.HTTP_request_time, sResultHTTP_request_time);

                        Dlog.v("Things jino0 =" + sResultHTTP_request_time);
                        break;
                    }
                }
                setHomeHubStateList();
            } 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);
        }
    }

    @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);
                } else {
                    act.onBackPressed();
                }
                break;
            default:
                break;
        }
    }

    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:
                            String sHTTP_device_id = util.null2string(alTotalList.get(0).get(Constants.HTTP_device_id));
                            String sHTTP_device_name = util.null2string(alTotalList.get(0).get(Constants.HTTP_device_name));
                            String sHTTP_node_id = util.null2string(alTotalList.get(0).get(Constants.HTTP_node_id));
                            intent = new Intent(act, Things_Name_Change.class);
                            intent.putExtra(Constants.EXTRA_DEVICE_ID, sHTTP_device_id);
                            intent.putExtra(Constants.EXTRA_DEVICE_NAME, sHTTP_device_name);
                            intent.putExtra(Constants.EXTRA_NODE_ID, sHTTP_node_id);
                            util.callActivityForResultNoAnim(act, intent, Constants.ACT_THINGS_NAME_CHANGE);
                            break;
                        case 3:
                            break;
                        case 4:
                            break;
                        case 5:
                            break;
                        case 6:
                            ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_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;
                    }
                }
            });
            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 protected void onSaveInstanceState(Bundle outState) {

        super.onSaveInstanceState(outState);
    }

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

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

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

        super.onActivityResult(requestCode, resultCode, data);
        String sCALL_TYPE = "";
        if ( resultCode == RESULT_OK ) {
            switch (requestCode) {
                case Constants.ACT_THINGS_NAME_CHANGE:
                    bReloadFinishFlag = true;
                    ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_G_DEVICES_DEVICE_ID), 10);
                    break;
            }
        } else {
            if ( appConfig.getGoErr() ) {
                act.setResult(RESULT_CANCELED, new Intent());
                finish();
            }
            switch (requestCode) {
                //				case Constants.ACT_RULES_CREATE_SAMPLE_STEP02:
                //					Boolean bExit = data.getBooleanExtra(Constants.EXTRA_EXIT_FLAG, false);
                //					if (bExit) {
                //						Intent intent1 = new Intent();
                //						intent1.putExtra(Constants.EXTRA_EXIT_FLAG, bExit);
                //						this.setResult(RESULT_CANCELED, intent1);
                //						finish();
                //					}
                //					break;
            }
        }
    }

    public void setNode_Disp() {

        try {
            Boolean bOption_First = true;
            alTotalList_M.clear();
            util.getLinearLayout(act, R.id.llvpNode_M_Icon).removeAllViews();
            for ( int iRow = 0; iRow < alTotalList.size(); iRow++ ) {
                HashMap<String, Object> hmItem = new HashMap<String, Object>();
                hmItem = alTotalList.get(iRow);

                String sHTTP_cmdcls_mandatory_yn = util.null2string(hmItem.get(Constants.HTTP_cmdcls_mandatory_yn));
                if ( sHTTP_cmdcls_mandatory_yn.equals("Y") ) {
                    alTotalList_M.add(hmItem);
                    LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(util.getScaleVal(act, 24), util.getScaleVal(act, 10));
                    ivMPage[alTotalList_M.size() - 1] = new ImageView(act);
                    ivMPage[alTotalList_M.size() - 1].setImageResource(R.drawable.d_common_bullet_circle2);
                    ivMPage[alTotalList_M.size() - 1].setLayoutParams(params2);
                    ivMPage[alTotalList_M.size() - 1].setPadding(util.getScaleVal(act, 7), 0, util.getScaleVal(act, 7), 0);
                    ivMPage[alTotalList_M.size() - 1].setSelected(false);
                    util.getLinearLayout(act, R.id.llvpNode_M_Icon).addView(ivMPage[alTotalList_M.size() - 1]);
                } else {
                    String sHTTP_online_state = util.null2string(hmItem.get(Constants.HTTP_online_state));
                    String sHTTP_device_id = util.null2string(hmItem.get(Constants.HTTP_device_id));
                    String sHTTP_device_mf_id = util.null2string(hmItem.get(Constants.HTTP_device_mf_id));
                    String sHTTP_cmdcls_id = util.null2string(hmItem.get(Constants.HTTP_cmdcls_id));
                    String sHTTP_cmdcls_name = util.null2string(hmItem.get(Constants.HTTP_cmdcls_name));
                    String sHTTP_control_min_value = util.null2string(hmItem.get(Constants.HTTP_control_min_value));
                    String sHTTP_control_max_value = util.null2string(hmItem.get(Constants.HTTP_control_max_value));
                    String sHTTP_control_step = util.null2string(hmItem.get(Constants.HTTP_control_step));
                    String sHTTP_unit = util.null2string(hmItem.get(Constants.HTTP_unit));
                    String sHTTP_data_type_code = util.null2string(hmItem.get(Constants.HTTP_data_type_code));
                    String sHTTP_cmdcls_type_id = util.null2string(hmItem.get(Constants.HTTP_cmdcls_type_id));
                    int iCmdcls_Type = util.null2int(hmItem.get(Constants.HTTP_cmdcls_type_id));
                    String sHTTP_cmdcls_code = util.null2string(hmItem.get(Constants.HTTP_cmdcls_code));
                    String sHTTP_cmdcls_type_name = util.null2string(hmItem.get(Constants.HTTP_cmdcls_type_name));
                    String sHTTP_cmdcls_type_system_name = util.null2string(hmItem.get(Constants.HTTP_cmdcls_type_system_name));
                    String sHTTP_content_value = util.null2string(hmItem.get(Constants.HTTP_content_value));
                    String sHTTP_request_time = util.null2string(hmItem.get(Constants.HTTP_request_time));

                    String sTempValue = "";
                    String sSelect = util.getStringValues(act, "CMDCLS_TYPE_ID_" + sHTTP_cmdcls_type_id + "_BG_DEFAULT");
                    if ( sHTTP_content_value.equals("none") ) {
                        sTempValue = util.getStringValues(act, "CMDCLS_TYPE_ID_" + sHTTP_cmdcls_type_id + "_" + sSelect);
                        sHTTP_content_value =sSelect;
                    } else {
                        sTempValue = util.getStringValues(act, "CMDCLS_TYPE_ID_" + sHTTP_cmdcls_type_id + "_" + sHTTP_content_value);
                    }
                    LinearLayout childView = (LinearLayout) View.inflate(this, R.layout.row_things_detail_list, null);
                    if ( bOption_First ) {
                        bOption_First = false;
                        util.getLinearLayout(act, R.id.llNode_O).removeAllViews();
                        util.getView(childView, R.id.vEmp).setVisibility(View.VISIBLE);
                    } else {
                        util.getView(childView, R.id.vEmp).setVisibility(View.GONE);
                    }

                    util.getView(childView, R.id.llRowBody1).setVisibility(View.GONE);
                    util.getView(childView, R.id.llRowBody2).setVisibility(View.VISIBLE);

                    final View vLoding = util.getView(childView, R.id.llLoading1);
                    if ( !sHTTP_request_time.equals("") ) {
                        vLoding.setVisibility(View.VISIBLE);
                    } else {
                        vLoding.setVisibility(View.GONE);
                    }

                    util.getTextView(childView, R.id.tvRowBody2_Title).setText(sHTTP_cmdcls_name);

                    util.getView(childView, R.id.btnRowBody2_Control).setTag(iRow);
                    util.getView(childView, R.id.btnRowBody2_Control).setVisibility(View.GONE);
                    switch (iCmdcls_Type) {
                        //SENSOR_BINARY
                        case Constants.CMDCLS_TYPE_ID_11001:
                        case Constants.CMDCLS_TYPE_ID_11002:
                        case Constants.CMDCLS_TYPE_ID_11003:
                        case Constants.CMDCLS_TYPE_ID_11004:
                        case Constants.CMDCLS_TYPE_ID_11005:
                        case Constants.CMDCLS_TYPE_ID_11006:
                        case Constants.CMDCLS_TYPE_ID_11007:
                        case Constants.CMDCLS_TYPE_ID_11008:
                        case Constants.CMDCLS_TYPE_ID_11009:
                        case Constants.CMDCLS_TYPE_ID_11010:
                        case Constants.CMDCLS_TYPE_ID_11011:
                        case Constants.CMDCLS_TYPE_ID_11012:
                        case Constants.CMDCLS_TYPE_ID_11013:
                        case Constants.CMDCLS_TYPE_ID_11014:
                        case Constants.CMDCLS_TYPE_ID_11015:
                        case Constants.CMDCLS_TYPE_ID_11016:
                        case Constants.CMDCLS_TYPE_ID_11017:
                        case Constants.CMDCLS_TYPE_ID_11018:
                            util.getTextView(childView, R.id.tvRowBody2_Body).setText(sTempValue);

                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-");
                            }
                            break;
                        //SWITCH_BINARY
                        case Constants.CMDCLS_TYPE_ID_17001:
                        case Constants.CMDCLS_TYPE_ID_17002:
                        case Constants.CMDCLS_TYPE_ID_17003:
                        case Constants.CMDCLS_TYPE_ID_17004:
                        case Constants.CMDCLS_TYPE_ID_17005:
                        case Constants.CMDCLS_TYPE_ID_17006:
                            util.getTextView(childView, R.id.tvRowBody2_Body).setText(sTempValue);
                            util.getView(childView, R.id.btnRowBody2_Control).setVisibility(View.VISIBLE);

                            if ( sHTTP_content_value.equals(sSelect) ) {
                                util.getView(childView, R.id.btnRowBody2_Control).setBackgroundResource(R.drawable.img_things_list_btn_onoff_on);
                            } else {
                                util.getView(childView, R.id.btnRowBody2_Control).setBackgroundResource(R.drawable.img_things_list_btn_onoff_off);
                            }

                            util.getView(childView, R.id.btnRowBody2_Control).setOnClickListener(new View.OnClickListener() {
                                int iTag = 0;
                                private Intent intent;
                                String sHTTP_Value = "";

                                @Override public void onClick(View v) {

                                    iTag = (int) v.getTag();
                                    String sHTTP_cmdcls_type_id = util.null2string(alTotalList.get(iTag).get(Constants.HTTP_cmdcls_type_id));
                                    String sHTTP_content_value = util.null2string(alTotalList.get(iTag).get(Constants.HTTP_content_value));
                                    if ( sHTTP_content_value.equals(util.getStringValues(act, "CMDCLS_TYPE_ID_" + sHTTP_cmdcls_type_id + "_BG_DEFAULT")) ) {
                                        sHTTP_Value = "ON";
                                    } else {
                                        sHTTP_Value = "OFF";
                                    }
                                    vLoding.setVisibility(View.VISIBLE);
                                    onCallAction1(iTag, sHTTP_Value);
                                }
                            });
                            break;
                        case Constants.CMDCLS_TYPE_ID_36002:
                            util.getTextView(childView, R.id.tvRowBody2_Body).setText(sTempValue);
                            util.getView(childView, R.id.btnRowBody2_Control).setVisibility(View.VISIBLE);

                            util.getView(childView, R.id.btnRowBody2_Control).setBackgroundResource(R.drawable.img_things_list_btn_lockunlock_lock);
                            util.getView(childView, R.id.btnRowBody2_Control).setOnClickListener(new View.OnClickListener() {
                                int iTag = 0;
                                private Intent intent;

                                String sHTTP_Value = "";
                                @Override public void onClick(View v) {

                                    iTag = (int) v.getTag();
                                    sHTTP_Value = "CLOSE";
                                    vLoding.setVisibility(View.VISIBLE);
                                    onCallAction1(iTag, sHTTP_Value);
                                }
                            });
                            break;

                        // SENSOR_MULTILEVEL
                        case Constants.CMDCLS_TYPE_ID_12001:
                        case Constants.CMDCLS_TYPE_ID_12002:
                        case Constants.CMDCLS_TYPE_ID_12003:
                        case Constants.CMDCLS_TYPE_ID_12004:
                        case Constants.CMDCLS_TYPE_ID_12005:
                        case Constants.CMDCLS_TYPE_ID_12006:
                        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_12018:
                        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_12028:
                        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 ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            break;

                        //METER_CURRENT
                        case Constants.CMDCLS_TYPE_ID_15001:
                        case Constants.CMDCLS_TYPE_ID_15002:
                            if ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            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 ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            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 ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            break;
                        //THERMOSTAT_SETPOINT
                        case Constants.CMDCLS_TYPE_ID_19001:
                            if ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            break;
                        // METER
                        case Constants.CMDCLS_TYPE_ID_29001:
                        case Constants.CMDCLS_TYPE_ID_29002:
                        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 ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            break;
                        //BATTERY
                        case Constants.CMDCLS_TYPE_ID_30001:
                            if ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            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 ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            break;
                        default:
                            if ( sHTTP_content_value.equals("none") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            } else {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText(sHTTP_content_value + sHTTP_unit);
                            }
                            if ( sHTTP_online_state.equals("OFF") || appConfig.getSelect_Homegrp_Homehub_Online_State().equals("OFF") ) {
                                util.getTextView(childView, R.id.tvRowBody2_Body).setText("-" + sHTTP_unit);
                            }
                            break;
                    }
                    util.getLinearLayout(act, R.id.llNode_O).addView(childView);
                }
            }
            callVpReLoad();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        //        vpNode_M.setCurrentItem(iIvPosition);
    }
    @Override public void onListReload() {
        //        ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_MEMBER_DEVICES), 10);
        // do something
    }

    @Override public void onLogout() {
        //        mCallback.onLogout();
    }
    @Override public void onCallAction(int iCallType, int iPosition) {

        if ( iCallType == 0 ) {
        } else if ( iCallType == 1 ) {
        } else if ( iCallType == 2 ) {
        } else if ( iCallType == 3 ) {
            // 실행하기
            sCall_HTTP_request_value = pageAdapter.getHTTP_Value();
            sCall_HTTP_device_id = util.null2string(alTotalList_M.get(iPosition).get(Constants.HTTP_device_id));
            sCall_HTTP_node_id = util.null2string(alTotalList_M.get(iPosition).get(Constants.HTTP_node_id));
            sCall_HTTP_cmdcls_id = util.null2string(alTotalList_M.get(iPosition).get(Constants.HTTP_cmdcls_id));
            String sHTTP_content_value = util.null2string(alTotalList_M.get(iPosition).get(Constants.HTTP_content_value));
            String sHTTP_cmdcls_type_id = util.null2string(alTotalList_M.get(iPosition).get(Constants.HTTP_cmdcls_type_id));
            String sHTTP_cmdcls_code = util.null2string(alTotalList_M.get(iPosition).get(Constants.HTTP_cmdcls_code));
            //            int iCmdcls_Type = util.null2int(alTotalList.get(iPosition).get(Constants.HTTP_cmdcls_type_id));

            util.callBtnGoogleAnalytics(act, "Control_Things", sHTTP_cmdcls_code + "_2depth");

            LogUtil.i(TAG, "Row info : " + alTotalList_M.get(iPosition).toString());
            Dlog.v("sCall_HTTP_request_value", sCall_HTTP_request_value);
            Dlog.v("sHTTP_content_value", sHTTP_content_value);
            Dlog.v("sHTTP_cmdcls_id", sCall_HTTP_cmdcls_id);

            String sTempValue = util.getStringValues(act, "CMDCLS_TYPE_ID_" + sHTTP_cmdcls_type_id + "_" + sCall_HTTP_request_value);

            if ( sCall_HTTP_request_value.equals(sHTTP_content_value) ) {
                util.setShowToast(act, util.getString(act, R.string.MSG899).replaceAll("\\'컨텐츠밸류\\'", sTempValue), Toast.LENGTH_SHORT);
                //                dataAdapter.notifyDataSetChanged();
                callVpReLoad();
                return;
            } else {
                util.setVibrator(100);
            }

            ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_WS_NODE_COMMAND), 10);
        }
    }

    public void onCallAction1(int iPosition, String sValue) {

        // 실행하기
        sCall_HTTP_request_value = sValue;
        sCall_HTTP_device_id = util.null2string(alTotalList.get(iPosition).get(Constants.HTTP_device_id));
        sCall_HTTP_node_id = util.null2string(alTotalList.get(iPosition).get(Constants.HTTP_node_id));
        sCall_HTTP_cmdcls_id = util.null2string(alTotalList.get(iPosition).get(Constants.HTTP_cmdcls_id));
        String sHTTP_content_value = util.null2string(alTotalList.get(iPosition).get(Constants.HTTP_content_value));
        String sHTTP_cmdcls_type_id = util.null2string(alTotalList.get(iPosition).get(Constants.HTTP_cmdcls_type_id));
        String sHTTP_cmdcls_code = util.null2string(alTotalList.get(iPosition).get(Constants.HTTP_cmdcls_code));
        //            int iCmdcls_Type = util.null2int(alTotalList.get(iPosition).get(Constants.HTTP_cmdcls_type_id));

        util.callBtnGoogleAnalytics(act, "Control_Things", sHTTP_cmdcls_code + "_2depth");

        Dlog.v("sCall_HTTP_request_value", sCall_HTTP_request_value);
        Dlog.v("sHTTP_content_value", sHTTP_content_value);
        Dlog.v("sHTTP_cmdcls_id", sCall_HTTP_cmdcls_id);

        String sTempValue = util.getStringValues(act, "CMDCLS_TYPE_ID_" + sHTTP_cmdcls_type_id + "_" + sCall_HTTP_request_value);

        if ( sCall_HTTP_request_value.equals(sHTTP_content_value) ) {
            util.setShowToast(act, util.getString(act, R.string.MSG899).replaceAll("\\'컨텐츠밸류\\'", sTempValue), Toast.LENGTH_SHORT);
            callVpReLoad();
            return;
        } else {
            util.setVibrator(100);
        }

        ComHandler.sendMessageDelayed(ComHandler.obtainMessage(MSG_COM_WS_NODE_COMMAND), 10);
    }

    /**
     * <PRE>
     * 1. MethodName: send_WS_node_command
     * 2. ClassName :
     * 3. Comment   : [Send]서비스 허브에 노드 제어를 요청한다.
     * 4. Developer : 정백호
     * 5. Created   : 2016. 07.
     * </PRE>
     */
    private void send_WS_node_command() {
        HashMap<String, Object> sendParams = new HashMap<>();
        sendParams.put(Constants.WEBSOCKET_KEY_MESSAGE_TYPE, Constants.WEBSOCKET_TYPE_NODE_COMMAND);
        sendParams.put(Constants.WEBSOCKET_KEY_DEVICE_ID, sDEVICE_ID);
        sendParams.put(Constants.WEBSOCKET_KEY_NODE_ID, sNODE_ID);
        sendParams.put(Constants.WEBSOCKET_KEY_COMMAND_TYPE, Constants.WEBSOCKET_COMM_TYPE_CONTROL);
        sendParams.put(Constants.WEBSOCKET_KEY_CMDCLS_ID, sCall_HTTP_cmdcls_id);
        sendParams.put(Constants.WEBSOCKET_KEY_CMDCLS_VALUE, sCall_HTTP_request_value);
        sendParams.put(Constants.WEBSOCKET_KEY_REQUEST_ID, appConfig.getiSelect_Servicehub_Request_Id());

        webSocketService.send(Constants.WEBSOCKET_SEND_NODE_COMMAND, sendParams);
    }

    /**
     * <PRE>
     * 1. MethodName: result_WS_node_command
     * 2. ClassName :
     * 3. Comment   : [Result]서비스 허브에 노드 제어를 요청한다.
     * 4. Developer : 정백호
     * 5. Created   : 2016. 07.
     * </PRE>
     */
    private void result_WS_node_command(JSONObject joResult) throws JSONException {
        String sResultHTTP_device_id = util.null2string(joResult.get(Constants.WEBSOCKET_KEY_DEVICE_ID));
        String sResultHTTP_node_id = util.null2string(joResult.get(Constants.WEBSOCKET_KEY_NODE_ID));
        String sResultHTTP_request_time = util.null2string(joResult.get(Constants.WEBSOCKET_KEY_REQUEST_TIME));
        for ( int iRow = 0; iRow < alTotalList.size(); iRow++ ) {

            String sHTTP_device_id = util.null2string(alTotalList.get(iRow).get(Constants.HTTP_device_id));
            String sHTTP_node_id = util.null2string(alTotalList.get(iRow).get(Constants.HTTP_node_id));
            if ( sResultHTTP_device_id.equals(sHTTP_device_id) && sResultHTTP_node_id.equals(sHTTP_node_id) ) {
                alTotalList.get(iRow).put(Constants.HTTP_request_time, sResultHTTP_request_time);

                Dlog.v("Things jino0 =" + sResultHTTP_request_time);
                break;
            }
        }
        setHomeHubStateList();
    }

    /**
     * <PRE>
     * 1. MethodName: notification_WS_node_content
     * 2. ClassName :
     * 3. Comment   : [notification]서비스 허브에서 노드 컨텐트 정보를 받는다.
     * 4. Developer : 정백호
     * 5. Created   : 2016. 07.
     * </PRE>
     */
    private void notification_WS_node_content(JSONObject joResult) throws JSONException {
        LogUtil.i(TAG, "notification_WS_node_content!!");
        String sTempHTTP_device_id1 = util.null2string(joResult.get(Constants.WEBSOCKET_KEY_DEVICE_ID));
        String sTempHTTP_node_id1 = util.null2string(joResult.get(Constants.WEBSOCKET_KEY_NODE_ID));
        String sTempHTTP_collect_time1 = util.null2string(joResult.get(Constants.WEBSOCKET_KEY_COLLECT_TIME));
        HashMap<String, Object> hmContentValue = util.jsonToMap(joResult.get(Constants.WEBSOCKET_KEY_CONTENT_VALUE));
        String sTempHTTP_online_state1 = util.null2string(hmContentValue.get(Constants.WEBSOCKET_KEY_ONLINE));

        for ( int iRow1 = 0; iRow1 < alTotalList.size(); iRow1++ ) {
            String sTempHTTP_device_id2 = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_device_id));
            String sTempHTTP_node_id2 = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_node_id));
            String sTempHTTP_request_time2 = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_request_time));
            String sContentValue = util.null2string(hmContentValue.get(alTotalList.get(iRow1).get(Constants.HTTP_cmdcls_id)));
            if ( sTempHTTP_device_id1.equals(sTempHTTP_device_id2) && sTempHTTP_node_id1.equals(sTempHTTP_node_id2) ) {
                alTotalList.get(iRow1).put(Constants.HTTP_content_value, sContentValue);
                alTotalList.get(iRow1).put(Constants.HTTP_collect_time, sTempHTTP_collect_time1);
                alTotalList.get(iRow1).put(Constants.HTTP_online_state, sTempHTTP_online_state1);
                LogUtil.i(TAG, "alTotalList : " + alTotalList.toString());
                if ( !sTempHTTP_request_time2.equals("") ) {
                    if ( !sTempHTTP_collect_time1.equals("") ) {
                        if ( util.str2long(util.UTCtoLocal4(sTempHTTP_collect_time1.replaceAll("Z", ""))) > util.str2long(util.UTCtoLocal4(sTempHTTP_request_time2.replaceAll(
                                "Z", ""))) ) {
                            iThingsAction = 0;
                            alTotalList.get(iRow1).put(Constants.HTTP_request_time, "");
                            Dlog.v("Things jino1");
                        }
                    }
                }
                break;
            }
        }
        for ( int iRow1 = 0; iRow1 < alTotalList.size(); iRow1++ ) {
            String sHTTP_request_time = util.null2string(alTotalList.get(iRow1).get(Constants.HTTP_request_time));
            if ( !sHTTP_request_time.equals("") ) {
                Dlog.v("Things jino5");
                Dlog.v("Things jino5 sHTTP_request_time=" + sHTTP_request_time);
                Dlog.v("Things jino5 util.getRealTime1()=" + util.getRealTime1());
                Dlog.v("Things jino5 10초후=" + util.stringDateAddTime(util.UTCtoLocal4(sHTTP_request_time.replaceAll("Z", "")), 10000));
                if ( util.str2long(util.getRealTime1()) > util.str2long(util.stringDateAddTime(util.UTCtoLocal4(sHTTP_request_time.replaceAll("Z", "")), 10000)) ) {
                    iThingsAction++;
                    alTotalList.get(iRow1).put(Constants.HTTP_request_time, "");
                }
            }
        }
        if ( iThingsAction == 3 ) {
            util.setShowToast(act, util.getString(act, R.string.MSG867), Toast.LENGTH_SHORT);
        }
        setNode_Disp();
        setHomeHubStateList();
    }
}