If you think the Android project AndroidPlaces listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2014 Brian Lee/*fromwww.java2s.com*/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.tigerpenguin.places.model;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
class Geometry extends JsonModel implements Parcelable {
@JsonProperty(LOCATION)
private PlaceLocation location;
@JsonProperty(VIEWPORT)
private Map<String, PlaceLocation> viewports;
public Geometry() {
// required for Jackson
}
public Geometry(Parcel in) {
location = in.readParcelable(PlaceLocation.class.getClassLoader());
viewports = new HashMap<String, PlaceLocation>();
Bundle bundle = in.readBundle(PlaceLocation.class.getClassLoader());
if (bundle != null) {
for (String key : bundle.keySet()) {
viewports.put(key, (PlaceLocation) bundle.getParcelable(key));
}
}
}
public PlaceLocation getLocation() {
return location;
}
@Override
publicint describeContents() {
return 0;
}
@Override
publicvoid writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(location, flags);
// Android documentation recommends using writeBundle() instead of writeMap()
Bundle bundle = null;
if (viewports != null && viewports.size() > 0) {
bundle = new Bundle();
for (Map.Entry<String, PlaceLocation> viewport : viewports.entrySet()) {
bundle.putParcelable(viewport.getKey(), viewport.getValue());
}
}
dest.writeBundle(bundle);
}
publicstaticfinal Creator<Geometry> CREATOR = new Creator<Geometry>() {
@Override
public Geometry createFromParcel(Parcel source) {
returnnew Geometry(source);
}
@Override
public Geometry[] newArray(int size) {
returnnew Geometry[size];
}
};
}