Android Open Source - boundaries-android Geofence Update 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;
/*  w  w w . ja v a 2s .c  om*/
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;

import com.chaione.contexthub.sdk.ContextHub;
import com.chaione.contexthub.sdk.model.Geofence;
import com.contexthub.boundaries.R;

/**
 * Dialog fragment for updating a geofence
 */
public class GeofenceUpdateDialogFragment extends GeofenceEditDialogFragment {

    private static final String ARG_GEOFENCE = "geofence";

    private Geofence geofence;

    public static GeofenceUpdateDialogFragment newInstance(Geofence geofence) {
        GeofenceUpdateDialogFragment fragment = new GeofenceUpdateDialogFragment();
        Bundle args = new Bundle();
        args.putParcelable(ARG_GEOFENCE, geofence);
        fragment.setArguments(args);
        return fragment;
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog dialog = super.onCreateDialog(savedInstanceState);
        geofence = getArguments().getParcelable(ARG_GEOFENCE);
        geofenceName.setText(geofence.getName());
        return dialog;
    }

    @Override
    public void onClick(View v) {
        if(!validGeofence()) return;
        showProgressDialog(R.string.updating_geofence);
        geofence.setName(geofenceName.getText().toString());
        proxy.updateGeofence(geofence.getId(), geofence, this);
    }

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

    public class GeofenceUpdatedEvent {
        private Geofence geofence;

        public GeofenceUpdatedEvent(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