Commit 9f9e9b36 authored by Romain Bertozzi's avatar Romain Bertozzi Committed by Alexandre Lision
Browse files

stability: prevent some NPE

This patch prevents some NPE to happen when activities and fragments
were deallocated.

Tuleap: #862
Change-Id: I574b6d19f82dd614e4cbe4d4de839daf9bd775cb
parent f10ec204
......@@ -339,7 +339,7 @@ public class ConversationActivity extends AppCompatActivity implements
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case REQ_ADD_CONTACT:
mService.refreshConversations();
if (mService != null) mService.refreshConversations();
break;
}
}
......
......@@ -138,7 +138,9 @@ public class SmartListFragment extends Fragment implements SearchView.OnQueryTex
}
if (service.isConnected()) {
mErrorMessagePane.setVisibility(View.GONE);
if (mErrorMessagePane != null) {
mErrorMessagePane.setVisibility(View.GONE);
}
} else {
this.presentNetworkErrorPanel(service);
}
......@@ -345,7 +347,9 @@ public class SmartListFragment extends Fragment implements SearchView.OnQueryTex
mSmartListAdapter.updateDataset(service.getConversations(), null);
mSmartListAdapter.setCallback(this);
mList.setAdapter(mSmartListAdapter);
if (mList != null) {
mList.setAdapter(mSmartListAdapter);
}
}
private void startConversation(CallContact c) {
......@@ -600,11 +604,17 @@ public class SmartListFragment extends Fragment implements SearchView.OnQueryTex
final boolean showImage,
final int imageResId,
@Nullable View.OnClickListener clickListener) {
mErrorMessagePane.setVisibility(View.VISIBLE);
mErrorMessagePane.setOnClickListener(clickListener);
mErrorMessageTextView.setText(textResId);
int visibility = (showImage) ? View.VISIBLE : View.GONE;
mErrorImageView.setVisibility(visibility);
mErrorImageView.setImageResource(imageResId);
if (mErrorMessagePane != null) {
mErrorMessagePane.setVisibility(View.VISIBLE);
mErrorMessagePane.setOnClickListener(clickListener);
}
if (mErrorMessageTextView != null) {
mErrorMessageTextView.setText(textResId);
}
if (mErrorImageView != null) {
int visibility = (showImage) ? View.VISIBLE : View.GONE;
mErrorImageView.setVisibility(visibility);
mErrorImageView.setImageResource(imageResId);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment