Exemplo n.º 1
0
  /**
   * 添加评论
   *
   * @param route 路线
   * @param listener 回调
   */
  public void addComment(final Route route, final OnRouteListener listener) {
    int commentNum = 0;
    if (route.getCommentNum() != null) {
      commentNum = route.getCommentNum();
    }
    commentNum++;
    route.setCommentNum(commentNum);
    route.update(
        mContext,
        route.getObjectId(),
        new UpdateListener() {
          @Override
          public void onSuccess() {
            UserManager.getInstance(mContext)
                .addComment(
                    route,
                    new UserManager.OnUpdateListener() {
                      @Override
                      public void onSuccess() {
                        listener.onSuccess(null);
                      }

                      @Override
                      public void onError() {
                        listener.onError(null);
                      }
                    });
          }

          @Override
          public void onFailure(int i, String s) {
            listener.onError(s);
          }
        });
  }
Exemplo n.º 2
0
  /**
   * 取消路线
   *
   * @param route 路线
   * @param listener 回调
   */
  public void cancelRoute(Route route, final OnRouteListener listener) {
    route.update(
        mContext,
        route.getObjectId(),
        new UpdateListener() {
          @Override
          public void onSuccess() {
            UserManager.getInstance(mContext)
                .setStartRoute(
                    false,
                    new UserManager.OnUpdateListener() {
                      @Override
                      public void onSuccess() {
                        listener.onSuccess(null);
                      }

                      @Override
                      public void onError() {
                        listener.onError(null);
                      }
                    });
          }

          @Override
          public void onFailure(int i, String s) {
            listener.onError(s);
          }
        });
  }
Exemplo n.º 3
0
  /**
   * 增加天数
   *
   * @param route 路线
   * @param listener 回调
   */
  public void addDay(Route route, final OnRouteListener listener) {
    Route r = new Route();
    r.setDays(route.getDays());
    r.update(
        mContext,
        route.getObjectId(),
        new UpdateListener() {
          @Override
          public void onSuccess() {
            listener.onSuccess(null);
          }

          @Override
          public void onFailure(int i, String s) {
            listener.onError(null);
          }
        });
  }
Exemplo n.º 4
0
  /**
   * 查看路线
   *
   * @param route 路线
   * @param listener 回调
   */
  public void watch(Route route, final OnRouteListener listener) {
    int watchNum = 0;
    if (route.getWatchNum() != null) {
      watchNum = route.getWatchNum().intValue();
    }
    watchNum++;
    route.setWatchNum(watchNum);
    route.update(
        mContext,
        new UpdateListener() {
          @Override
          public void onSuccess() {
            listener.onSuccess(null);
          }

          @Override
          public void onFailure(int i, String s) {
            listener.onError(s);
          }
        });
  }
Exemplo n.º 5
0
  /**
   * 路线点赞
   *
   * @param route 路线
   * @param listener 回调
   */
  public void good(Route route, final OnRouteListener listener) {
    int favor = 0;
    if (route.getFavor() != null) {
      favor = route.getFavor().intValue();
    }
    favor++;
    route.setFavor(favor);
    route.update(
        mContext,
        route.getObjectId(),
        new UpdateListener() {
          @Override
          public void onSuccess() {
            listener.onSuccess(null);
          }

          @Override
          public void onFailure(int i, String s) {
            listener.onError(s);
          }
        });
  }