/** * 复制路线 * * @param route 路线 * @param listener 回调 */ public void copyRoute(final Route route, final OnRouteListener listener) { final Route myRoute = new Route(); myRoute.setCreator(UserManager.getInstance(mContext).getUser()); myRoute.setName(route.getName()); myRoute.setDescription(route.getDescription()); myRoute.setStatus(Route.PLANNING); myRoute.setDays(route.getDays()); myRoute.save( mContext, new SaveListener() { @Override public void onSuccess() { UserManager.getInstance(mContext) .addRoute( new UserManager.OnUpdateListener() { @Override public void onSuccess() {} @Override public void onError() {} }); BmobQuery<Daily> query = new BmobQuery<>(); query.addWhereEqualTo("route", new BmobPointer(route)); query.order("day"); query.findObjects( mContext, new FindListener<Daily>() { @Override public void onSuccess(List<Daily> list) { copyDaily(myRoute, list, listener); } @Override public void onError(int i, String s) { listener.onError(s); } }); } @Override public void onFailure(int i, String s) { listener.onError(s); } }); }
/** * 增加天数 * * @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); } }); }