All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mapbox.mapboxsdk.annotations.MarkerViewOptions Maven / Gradle / Ivy

There is a newer version: 9.2.1
Show newest version
package com.mapbox.mapboxsdk.annotations;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

import com.mapbox.mapboxsdk.geometry.LatLng;

public class MarkerViewOptions extends BaseMarkerViewOptions {

    private MarkerView marker;

    public MarkerViewOptions() {
        marker = new MarkerView();
    }

    protected MarkerViewOptions(Parcel in) {
        marker = new MarkerView();
        position((LatLng) in.readParcelable(LatLng.class.getClassLoader()));
        snippet(in.readString());
        title(in.readString());
        flat(in.readByte() != 0);
        anchor(in.readFloat(), in.readFloat());
        infoWindowAnchor(in.readFloat(), in.readFloat());
        selectAnimatorResource(in.readInt());
        deselectAnimatorResource(in.readInt());
        rotation(in.readInt());
        visible(in.readByte() != 0);
        if (in.readByte() != 0) {
            // this means we have an icon
            String iconId = in.readString();
            Bitmap iconBitmap = in.readParcelable(Bitmap.class.getClassLoader());
            Icon icon = new Icon(iconId, iconBitmap);
            icon(icon);
        }
    }

    @Override
    public MarkerViewOptions getThis() {
        return this;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeParcelable(getPosition(), flags);
        out.writeString(getSnippet());
        out.writeString(getTitle());
        out.writeByte((byte) (isFlat() ? 1 : 0));
        out.writeFloat(getAnchorU());
        out.writeFloat(getAnchorV());
        out.writeFloat(getInfoWindowAnchorU());
        out.writeFloat(getInfoWindowAnchorV());
        out.writeInt(getSelectAnimRes());
        out.writeInt(getDeselectAnimRes());
        out.writeInt(getRotation());
        out.writeByte((byte) (isVisible() ? 1 : 0));
        Icon icon = getIcon();
        out.writeByte((byte) (icon != null ? 1 : 0));
        if (icon != null) {
            out.writeString(getIcon().getId());
            out.writeParcelable(getIcon().getBitmap(), flags);
        }
    }

    @Override
    public MarkerView getMarker() {
        marker.setPosition(position);
        marker.setSnippet(snippet);
        marker.setTitle(title);
        marker.setIcon(icon);
        marker.setFlat(flat);
        marker.setAnchor(anchorU, anchorV);
        marker.setInfoWindowAnchor(infoWindowAnchorU, infoWindowAnchorV);
        marker.setSelectAnimRes(selectAnimRes);
        marker.setDeselectAnimRes(deselectAnimRes);
        marker.setRotation(rotation);
        marker.setVisible(visible);
        return marker;
    }

    public static final Parcelable.Creator CREATOR
            = new Parcelable.Creator() {
        public MarkerViewOptions createFromParcel(Parcel in) {
            return new MarkerViewOptions(in);
        }

        public MarkerViewOptions[] newArray(int size) {
            return new MarkerViewOptions[size];
        }
    };

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MarkerViewOptions that = (MarkerViewOptions) o;
        return marker != null ? marker.equals(that.marker) : that.marker == null;
    }

    @Override
    public int hashCode() {
        return marker != null ? marker.hashCode() : 0;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy