Exemplo n.º 1
0
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       if (!NetStateUtils.checkSdCard()) {
         ShowToast("发送语音需要sdcard支持!");
         return false;
       }
       try {
         v.setPressed(true);
         layout_record.setVisibility(View.VISIBLE);
         tv_voice_tips.setText(getString(R.string.chat_voice_cancel_tips));
         // 开始录音
         recordManager.startRecording(targetId);
       } catch (Exception e) {
       }
       return true;
     case MotionEvent.ACTION_MOVE:
       {
         if (event.getY() < 0) {
           tv_voice_tips.setText(getString(R.string.chat_voice_cancel_tips));
           tv_voice_tips.setTextColor(Color.RED);
         } else {
           tv_voice_tips.setText(getString(R.string.chat_voice_up_tips));
           tv_voice_tips.setTextColor(Color.WHITE);
         }
         return true;
       }
     case MotionEvent.ACTION_UP:
       v.setPressed(false);
       layout_record.setVisibility(View.INVISIBLE);
       try {
         if (event.getY() < 0) { // 放弃录音
           recordManager.cancelRecording();
           BmobLog.i("voice", "放弃发送语音");
         } else {
           int recordTime = recordManager.stopRecording();
           if (recordTime > 1) {
             // 发送语音文件
             BmobLog.i("voice", "发送语音");
             sendVoiceMessage(recordManager.getRecordFilePath(targetId), recordTime);
           } else { // 录音时间过短,则提示录音过短的提示
             layout_record.setVisibility(View.GONE);
             showShortToast().show();
           }
         }
       } catch (Exception e) {
       }
       return true;
     default:
       return false;
   }
 }
Exemplo n.º 2
0
    @Override
    public void onReceiveLocation(BDLocation location) {
      // map view 销毁后不在处理新接收的位置
      if (location == null || mMapView == null) return;

      if (lastLocation != null) {
        if (lastLocation.getLatitude() == location.getLatitude()
            && lastLocation.getLongitude() == location.getLongitude()) {
          BmobLog.i("获取坐标相同"); // 若两次请求获取到的地理位置坐标是相同的,则不再定位
          mLocClient.stop();
          return;
        }
      }
      lastLocation = location;
      // TODO 测试上传位置!
      CustomApplication.getInstance().mLastLocation =
          new BmobGeoPoint(location.getLongitude(), location.getLatitude());
      updateUserLocation();

      BmobLog.i(
          "lontitude = "
              + location.getLongitude()
              + ",latitude = "
              + location.getLatitude()
              + ",地址 = "
              + lastLocation.getAddrStr());

      //			MyLocationData locData = new MyLocationData.Builder()
      //					.accuracy(location.getRadius())
      //					// 此处设置开发者获取到的方向信息,顺时针0-360
      //					.direction(100).latitude(location.getLatitude())
      //					.longitude(location.getLongitude()).build();
      //			mBaiduMap.setMyLocationData(locData);
      //			LatLng ll = new LatLng(location.getLatitude(),
      //					location.getLongitude());
      //			String address = location.getAddrStr();
      //			if (address != null && !address.equals("")) {
      //				lastLocation.setAddrStr(address);
      //			} else {
      //				// 反Geo搜索
      //				mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(ll));
      //			}
      // TODO 显示在地图上
      //			MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
      //			mBaiduMap.animateMapStatus(u);
      // 设置按钮可点击
      mHeadLayout.getRightImageButton().setEnabled(true);
    }
Exemplo n.º 3
0
 @Override
 public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
   if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
     showToast("抱歉,未能找到结果");
     return;
   }
   BmobLog.i("反编码得到的地址:" + result.getAddress());
   lastLocation.setAddrStr(result.getAddress());
 }
Exemplo n.º 4
0
 public void showLog(String msg) {
   BmobLog.i(msg);
 }
Exemplo n.º 5
0
 public static void ShowLog(String msg) {
   BmobLog.i(msg);
 }