From 891fe9a814a0dbf65456209904e4054589f91550 Mon Sep 17 00:00:00 2001 From: demasterr Date: Mon, 11 Mar 2019 16:56:03 +0100 Subject: [PATCH] Refactored BottomPanel update Reduced the complexity of update() from 22 to 18. getAdapter is a function that returns a NonNull adapter. This means that the `!= null` check is not needed. Also, one duplicate line was removed outside the if-else. The state does not seem to be affected by any other lines and thus could be reduced to one single assignment. --- .../com/mapswithme/maps/downloader/BottomPanel.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/android/src/com/mapswithme/maps/downloader/BottomPanel.java b/android/src/com/mapswithme/maps/downloader/BottomPanel.java index e95c7b053c..a200a0a59f 100644 --- a/android/src/com/mapswithme/maps/downloader/BottomPanel.java +++ b/android/src/com/mapswithme/maps/downloader/BottomPanel.java @@ -112,18 +112,19 @@ class BottomPanel public void update() { + // DownloaderAdapter getAdapter is nonNull. DownloaderAdapter adapter = mFragment.getAdapter(); - boolean search = adapter != null && adapter.isSearchResultsMode(); + boolean search = adapter.isSearchResultsMode(); boolean show = !search; - UiUtils.showIf(show && adapter != null && adapter.isMyMapsMode(), mFab); + UiUtils.showIf(show && adapter.isMyMapsMode(), mFab); if (show) { - String root = adapter != null ? adapter.getCurrentRootId() : ""; - if (adapter != null && adapter.isMyMapsMode()) + String root = adapter.getCurrentRootId(); + int status = MapManager.nativeGetStatus(root); + if (adapter.isMyMapsMode()) { - int status = MapManager.nativeGetStatus(root); switch (status) { case CountryItem.STATUS_UPDATABLE: @@ -156,7 +157,6 @@ class BottomPanel show = !CountryItem.isRoot(root); if (show) { - int status = MapManager.nativeGetStatus(root); switch (status) { case CountryItem.STATUS_UPDATABLE: