Search in sources :

Example 1 with MicroStatusImpl

use of com.eveningoutpost.dexdrip.ui.MicroStatusImpl in project xDrip-plus by jamorham.

the class SystemStatusFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // Injectors.getMicroStatusComponent().inject(this);
    requestWearCollectorStatus();
    serviceDataReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context ctx, Intent intent) {
            final String action = intent.getAction();
            // final String msg = intent.getStringExtra("data");
            Bundle bundle = intent.getBundleExtra("data");
            if (bundle != null) {
                DataMap dataMap = DataMap.fromBundle(bundle);
                String lastState = dataMap.getString("lastState", "");
                long last_timestamp = dataMap.getLong("timestamp", 0);
                UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp);
                switch(action) {
                    case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE:
                        switch(DexCollectionType.getDexCollectionType()) {
                            case DexcomG5:
                                // msg, last_timestamp
                                G5CollectionService.setWatchStatus(dataMap);
                                break;
                            case DexcomShare:
                                if (lastState != null && !lastState.isEmpty()) {
                                    // TODO getLastState() in non-G5 Services
                                    setConnectionStatus(lastState);
                                }
                                break;
                            default:
                                // msg, last_timestamp
                                DexCollectionService.setWatchStatus(dataMap);
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);
                                }
                                break;
                        }
                        break;
                }
            }
        }
    };
    final ActivitySystemStatusBinding binding = DataBindingUtil.inflate(inflater, R.layout.activity_system_status, container, false);
    microStatus = new MicroStatusImpl();
    binding.setMs(microStatus);
    return binding.getRoot();
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Intent(android.content.Intent) ActivitySystemStatusBinding(com.eveningoutpost.dexdrip.databinding.ActivitySystemStatusBinding) MicroStatusImpl(com.eveningoutpost.dexdrip.ui.MicroStatusImpl) BroadcastReceiver(android.content.BroadcastReceiver) DataMap(com.google.android.gms.wearable.DataMap)

Example 2 with MicroStatusImpl

use of com.eveningoutpost.dexdrip.ui.MicroStatusImpl in project xDrip by NightscoutFoundation.

the class Home method showInitialStatusHelper.

private synchronized void showInitialStatusHelper() {
    if (checkBatteryOptimization()) {
        // update
        initialDataQuality = ProcessInitialDataQuality.getInitialDataQuality();
        if ((helper_dialog != null) && (helper_dialog.isShowing()))
            helper_dialog.dismiss();
        if ((status_helper_dialog != null) && (status_helper_dialog.isShowing())) {
            if (initial_status_binding != null)
                // update data
                initial_status_binding.setIdq(initialDataQuality);
            return;
        }
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.collecting_initial_readings);
        initial_status_binding = PopupInitialStatusHelperBinding.inflate(getLayoutInflater());
        initial_status_binding.setIdq(initialDataQuality);
        if (microStatus == null)
            microStatus = new MicroStatusImpl();
        initial_status_binding.setMs(microStatus);
        initial_status_binding.setPrefs(new PrefsViewImpl());
        builder.setView(initial_status_binding.getRoot());
        status_helper_dialog = builder.create();
        status_helper_dialog.setCanceledOnTouchOutside(true);
        try {
            status_helper_dialog.show();
        } catch (Exception e) {
            UserError.Log.e(TAG, "Could not display calibration prompt helper: " + e);
        }
        keepScreenOn();
    }
}
Also used : AlertDialog(android.app.AlertDialog) PrefsViewImpl(com.eveningoutpost.dexdrip.UtilityModels.PrefsViewImpl) GsonBuilder(com.google.gson.GsonBuilder) BgGraphBuilder(com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder) MicroStatusImpl(com.eveningoutpost.dexdrip.ui.MicroStatusImpl) IOException(java.io.IOException) ParseException(java.text.ParseException) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 3 with MicroStatusImpl

use of com.eveningoutpost.dexdrip.ui.MicroStatusImpl in project xDrip-plus by jamorham.

the class Home method showInitialStatusHelper.

private synchronized void showInitialStatusHelper() {
    if (checkBatteryOptimization()) {
        // update
        initialDataQuality = ProcessInitialDataQuality.getInitialDataQuality();
        if ((helper_dialog != null) && (helper_dialog.isShowing()))
            helper_dialog.dismiss();
        if ((status_helper_dialog != null) && (status_helper_dialog.isShowing())) {
            if (initial_status_binding != null)
                // update data
                initial_status_binding.setIdq(initialDataQuality);
            return;
        }
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.collecting_initial_readings);
        initial_status_binding = PopupInitialStatusHelperBinding.inflate(getLayoutInflater());
        initial_status_binding.setIdq(initialDataQuality);
        if (microStatus == null)
            microStatus = new MicroStatusImpl();
        initial_status_binding.setMs(microStatus);
        initial_status_binding.setPrefs(new PrefsViewImpl());
        builder.setView(initial_status_binding.getRoot());
        status_helper_dialog = builder.create();
        status_helper_dialog.setCanceledOnTouchOutside(true);
        try {
            status_helper_dialog.show();
        } catch (Exception e) {
            UserError.Log.e(TAG, "Could not display calibration prompt helper: " + e);
        }
        keepScreenOn();
    }
}
Also used : AlertDialog(android.app.AlertDialog) PrefsViewImpl(com.eveningoutpost.dexdrip.UtilityModels.PrefsViewImpl) GsonBuilder(com.google.gson.GsonBuilder) BgGraphBuilder(com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder) MicroStatusImpl(com.eveningoutpost.dexdrip.ui.MicroStatusImpl) IOException(java.io.IOException) ParseException(java.text.ParseException) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 4 with MicroStatusImpl

use of com.eveningoutpost.dexdrip.ui.MicroStatusImpl in project xDrip by NightscoutFoundation.

the class SystemStatusFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // Injectors.getMicroStatusComponent().inject(this);
    requestWearCollectorStatus();
    serviceDataReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context ctx, Intent intent) {
            final String action = intent.getAction();
            // final String msg = intent.getStringExtra("data");
            Bundle bundle = intent.getBundleExtra("data");
            if (bundle != null) {
                DataMap dataMap = DataMap.fromBundle(bundle);
                String lastState = dataMap.getString("lastState", "");
                long last_timestamp = dataMap.getLong("timestamp", 0);
                UserError.Log.d(TAG, "serviceDataReceiver onReceive:" + action + " :: " + lastState + " last_timestamp :: " + last_timestamp);
                switch(action) {
                    case WatchUpdaterService.ACTION_BLUETOOTH_COLLECTION_SERVICE_UPDATE:
                        switch(DexCollectionType.getDexCollectionType()) {
                            case DexcomG5:
                                // msg, last_timestamp
                                G5CollectionService.setWatchStatus(dataMap);
                                break;
                            case DexcomShare:
                                if (lastState != null && !lastState.isEmpty()) {
                                    // TODO getLastState() in non-G5 Services
                                    setConnectionStatus(lastState);
                                }
                                break;
                            default:
                                // msg, last_timestamp
                                DexCollectionService.setWatchStatus(dataMap);
                                if (lastState != null && !lastState.isEmpty()) {
                                    setConnectionStatus(lastState);
                                }
                                break;
                        }
                        break;
                }
            }
        }
    };
    final ActivitySystemStatusBinding binding = DataBindingUtil.inflate(inflater, R.layout.activity_system_status, container, false);
    microStatus = new MicroStatusImpl();
    binding.setMs(microStatus);
    return binding.getRoot();
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Intent(android.content.Intent) ActivitySystemStatusBinding(com.eveningoutpost.dexdrip.databinding.ActivitySystemStatusBinding) MicroStatusImpl(com.eveningoutpost.dexdrip.ui.MicroStatusImpl) BroadcastReceiver(android.content.BroadcastReceiver) DataMap(com.google.android.gms.wearable.DataMap)

Aggregations

MicroStatusImpl (com.eveningoutpost.dexdrip.ui.MicroStatusImpl)4 AlertDialog (android.app.AlertDialog)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2 BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 BgGraphBuilder (com.eveningoutpost.dexdrip.UtilityModels.BgGraphBuilder)2 PrefsViewImpl (com.eveningoutpost.dexdrip.UtilityModels.PrefsViewImpl)2 ActivitySystemStatusBinding (com.eveningoutpost.dexdrip.databinding.ActivitySystemStatusBinding)2 DataMap (com.google.android.gms.wearable.DataMap)2 GsonBuilder (com.google.gson.GsonBuilder)2 IOException (java.io.IOException)2 ParseException (java.text.ParseException)2