// 添加采集端 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(); } } }
@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); }
// 删除采集端 public void removeStreamer(long streamerCid) { mViewer.disconnectStreamer(streamerCid); }