mirror of https://github.com/tasks/tasks
One geofence per place
parent
2d79e2e571
commit
0bdf9c8d6f
@ -0,0 +1,31 @@
|
||||
package org.tasks.makers
|
||||
|
||||
import com.natpryce.makeiteasy.Instantiator
|
||||
import com.natpryce.makeiteasy.Property
|
||||
import com.natpryce.makeiteasy.PropertyLookup
|
||||
import com.natpryce.makeiteasy.PropertyValue
|
||||
import com.todoroo.astrid.helper.UUIDHelper
|
||||
import org.tasks.data.Geofence
|
||||
import org.tasks.data.Place
|
||||
|
||||
object GeofenceMaker {
|
||||
val PLACE: Property<Geofence, String> = Property.newProperty()
|
||||
val TASK: Property<Geofence, Long> = Property.newProperty()
|
||||
val ARRIVAL: Property<Geofence, Boolean> = Property.newProperty()
|
||||
val DEPARTURE: Property<Geofence, Boolean> = Property.newProperty()
|
||||
val RADIUS: Property<Geofence, Int> = Property.newProperty()
|
||||
|
||||
private val instantiator = Instantiator { lookup: PropertyLookup<Geofence> ->
|
||||
val geofence = Geofence()
|
||||
geofence.place = lookup.valueOf(PLACE, "")
|
||||
geofence.task = lookup.valueOf(TASK, 1)
|
||||
geofence.isArrival = lookup.valueOf(ARRIVAL, false)
|
||||
geofence.isDeparture = lookup.valueOf(DEPARTURE, false)
|
||||
geofence.radius = lookup.valueOf(RADIUS, 250)
|
||||
geofence
|
||||
}
|
||||
|
||||
fun newGeofence(vararg properties: PropertyValue<in Geofence?, *>): Geofence {
|
||||
return Maker.make(instantiator, *properties)
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package org.tasks.data;
|
||||
|
||||
import androidx.room.Embedded;
|
||||
|
||||
public class MergedGeofence {
|
||||
@Embedded Place place;
|
||||
boolean arrival;
|
||||
boolean departure;
|
||||
int radius;
|
||||
|
||||
public Place getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
||||
public String getUid() {
|
||||
return place.getUid();
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return place.getLatitude();
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return place.getLongitude();
|
||||
}
|
||||
|
||||
public boolean isArrival() {
|
||||
return arrival;
|
||||
}
|
||||
|
||||
public boolean isDeparture() {
|
||||
return departure;
|
||||
}
|
||||
|
||||
public int getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MergedGeofence{"
|
||||
+ "place="
|
||||
+ place.getDisplayName()
|
||||
+ ", arrival="
|
||||
+ arrival
|
||||
+ ", departure="
|
||||
+ departure
|
||||
+ ", radius="
|
||||
+ radius
|
||||
+ '}';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue