Preventing a NullPointerException while handling a node disconnection

This commit is contained in:
Nelson R. Perez 2018-11-15 17:54:57 -05:00
parent af5896a160
commit 843aacb859

View file

@ -690,19 +690,21 @@ public class NetworkService extends Service {
isLoggedIn = false; isLoggedIn = false;
if(mSelectedNode != null){
// Marking the selected node as not connected // Marking the selected node as not connected
mSelectedNode.setConnected(false); mSelectedNode.setConnected(false);
// Updating the selected node's 'connected' status on the NodeLatencyVerifier instance // Updating the selected node's 'connected' status on the NodeLatencyVerifier instance
if(nodeLatencyVerifier != null) if(nodeLatencyVerifier != null)
nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode); nodeLatencyVerifier.updateActiveNodeInformation(mSelectedNode);
}
if(tryReconnection) { if(tryReconnection) {
// Registering current status // Registering current status
mCurrentId = 0; mCurrentId = 0;
mApiIds.clear(); mApiIds.clear();
if (removeSelectedNode) { if (removeSelectedNode && mSelectedNode != null) {
// Remove node from node provider so that it is not returned for following connections // Remove node from node provider so that it is not returned for following connections
nodeProvider.removeNode(mSelectedNode); nodeProvider.removeNode(mSelectedNode);