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.
This commit is contained in:
demasterr 2019-03-11 16:56:03 +01:00 committed by Aleksandr Zatsepin
parent 420aabcecb
commit 891fe9a814

View file

@ -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: