Android Open Source - Arduino-Android-BLE-NRF8001 Sensor Dialog






From Project

Back to project page Arduino-Android-BLE-NRF8001.

License

The source code is released under:

MIT License

If you think the Android project Arduino-Android-BLE-NRF8001 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 edu.uci.fallsensor.dialog;
/*from  w w  w  .java 2 s  .co  m*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;

import edu.uci.arduinosensor.R;

public class SensorDialog extends DialogFragment
        implements OnClickListener {
    SensorDialogOnClickListener mListener;
    private final String msgString;
    private final int sensorStatus;
    public static SensorDialog newInstance(String msg, int status) {
        return new SensorDialog(msg, status);
    }

    private SensorDialog(String msg, int status) {
        msgString = msg;
        sensorStatus = status;
    }

    public void onAttach(Activity activity) {
        super.onAttach(activity);
        // Verify that the host activity implements the callback interface
        try {
            // Instantiate the SensorDialogOnClickListener so we can send events
            // to the host
            mListener = (SensorDialogOnClickListener) activity;
        } catch (ClassCastException e) {
            // The activity doesn't implement the interface, throw exception
            throw new ClassCastException(activity.toString()
                    + " must implement " + SensorDialogOnClickListener.class.getSimpleName());
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("Sensor Detected Event Status " + sensorStatus)
                .setMessage(msgString)
                .setPositiveButton(getString(R.string.confirm), this)
                .setNegativeButton(getString(R.string.cancel), this);

        return builder.create();
    }

    @Override
    public void onClick(DialogInterface dialog, int which) {
        switch (which) {
            case AlertDialog.BUTTON_POSITIVE:
            case AlertDialog.BUTTON_NEGATIVE:
                mListener.notifySensorDialogListener(which);
                break;
        }
    }

    public interface SensorDialogOnClickListener {
        void notifySensorDialogListener(int choice);
    }
}




Java Source Code List

com.adapters.ListAdapterCheckboxTitle.java
com.adapters.ListAdapterTitleDescription.java
com.adapters.ListAdapterTitleDescription.java
com.adapters.MainViewPagerAdapter.java
com.ble.sensors.NRF8001.java
edu.uci.fallsensor.MainActivity.java
edu.uci.fallsensor.dialog.SensorDialog.java
edu.uci.fallsensor.service.BLEController.java
edu.uci.fallsensor.service.BLEManager.java
edu.uci.fallsensor.service.BLEState.java
edu.uci.fallsensor.service.BLETask.java
edu.uci.fallsensor.service.BluetoothMetaData.java