Android Open Source - boundaries-android Geofence Create Dialog Fragment






From Project

Back to project page boundaries-android.

License

The source code is released under:

MIT License

If you think the Android project boundaries-android 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

package com.contexthub.boundaries.fragments;
/*from w  ww  .  j a  v  a2  s  . c  o m*/
import android.os.Bundle;
import android.view.View;

import com.chaione.contexthub.sdk.ContextHub;
import com.chaione.contexthub.sdk.model.Geofence;
import com.contexthub.boundaries.R;
import com.google.android.gms.maps.model.LatLng;

import java.util.Arrays;

/**
 * Dialog fragment for creating a geofence
 */
public class GeofenceCreateDialogFragment extends GeofenceEditDialogFragment {

    private static final int GEOFENCE_RADIUS = 500;

    private static final String ARG_COORDINATES = "coordinates";

    public static GeofenceCreateDialogFragment newInstance(LatLng coordinates) {
        GeofenceCreateDialogFragment fragment = new GeofenceCreateDialogFragment();
        Bundle args = new Bundle();
        args.putParcelable(ARG_COORDINATES, coordinates);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onClick(View v) {
        if(!validGeofence()) return;
        showProgressDialog(R.string.creating_geofence);
        LatLng coordinates = (LatLng) getArguments().getParcelable(ARG_COORDINATES);
        proxy.createGeofence(geofenceName.getText().toString(), coordinates.latitude, coordinates.longitude,
                GEOFENCE_RADIUS, Arrays.asList("geofence-tag"), this);
    }

    @Override
    protected void postGeofenceChangedEvent(Geofence geofence) {
        ContextHub.getInstance().getBus().post(new GeofenceCreatedEvent(geofence));
    }

    public class GeofenceCreatedEvent {
        private Geofence geofence;

        public GeofenceCreatedEvent(Geofence geofence) {
            this.geofence = geofence;
        }

        public Geofence getGeofence() {
            return geofence;
        }
    }
}




Java Source Code List

com.contexthub.boundaries.ApplicationTest.java
com.contexthub.boundaries.BoundariesApp.java
com.contexthub.boundaries.MainActivity.java
com.contexthub.boundaries.fragments.AboutFragment.java
com.contexthub.boundaries.fragments.GeofenceCreateDialogFragment.java
com.contexthub.boundaries.fragments.GeofenceEditDialogFragment.java
com.contexthub.boundaries.fragments.GeofenceListFragment.java
com.contexthub.boundaries.fragments.GeofenceUpdateDialogFragment.java
com.contexthub.boundaries.fragments.GeofencesMapFragment.java