mirror of https://github.com/tasks/tasks
Convert MapPosition to Kotlin
parent
af0b0121a9
commit
6535406689
@ -1,63 +0,0 @@
|
||||
package org.tasks.location;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class MapPosition implements Parcelable {
|
||||
|
||||
public static final Parcelable.Creator<MapPosition> CREATOR =
|
||||
new Parcelable.Creator<MapPosition>() {
|
||||
@Override
|
||||
public MapPosition createFromParcel(Parcel in) {
|
||||
return new MapPosition(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapPosition[] newArray(int size) {
|
||||
return new MapPosition[size];
|
||||
}
|
||||
};
|
||||
private final double latitude;
|
||||
private final double longitude;
|
||||
private final float zoom;
|
||||
|
||||
public MapPosition(double latitude, double longitude) {
|
||||
this(latitude, longitude, 15.0f);
|
||||
}
|
||||
|
||||
public MapPosition(double latitude, double longitude, float zoom) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.zoom = zoom;
|
||||
}
|
||||
|
||||
private MapPosition(Parcel in) {
|
||||
latitude = in.readDouble();
|
||||
longitude = in.readDouble();
|
||||
zoom = in.readFloat();
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
float getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeDouble(latitude);
|
||||
dest.writeDouble(longitude);
|
||||
dest.writeFloat(zoom);
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package org.tasks.location
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
|
||||
class MapPosition : Parcelable {
|
||||
val latitude: Double
|
||||
val longitude: Double
|
||||
val zoom: Float
|
||||
|
||||
@JvmOverloads
|
||||
constructor(latitude: Double, longitude: Double, zoom: Float = 15.0f) {
|
||||
this.latitude = latitude
|
||||
this.longitude = longitude
|
||||
this.zoom = zoom
|
||||
}
|
||||
|
||||
private constructor(parcel: Parcel) {
|
||||
latitude = parcel.readDouble()
|
||||
longitude = parcel.readDouble()
|
||||
zoom = parcel.readFloat()
|
||||
}
|
||||
|
||||
override fun describeContents() = 0
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeDouble(latitude)
|
||||
dest.writeDouble(longitude)
|
||||
dest.writeFloat(zoom)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other !is MapPosition) return false
|
||||
|
||||
if (latitude != other.latitude) return false
|
||||
if (longitude != other.longitude) return false
|
||||
if (zoom != other.zoom) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = latitude.hashCode()
|
||||
result = 31 * result + longitude.hashCode()
|
||||
result = 31 * result + zoom.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun toString() = "MapPosition(latitude=$latitude, longitude=$longitude, zoom=$zoom)"
|
||||
|
||||
companion object {
|
||||
@JvmField val CREATOR: Parcelable.Creator<MapPosition> = object : Parcelable.Creator<MapPosition> {
|
||||
override fun createFromParcel(source: Parcel) = MapPosition(source)
|
||||
|
||||
override fun newArray(size: Int): Array<MapPosition?> = arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue