Fix duty hours

This commit is contained in:
Mieszko Wrzeszczyński 2018-12-16 22:45:44 +01:00
parent e7a2ecf86a
commit 9d82261be9
4 changed files with 8 additions and 23 deletions

View File

@ -23,6 +23,7 @@ public class StartupActivity extends AppCompatActivity {
if (PrefUtils.isLoggedIn(getApplicationContext())){ if (PrefUtils.isLoggedIn(getApplicationContext())){
Intent startupIntent = new Intent(this, MapActivity.class); Intent startupIntent = new Intent(this, MapActivity.class);
PrefUtils.storeLocale(getApplicationContext(),PrefUtils.getLocale(getApplicationContext()));
startupIntent.putExtra(currentLang, PrefUtils.getLocale(getApplicationContext())); startupIntent.putExtra(currentLang, PrefUtils.getLocale(getApplicationContext()));
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(startupIntent); startActivity(startupIntent);

View File

@ -95,7 +95,7 @@ public class DutyHourViewModel {
} }
public String getSummary() { public String getSummary() {
return this.getDay() + " " + this.getStart() + " " + this.getEnd(); return this.getDay() + ": " + this.getStart() + " - " + this.getEnd();
} }

View File

@ -1,25 +1,18 @@
package com.uam.wmi.findmytutor.utils; package com.uam.wmi.findmytutor.utils;
import android.support.annotation.NonNull;
import com.google.gson.GsonBuilder;
import com.mapbox.geojson.BoundingBox;
import com.mapbox.geojson.Feature; import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection; import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.Geometry;
import com.mapbox.geojson.Point; import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon; import com.mapbox.geojson.Polygon;
import com.mapbox.geojson.gson.BoundingBoxDeserializer; import com.mapbox.turf.TurfClassification;
import com.mapbox.geojson.gson.GeoJsonAdapterFactory;
import com.mapbox.geojson.gson.GeometryDeserializer;
import com.mapbox.geojson.gson.PointDeserializer;
import com.mapbox.turf.TurfJoins; import com.mapbox.turf.TurfJoins;
import com.mapbox.turf.TurfMeasurement;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
; ;import static com.mapbox.geojson.FeatureCollection.fromJson;
public class ApproximatedLocalization { public class ApproximatedLocalization {
private FeatureCollection buildingSchema = null; private FeatureCollection buildingSchema = null;
@ -28,17 +21,6 @@ public class ApproximatedLocalization {
buildingSchema = fromJson(buildingObject); buildingSchema = fromJson(buildingObject);
} }
private FeatureCollection fromJson(@NonNull String json) {
GsonBuilder gson = new GsonBuilder();
gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create());
gson.registerTypeAdapter(Point.class, new PointDeserializer());
gson.registerTypeAdapter(Geometry.class, new GeometryDeserializer());
gson.registerTypeAdapter(BoundingBox.class, new BoundingBoxDeserializer());
return gson.create().fromJson(json, FeatureCollection.class);
}
public String getNameOfBuildingPart(Point point) { public String getNameOfBuildingPart(Point point) {
for (Feature feature : Objects.requireNonNull(buildingSchema.features())) { for (Feature feature : Objects.requireNonNull(buildingSchema.features())) {
@ -56,7 +38,9 @@ public class ApproximatedLocalization {
for (Feature feature : Objects.requireNonNull(buildingSchema.features())) { for (Feature feature : Objects.requireNonNull(buildingSchema.features())) {
String partName = feature.getStringProperty("name"); String partName = feature.getStringProperty("name");
if (buildingPart != null && buildingPart.equals(partName)) { if (buildingPart != null && buildingPart.equals(partName)) {
Double longitude = feature.getNumberProperty("longitude").doubleValue(); Double longitude = feature.getNumberProperty("longitude").doubleValue();
Double latitude = feature.getNumberProperty("latitude").doubleValue(); Double latitude = feature.getNumberProperty("latitude").doubleValue();