@Override public void onResume() { // If the app is resumed, we need to update the list adapter in case changes have been made to // the list of devices (eg: new device added) super.onResume(); AutomatedDeviceListFragment frag = (AutomatedDeviceListFragment) getSupportFragmentManager().findFragmentById(R.id.automateddevice_list); frag.updateDevAdapter(); }
// Listener interface method to make sure that changes made in the detail fragment get saved // appropriately and update the UI public void onDeviceChangeMade(AutomatedDevice newDev, AutomatedDevice oldDev) { testSharedPrefsDevices(); logSharedPrefsDevices(); SharedPreferences prefs = this.getSharedPreferences("distributed.directions.saved.devices", 0); if (prefs.contains(oldDev.getName())) { SharedPreferences.Editor editor = prefs.edit(); editor.remove(oldDev.getName()); editor.putString(newDev.getName(), newDev.delimitedRep()); boolean success = editor.commit(); if (!success) { Log.i("ERROR: ", "Failed to update shared preferences"); } } else { Log.i("ERROR: ", "Shared Prefs did not have " + oldDev.getName()); } AutomatedDeviceListFragment frag = (AutomatedDeviceListFragment) getSupportFragmentManager().findFragmentById(R.id.automateddevice_list); frag.updateDevAdapter(); }