codacy: These nested if statements could be combined

This commit is contained in:
AndyScherzinger 2018-02-21 21:59:38 +01:00
parent 4440e1e192
commit c6de6bdf28
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
4 changed files with 25 additions and 29 deletions

View File

@ -146,12 +146,11 @@ public class CallsListController extends BaseController implements SearchView.On
userEntity = userUtils.getCurrentUser(); userEntity = userUtils.getCurrentUser();
if (userEntity == null) { if (userEntity == null &&
if (getParentController() != null && getParentController().getRouter() != null) { getParentController() != null && getParentController().getRouter() != null) {
getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController()) getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
.pushChangeHandler(new HorizontalChangeHandler()) .pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler()))); .popChangeHandler(new HorizontalChangeHandler())));
}
} }
if (adapter == null) { if (adapter == null) {
@ -359,12 +358,11 @@ public class CallsListController extends BaseController implements SearchView.On
private void dispose(@Nullable Disposable disposable) { private void dispose(@Nullable Disposable disposable) {
if (disposable != null && !disposable.isDisposed()) { if (disposable != null && !disposable.isDisposed()) {
disposable.dispose(); disposable.dispose();
} else if (disposable == null) { } else if (disposable == null &&
roomsQueryDisposable != null && !roomsQueryDisposable.isDisposed() {
roomsQueryDisposable.dispose();
roomsQueryDisposable = null;
if (roomsQueryDisposable != null && !roomsQueryDisposable.isDisposed()) {
roomsQueryDisposable.dispose();
roomsQueryDisposable = null;
}
} }
} }

View File

@ -184,12 +184,11 @@ public class ContactsController extends BaseController implements SearchView.OnQ
userEntity = userUtils.getCurrentUser(); userEntity = userUtils.getCurrentUser();
if (userEntity == null) { if (userEntity == null &&
if (getParentController().getRouter() != null) { getParentController() != null && getParentController().getRouter() != null) {
getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController()) getParentController().getRouter().setRoot((RouterTransaction.with(new ServerSelectionController())
.pushChangeHandler(new HorizontalChangeHandler()) .pushChangeHandler(new HorizontalChangeHandler())
.popChangeHandler(new HorizontalChangeHandler()))); .popChangeHandler(new HorizontalChangeHandler())));
}
} }
if (adapter == null) { if (adapter == null) {
@ -197,7 +196,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
adapter.setNotifyChangeOfUnfilteredItems(true) adapter.setNotifyChangeOfUnfilteredItems(true)
.setMode(SelectableAdapter.Mode.MULTI); .setMode(SelectableAdapter.Mode.MULTI);
if (userEntity != null) { if (userEntity != null) {
fetchData(); fetchData();
} }

View File

@ -545,14 +545,15 @@ public class MagicAudioManager {
bluetoothManager.updateDevice(); bluetoothManager.updateDevice();
} }
if (needBluetoothAudioStart && !needBluetoothAudioStop) { // Attempt to start Bluetooth SCO audio (takes a few second to start).
// Attempt to start Bluetooth SCO audio (takes a few second to start). if (needBluetoothAudioStart &&
if (!bluetoothManager.startScoAudio()) { !needBluetoothAudioStop &&
// Remove BLUETOOTH from list of available devices since SCO failed. !bluetoothManager.startScoAudio()) {
audioDevices.remove(AudioDevice.BLUETOOTH); // Remove BLUETOOTH from list of available devices since SCO failed.
audioDeviceSetUpdated = true; audioDevices.remove(AudioDevice.BLUETOOTH);
} audioDeviceSetUpdated = true;
} }
}
// Update selected audio device. // Update selected audio device.
AudioDevice newAudioDevice = selectedAudioDevice; AudioDevice newAudioDevice = selectedAudioDevice;

View File

@ -111,10 +111,9 @@ public class MagicProximitySensor implements SensorEventListener {
@Override @Override
public final void onAccuracyChanged(Sensor sensor, int accuracy) { public final void onAccuracyChanged(Sensor sensor, int accuracy) {
threadChecker.checkIsOnValidThread(); threadChecker.checkIsOnValidThread();
if (sensor.getType() == Sensor.TYPE_PROXIMITY) { if (sensor.getType() == Sensor.TYPE_PROXIMITY &&
if (accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) { accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) {
Log.e(TAG, "The values returned by this sensor cannot be trusted"); Log.e(TAG, "The values returned by this sensor cannot be trusted");
}
} }
} }