Эх сурвалжийг харах

codacy: These nested if statements could be combined

AndyScherzinger 7 жил өмнө
parent
commit
c6de6bdf28

+ 9 - 11
app/src/main/java/com/nextcloud/talk/controllers/CallsListController.java

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

+ 5 - 7
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java

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

+ 8 - 7
app/src/main/java/com/nextcloud/talk/webrtc/MagicAudioManager.java

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

+ 3 - 4
app/src/main/java/com/nextcloud/talk/webrtc/MagicProximitySensor.java

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