Search in sources :

Example 1 with ActivitySystemStatusBinding

use of com.eveningoutpost.dexdrip.databinding.ActivitySystemStatusBinding 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 ActivitySystemStatusBinding

use of com.eveningoutpost.dexdrip.databinding.ActivitySystemStatusBinding 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

BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 ActivitySystemStatusBinding (com.eveningoutpost.dexdrip.databinding.ActivitySystemStatusBinding)2 MicroStatusImpl (com.eveningoutpost.dexdrip.ui.MicroStatusImpl)2 DataMap (com.google.android.gms.wearable.DataMap)2