Пример #1
0
  @Override
  public void UploadPicTure(Uri uri) {
    mMainView.showProgress("上传中...");
    try {
      AVFile file =
          AVFile.withFile(mPreferenceManager.getCurrentUserId(), new File(new URI(uri.toString())));
      mRxLeanCloud
          .UploadPicture(file)
          .flatMap(
              new Func1<String, Observable<AVUser>>() {
                @Override
                public Observable<AVUser> call(String s) {
                  User user = User.getCurrentUser(User.class);
                  user.setBackground(s);
                  return mRxLeanCloud.SaveUserByLeanCloud(user);
                }
              })
          .observeOn(AndroidSchedulers.mainThread())
          .subscribe(
              new Observer<AVUser>() {
                @Override
                public void onCompleted() {
                  mMainView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                  mMainView.hideProgress();
                  com.orhanobut.logger.Logger.e(e.getMessage());
                }

                @Override
                public void onNext(AVUser user) {
                  mMainView.showToast("保存成功");
                }
              });
    } catch (FileNotFoundException | URISyntaxException e) {
      e.printStackTrace();
    }
  }
Пример #2
0
 @Override
 public boolean isHavedLover() {
   return !TextUtils.isEmpty(mPreferenceManager.GetLoverID());
 }