Ejemplo n.º 1
0
  public void initializeMainWork() {
    mContext = getApplicationContext();
    // StricMode Thread Policy setting
    StrictMode.setThreadPolicy(
        new StrictMode.ThreadPolicy.Builder()
            .permitDiskReads()
            .permitDiskWrites()
            .permitNetwork()
            .build());
    select_icon = (Button) findViewById(R.id.select_icon);
    select_icon.setOnClickListener(this);

    mAddress = new MyAddress();
    mAddress.getAddressFromText();
    if (!mAddress.getIP().equals("")
        && !mAddress.getPORTDATA().equals("")
        && !mAddress.getPORTVIDEO().equals("")) {
      SIP = mAddress.getIP();
      DATA_SPORT = mAddress.getPORTDATA();
      VIDEO_SPORT = mAddress.getPORTVIDEO();
      editText3.setText(SIP);
      editText4.setText(DATA_SPORT);
      editText5.setText(VIDEO_SPORT);
      CONNECTION_READY = true;
    }

    mUser = new MyUser();

    img_lock = (ImageView) findViewById(R.id.image_lock);
    img_unlock = (ImageView) findViewById(R.id.image_unlock);
    img_lock.setOnClickListener(this);
    img_unlock.setOnClickListener(this);
  }
Ejemplo n.º 2
0
  @Override
  public void onTabChanged(String tabId) {
    // TODO Auto-generated method stub
    if (tabId.equals("tab1")) {
      mAb.setTitle("문지기 | 메인");
      if (CONNECTION_SERVER) {
        dataID = String.valueOf(Constants.MSG_CHECK);
        data = "0";
        dataLen = mSocket.makeDataLenToByte(data.length());
        mSocket.sendMessage(dataID.getBytes(), dataLen, data.getBytes());
      }
      onTabUnselected(2);
      onTabUnselected(3);
      onTabUnselected(4);
      onTabUnselected(5);

    } else if (tabId.equals("tab2")) {
      mAb.setTitle("문지기 | 로그");
      if (CONNECTION_SERVER) {
        // Request Log Record to Server
        log.clear();
        dataID = String.valueOf(Constants.MSG_SHOWLOG);
        data = "0";
        dataLen = mSocket.makeDataLenToByte(data.length());
        mSocket.sendMessage(dataID.getBytes(), dataLen, data.getBytes());
      } else {
        setToast("기록을 불러올 수 없습니다. 서버와 연결 후 다시 시도해 주세요.");
      }

      mUserList = new ArrayList<MyItem>();
      mMyAdapter = new MyListAdapter(mContext, R.layout.logtab_listview, mUserList);
      listView.setAdapter(mMyAdapter);
      mMyAdapter.notifyDataSetChanged();

      onTabUnselected(1);
      onTabUnselected(3);
      onTabUnselected(4);
      onTabUnselected(5);

    } else if (tabId.equals("tab3")) {
      mAb.setTitle("문지기 | 영상");

      onTabUnselected(1);
      onTabUnselected(2);
      onTabUnselected(4);
      onTabUnselected(5);

    } else if (tabId.equals("tab4")) {
      mAb.setTitle("문지기 | 캡쳐");

      onTabUnselected(1);
      onTabUnselected(2);
      onTabUnselected(3);
      onTabUnselected(5);

    } else if (tabId.equals("tab5")) {
      mAb.setTitle("문지기 | 설정");
      NFC_SETTING = true;
      if (mAddress.getIP().equals("")
          || mAddress.getPORTDATA().equals("")
          || mAddress.getPORTVIDEO().equals("")) {
        CONNECTION_READY = false;
      }
      if (CONNECTION_USER) button1.setBackgroundResource(R.drawable.selector_green);
      else button1.setBackgroundResource(R.drawable.selector_red);
      if (CONNECTION_SERVER) button2.setBackgroundResource(R.drawable.selector_green);
      else button2.setBackgroundResource(R.drawable.selector_red);

      onTabUnselected(1);
      onTabUnselected(2);
      onTabUnselected(3);
      onTabUnselected(4);
    }
  }