Esempio n. 1
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();
   }
 }
Esempio n. 2
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;
    }