コード例 #1
0
 private int getStateTxtDrawable(CameraInfo info) {
   if (info.getPwdIsRight()) {
     return info.getIsOnline() ? R.string.online : R.string.offline;
   } else {
     return R.string.pwd_wrong;
   }
 }
コード例 #2
0
 private int getStateDrawable(CameraInfo info) {
   if (info.getPwdIsRight()) {
     return info.getIsOnline() ? R.drawable.avs_status_connected : R.drawable.avs_status_unknow;
   } else {
     return R.drawable.avs_status_pwderror;
   }
 }
コード例 #3
0
 // 添加采集端
 public void addStreamer(long streamerCid, String user, String pass) {
   boolean ret = mViewer.connectStreamer(streamerCid, user, pass);
   CameraInfo info = mMyViewerHelper.getCameraInfo(streamerCid);
   if (ret) {
     if (null == info) {
       StreamerInfo sinfo = mViewer.getStreamerInfoMgr().getStreamerInfo(streamerCid);
       info = new CameraInfo();
       info.setCid(streamerCid);
       String name = sinfo.getDeviceName();
       info.setCameraName((null == name) ? "" : name);
       info.setCameraUser(user);
       info.setCameraPwd(pass);
       info.setCameraThumb(mCameraDefaulThumb);
       info.setIsOnline(false);
       info.setPwdIsRight(true);
       info.setOS(sinfo.getOsVersion());
       mCameraInfoManager.addCameraInfo(info);
       mMyViewerHelper.addCameraInfo(info);
       mCameraListAdapter.notifyDataSetChanged();
     }
   } else {
     if (null != info) {
       info.setPwdIsRight(false);
       mCameraListAdapter.notifyDataSetChanged();
     }
   }
 }
コード例 #4
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   for (CameraInfo info : mCameraInfos) {
     removeStreamer(info.getCid());
   }
   mMyViewerHelper.removeCameraStateListener(this);
   mMyViewerHelper.logout();
   android.os.Process.killProcess(android.os.Process.myPid());
 }
コード例 #5
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   CameraInfo cameraInfo = mCameraInfos.get(position);
   if (cameraInfo.getIsOnline()) {
     Intent intent = new Intent(this, WatchActivity.class);
     intent.putExtra(Constants.INTENT_CID, cameraInfo.getCid());
     intent.putExtra(Constants.INTENT_CAMERA_NAME, cameraInfo.getCameraName());
     startActivity(intent);
   } else {
     Toast.makeText(this, R.string.camera_offline, Toast.LENGTH_LONG).show();
   }
 }
コード例 #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.camera_list);
    mLayoutInflater = LayoutInflater.from(this);
    mCameraListView = (ListView) findViewById(R.id.cameraList);
    TextView titleView = (TextView) findViewById(R.id.title);
    titleView.setText(R.string.app_name);
    mMenuView = (ImageView) findViewById(R.id.menu);
    mMenuView.setVisibility(View.VISIBLE);
    mMenuView.setOnClickListener(this);
    mMenu = new PopupMenu(this, mMenuView);
    MenuInflater inflater = mMenu.getMenuInflater();
    inflater.inflate(R.menu.popup_menu, mMenu.getMenu());
    mMenu.setOnMenuItemClickListener(this);

    mViewer = Viewer.getViewer();
    mMyViewerHelper = MyViewerHelper.getInstance(getApplicationContext());
    mMyViewerHelper.addCameraStateListener(this);
    mCameraDefaulThumb = BitmapFactory.decodeResource(getResources(), R.drawable.avs_type_android);

    mCameraInfoManager = new CameraInfoManager(this);
    mCameraInfos = mMyViewerHelper.getAllCameraInfos();
    for (CameraInfo info : mCameraInfos) {
      addStreamer(info.getCid(), info.getCameraUser(), info.getCameraPwd());
    }
    mCameraListAdapter = new CameraListAdapter(this, mCameraInfos);
    mCameraListView.setAdapter(mCameraListAdapter);
    mCameraListView.setOnItemClickListener(this);

    mShowChinese = "zh".equals(Locale.getDefault().getLanguage().toLowerCase());

    // update
    UmengUpdateAgent.setUpdateOnlyWifi(false);
    UmengUpdateAgent.update(this);

    // admob ad
    RelativeLayout adContainer = (RelativeLayout) findViewById(R.id.adLayout);
    AdView ad = new AdView(this, AdSize.BANNER, AD_UNIT_ID);
    // .addTestDevice("703C305FC29B7ED91BD7625874CFDEBC")
    ad.loadAd(new AdRequest());
    adContainer.addView(ad);
  }
コード例 #7
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = null;
      if (null == convertView) {
        view = mLayoutInflater.inflate(R.layout.camera_list_item, null);
      } else {
        view = convertView;
      }

      ImageView thumbView = (ImageView) view.findViewById(R.id.thumb);
      TextView cameraName = (TextView) view.findViewById(R.id.cameraName);
      ImageView cameraStateView = (ImageView) view.findViewById(R.id.cameraState);
      TextView cameraStateTxtView = (TextView) view.findViewById(R.id.cameraStateTxt);
      ImageView editView = (ImageView) view.findViewById(R.id.edit);
      ImageView deleteView = (ImageView) view.findViewById(R.id.delete);
      final CameraInfo info = mCameraInfos.get(position);
      thumbView.setImageBitmap(info.getCameraThumb());
      cameraName.setText(info.getCameraName());
      cameraStateView.setImageResource(getStateDrawable(info));
      cameraStateTxtView.setText(getStateTxtDrawable(info));
      editView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              if (info.getIsOnline()) {
                Intent intent = new Intent();
                intent.setClass(getApplicationContext(), CameraInfoSettingActivity.class);
                intent.putExtra(Constants.INTENT_CID, info.getCid());
                startActivity(intent);
              } else {
                Toast.makeText(CameraListActivity.this, R.string.camera_offline, Toast.LENGTH_LONG)
                    .show();
              }
            }
          });
      deleteView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              new AlertDialog.Builder(CameraListActivity.this)
                  .setTitle(R.string.delete_camera_dlg_title)
                  .setPositiveButton(
                      R.string.confirm,
                      new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                          removeStreamer(info.getCid());
                          mCameraInfoManager.delete(info);
                          mMyViewerHelper.removeCameraInfo(info);
                          mCameraListAdapter.notifyDataSetChanged();
                        }
                      })
                  .setNegativeButton(
                      R.string.cancel,
                      new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                          dialog.dismiss();
                        }
                      })
                  .create()
                  .show();
            }
          });
      return view;
    }