From 71720104f5ebcf2ff1d7d31bf8dee5e038175817 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Wed, 24 Oct 2018 20:54:20 +0200 Subject: code cleanup, null check not necessary when using instance of --- .../de/pixart/messenger/ui/ConversationsActivity.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java index 932ab452b..787942b8d 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationsActivity.java @@ -280,7 +280,8 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio return; } final Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment); - if (fragment != null && fragment instanceof ConversationsOverviewFragment) { + if (fragment instanceof ConversationsOverviewFragment) { + if (ExceptionHelper.checkForCrash(this)) { return; } @@ -335,14 +336,14 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio private void notifyFragmentOfBackendConnected(@IdRes int id) { final Fragment fragment = getFragmentManager().findFragmentById(id); - if (fragment != null && fragment instanceof OnBackendConnected) { + if (fragment instanceof OnBackendConnected) { ((OnBackendConnected) fragment).onBackendConnected(); } } private void refreshFragment(@IdRes int id) { final Fragment fragment = getFragmentManager().findFragmentById(id); - if (fragment != null && fragment instanceof XmppFragment) { + if (fragment instanceof XmppFragment) { ((XmppFragment) fragment).refresh(); } } @@ -530,7 +531,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio if (conversationFragment == null) { mainNeedsRefresh = false; Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment); - if (mainFragment != null && mainFragment instanceof ConversationFragment) { + if (mainFragment instanceof ConversationFragment) { conversationFragment = (ConversationFragment) mainFragment; } else { conversationFragment = new ConversationFragment(); @@ -686,7 +687,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio return; } } else { - if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) { + if (secondaryFragment instanceof ConversationFragment) { Log.d(Config.LOGTAG, "lost secondary fragment. moving..."); transaction.remove(secondaryFragment); transaction.commit(); @@ -712,7 +713,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment); - if (mainFragment != null && mainFragment instanceof ConversationFragment) { + if (mainFragment instanceof ConversationFragment) { final Conversation conversation = ((ConversationFragment) mainFragment).getConversation(); if (conversation != null) { actionBar.setDisplayHomeAsUpEnabled(true); @@ -895,7 +896,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio return; } Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment); - if (mainFragment != null && mainFragment instanceof ConversationFragment) { + if (mainFragment instanceof ConversationFragment) { try { getFragmentManager().popBackStack(); } catch (IllegalStateException e) { @@ -905,7 +906,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio return; } Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment); - if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) { + if (secondaryFragment instanceof ConversationFragment) { if (((ConversationFragment) secondaryFragment).getConversation() == conversation) { Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation); if (suggestion != null) { @@ -918,7 +919,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio @Override public void onConversationsListItemUpdated() { Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment); - if (fragment != null && fragment instanceof ConversationsOverviewFragment) { + if (fragment instanceof ConversationsOverviewFragment) { ((ConversationsOverviewFragment) fragment).refresh(); } } -- cgit v1.2.3