Exemplo n.º 1
0
  /**
   * @Title: updateUserLocation @Description: 更新经纬度
   *
   * @param
   * @return void
   * @throws
   */
  public void updateUserLocation() {
    String newLat = mApplication.getLatitude();
    String newLong = mApplication.getLongtitude();
    if (TextUtils.isEmpty(newLat) && TextUtils.isEmpty(newLong)) return;
    // 是否存在数据
    if (!DBHelper.getInstance(mContext).isUsersInfoSaved(mApplication.getUsername())) {
      return;
    }
    // 获取当前用户名
    final CamelUser mCamelUser =
        DBHelper.getInstance(getApplicationContext())
            .getCurrentUsers(mApplication.getUsername())
            .get(0);
    String saveLatitude = mCamelUser.getUserLatitude();
    String saveLongtitude = mCamelUser.getUserLongitude();
    if (!saveLatitude.equals(newLat)
        || !saveLongtitude.equals(newLong)) { // 只有位置有变化就更新当前位置,达到实时更新的目的
      mCamelUser.setUserLatitude(newLat); // 设置纬度
      mCamelUser.setUserLongitude(newLong); // 设置经度

      if (DBHelper.getInstance(mContext).isUsersInfoSaved(mCamelUser.getUserAccount())) {
        Log.e("latlon", "更新经纬度成功");
        DBHelper.getInstance(mContext).updateToUsersInfoTable(mCamelUser);
      }
    }
  }
Exemplo n.º 2
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
   super.onCreate(savedInstanceState);
   mContext = this;
   mSocketInit = SocketInit.getInstance();
   mApplication = CustomApplcation.getInstance();
   mLoadingDialog = new FlippingLoadingDialog(this, "请求提交中");
   agent = new FeedbackAgent(mContext);
 }
Exemplo n.º 3
0
  /**
   * @Title: updateDeviceNewestMessage @Description: 更新当前设备最新数据
   *
   * @param
   * @return void 4A
   * @throws
   */
  public void updateDeviceNewestMessage() {
    if (CustomApplcation.getInstance().getCurrentCamelDevice() == null) {
      return;
    }
    SocketInit.getInstance()
        .queryCurrentNewestMessage(
            new FindNewMessageListener() {
              @Override
              public void onSuccess() {}

              @Override
              public void onFailure(int paramInt, String paramString) {
                Log.e("updateFamilyMember", paramString);
              }
            });
  }
Exemplo n.º 4
0
  /**
   * @Title: updateMessageData @Description: 获取历史数据
   *
   * @param
   * @return void 3E
   * @throws
   */
  @SuppressLint("SimpleDateFormat")
  public void updateMessageData() {
    if (CustomApplcation.getInstance().getCurrentCamelDevice() == null) {
      return;
    }
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date curDate = new Date(System.currentTimeMillis()); // 获取当前时间
    String time = formatter.format(curDate);
    SocketInit.getInstance()
        .queryCurrentDeviceState(
            Config.HISTORY_PAGE,
            time,
            new FindStateListener() {

              @Override
              public void onSuccess() {
                try {
                  runOnUiThread(
                      new Runnable() {
                        public void run() {
                          new Handler()
                              .postDelayed(
                                  new Runnable() {
                                    public void run() {
                                      Config.HISTORY_PAGE++;
                                      updateMessageData();
                                    }
                                  },
                                  2000);
                        }
                      });
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }

              @Override
              public void onFailure(int paramInt, String paramString) {}
            });
  }