Add put for cord

This commit is contained in:
Mieszko Wrzeszczyński 2018-12-10 00:00:04 +01:00
parent 385df14b2f
commit 4c2f706422
4 changed files with 19 additions and 29 deletions

View File

@ -20,9 +20,6 @@ public class Coordinate extends BaseResponse {
private Range<Double> longtitudeRange = Const.buildingLongitudeRange;
private List<String> allowedApproximatedLocations = Const.validApproximatedLocations;
@SerializedName("coordinateId")
private UUID coordinateId = null;
@SerializedName("latitude")
private Double latitude;
@ -66,23 +63,9 @@ public class Coordinate extends BaseResponse {
}
public Coordinate coordinateId(UUID coordinateId) {
this.coordinateId = coordinateId;
return this;
}
/**
* Get coordinateId
* @return coordinateId
**/
@ApiModelProperty(required = true, value = "")
public UUID getCoordinateId() {
return coordinateId;
}
public void setCoordinateId(UUID coordinateId) {
this.coordinateId = coordinateId;
}
public Coordinate latitude(Double latitude) {
this.latitude = latitude;
return this;
@ -236,8 +219,7 @@ public class Coordinate extends BaseResponse {
return false;
}
Coordinate coordinate = (Coordinate) o;
return Objects.equals(this.coordinateId, coordinate.coordinateId) &&
Objects.equals(this.latitude, coordinate.latitude) &&
return Objects.equals(this.latitude, coordinate.latitude) &&
Objects.equals(this.longitude, coordinate.longitude) &&
Objects.equals(this.altitude, coordinate.altitude) &&
Objects.equals(this.userId, coordinate.userId) &&
@ -249,7 +231,7 @@ public class Coordinate extends BaseResponse {
@Override
public int hashCode() {
return Objects.hash(coordinateId, latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label);
return Objects.hash( latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label);
}
@ -258,7 +240,6 @@ public class Coordinate extends BaseResponse {
StringBuilder sb = new StringBuilder();
sb.append("class Coordinate {\n");
sb.append(" coordinateId: ").append(toIndentedString(coordinateId)).append("\n");
sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n");
sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n");
sb.append(" altitude: ").append(toIndentedString(altitude)).append("\n");

View File

@ -26,7 +26,7 @@ public class ApiClient {
private static Retrofit retrofit = null;
private static int REQUEST_TIMEOUT = 60;
private static OkHttpClient okHttpClient;
private static final String BASE_URL = "https://s416084.projektstudencki.pl/master/";
private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/";
public static Retrofit getClient(Context context) {

View File

@ -25,6 +25,7 @@ import android.util.Log;
import com.annimon.stream.Stream;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.uam.wmi.findmytutor.model.Coordinate;
@ -32,6 +33,7 @@ import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.utils.ApproximatedLocalization;
import com.uam.wmi.findmytutor.utils.MapUtils;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.SharingLevel;
import org.apache.commons.collections4.queue.CircularFifoQueue;
@ -42,8 +44,10 @@ import java.util.concurrent.atomic.AtomicReference;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableCompletableObserver;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static com.uam.wmi.findmytutor.utils.Const.offlineBackgroundLocationInterval;
import static com.uam.wmi.findmytutor.utils.Const.onlineBackgroundLocationInterval;
@ -51,6 +55,7 @@ import static com.uam.wmi.findmytutor.utils.Const.presenceApproximatedName;
import static com.uam.wmi.findmytutor.utils.Const.presenceLatitude;
import static com.uam.wmi.findmytutor.utils.Const.presenceLongitude;
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
import static java.lang.String.valueOf;
public class BackgroundLocalizationService extends Service {
@ -353,18 +358,21 @@ public class BackgroundLocalizationService extends Service {
disposable.add(
coordinateService
.postCoordinate(coordinate)
.putCoordinate(coordinate, PrefUtils.getUserId(getApplicationContext()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<Coordinate>() {
.subscribeWith(new DisposableCompletableObserver() {
@Override
public void onSuccess(Coordinate coordinate) {
Log.e(TAG, String.valueOf(coordinate));
public void onComplete() {
Log.e(TAG, "CoordinateSuccess");
}
@Override
public void onError(Throwable e) {
Log.e(TAG, e.getMessage());
Log.e(TAG,"onErr" + valueOf(e));
}
}));
} catch (IllegalArgumentException e) {

View File

@ -3,6 +3,7 @@ package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.Coordinate;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Single;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
@ -36,9 +37,9 @@ public interface CoordinateService {
Single <Coordinate> postCoordinate(@Body Coordinate coordinate);
@PUT("api/coordinates/{id}")
Single<Coordinate> putCoordinatesById(@Path("id") String id);
Completable putCoordinate(@Body Coordinate coordinate, @Path("id") String id);
@DELETE("api/coordinates/{id}")
Single<Coordinate> deleteCoordinatesById(@Path("id") String id);
Completable deleteCoordinatesById(@Path("id") String id);
}