Merge pull request #1781 from MilosKozak/NPEfixes
NPE fixes from Firebase
This commit is contained in:
commit
75d469a9db
|
@ -93,7 +93,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
} else if (editTextPref.getText() != null) {
|
} else if (editTextPref.getText() != null) {
|
||||||
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
|
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
|
||||||
pref.setSummary(editTextPref.getText());
|
pref.setSummary(editTextPref.getText());
|
||||||
} else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().trim())) {
|
} else if (pref.getKey().contains("smscommunicator_allowednumbers") && (editTextPref.getText() == null || TextUtils.isEmpty(editTextPref.getText().trim()))) {
|
||||||
pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
|
pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,20 +160,25 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight
|
||||||
private void startBLScan() {
|
private void startBLScan() {
|
||||||
if (!scanning) {
|
if (!scanning) {
|
||||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
if (!bluetoothAdapter.isEnabled()) bluetoothAdapter.enable();
|
if (bluetoothAdapter != null) {
|
||||||
IntentFilter intentFilter = new IntentFilter();
|
if (!bluetoothAdapter.isEnabled()) bluetoothAdapter.enable();
|
||||||
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
|
IntentFilter intentFilter = new IntentFilter();
|
||||||
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
|
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
|
||||||
registerReceiver(broadcastReceiver, intentFilter);
|
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
|
||||||
bluetoothAdapter.startDiscovery();
|
registerReceiver(broadcastReceiver, intentFilter);
|
||||||
scanning = true;
|
bluetoothAdapter.startDiscovery();
|
||||||
|
scanning = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopBLScan() {
|
private void stopBLScan() {
|
||||||
if (scanning) {
|
if (scanning) {
|
||||||
unregisterReceiver(broadcastReceiver);
|
unregisterReceiver(broadcastReceiver);
|
||||||
BluetoothAdapter.getDefaultAdapter().cancelDiscovery();
|
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
if (bluetoothAdapter != null) {
|
||||||
|
bluetoothAdapter.cancelDiscovery();
|
||||||
|
}
|
||||||
scanning = false;
|
scanning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,8 +190,9 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
}
|
}
|
||||||
// prepare task for execution in 1 sec
|
// prepare task for execution in 1 sec
|
||||||
// cancel waiting task to prevent sending multiple posts
|
// cancel waiting task to prevent sending multiple posts
|
||||||
if (callback.getPost() != null)
|
ScheduledFuture<?> scheduledFuture = callback.getPost();
|
||||||
callback.getPost().cancel(false);
|
if (scheduledFuture != null)
|
||||||
|
scheduledFuture.cancel(false);
|
||||||
Runnable task = new PostRunnable();
|
Runnable task = new PostRunnable();
|
||||||
final int sec = 1;
|
final int sec = 1;
|
||||||
callback.setPost(eventWorker.schedule(task, sec, TimeUnit.SECONDS));
|
callback.setPost(eventWorker.schedule(task, sec, TimeUnit.SECONDS));
|
||||||
|
|
|
@ -12,6 +12,8 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
@ -143,11 +145,11 @@ public class CommandQueue {
|
||||||
return queue.size();
|
return queue.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Command performing() {
|
Command performing() {
|
||||||
return performing;
|
return performing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetPerforming() {
|
void resetPerforming() {
|
||||||
performing = null;
|
performing = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,15 +141,17 @@ public class QueueThread extends Thread {
|
||||||
// Pickup 1st command and set performing variable
|
// Pickup 1st command and set performing variable
|
||||||
if (queue.size() > 0) {
|
if (queue.size() > 0) {
|
||||||
queue.pickup();
|
queue.pickup();
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (queue.performing() != null) {
|
||||||
log.debug("performing " + queue.performing().status());
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
MainApp.bus().post(new EventQueueChanged());
|
log.debug("performing " + queue.performing().status());
|
||||||
queue.performing().execute();
|
MainApp.bus().post(new EventQueueChanged());
|
||||||
queue.resetPerforming();
|
queue.performing().execute();
|
||||||
MainApp.bus().post(new EventQueueChanged());
|
queue.resetPerforming();
|
||||||
lastCommandTime = System.currentTimeMillis();
|
MainApp.bus().post(new EventQueueChanged());
|
||||||
SystemClock.sleep(100);
|
lastCommandTime = System.currentTimeMillis();
|
||||||
continue;
|
SystemClock.sleep(100);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +175,7 @@ public class QueueThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (mWakeLock != null)
|
if (mWakeLock != null && mWakeLock.isHeld())
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("thread end");
|
log.debug("thread end");
|
||||||
|
|
|
@ -150,6 +150,7 @@ public class AAPSMocker {
|
||||||
when(MainApp.gs(R.string.pumpsuspended)).thenReturn("Pump suspended");
|
when(MainApp.gs(R.string.pumpsuspended)).thenReturn("Pump suspended");
|
||||||
when(MainApp.gs(R.string.cob)).thenReturn("COB");
|
when(MainApp.gs(R.string.cob)).thenReturn("COB");
|
||||||
when(MainApp.gs(R.string.value_unavailable_short)).thenReturn("n/a");
|
when(MainApp.gs(R.string.value_unavailable_short)).thenReturn("n/a");
|
||||||
|
when(MainApp.gs(R.string.pumpNotInitialized)).thenReturn("Pump not initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MainApp mockMainApp() {
|
public static MainApp mockMainApp() {
|
||||||
|
|
Loading…
Reference in a new issue