Fixed app crash when trying to connect without server address
This commit is contained in:
parent
678777a330
commit
f4274ed03e
3 changed files with 32 additions and 18 deletions
|
|
@ -101,6 +101,8 @@ public class LoginActivity extends AbsBaseActivity implements View.OnClickListen
|
||||||
|
|
||||||
credentialProvider = new AndroidCredentialProvider(jsonSerializer, this, logger);
|
credentialProvider = new AndroidCredentialProvider(jsonSerializer, this, logger);
|
||||||
ConnectionManager connectionManager = App.getConnectionManager(context, jsonSerializer, logger, httpClient);
|
ConnectionManager connectionManager = App.getConnectionManager(context, jsonSerializer, logger, httpClient);
|
||||||
|
|
||||||
|
try {
|
||||||
connectionManager.Connect(server.getText().toString(), new Response<ConnectionResult>() {
|
connectionManager.Connect(server.getText().toString(), new Response<ConnectionResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(ConnectionResult result) {
|
public void onResponse(ConnectionResult result) {
|
||||||
|
|
@ -122,6 +124,14 @@ public class LoginActivity extends AbsBaseActivity implements View.OnClickListen
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
if (e.getMessage().equals("address")) {
|
||||||
|
Toast.makeText(context, context.getResources().getString(R.string.error_login_empty_addr), Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, context.getResources().getString(R.string.error_unexpected), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,4 +149,6 @@
|
||||||
<string name="sort_method_artist">Artiste</string>
|
<string name="sort_method_artist">Artiste</string>
|
||||||
<string name="sort_method_album">Album</string>
|
<string name="sort_method_album">Album</string>
|
||||||
<string name="sort_method_year">Année</string>
|
<string name="sort_method_year">Année</string>
|
||||||
|
<string name="error_login_empty_addr">Veuillez saisir l\'adresse du serveur.</string>
|
||||||
|
<string name="error_unexpected">Une erreur inattendue s\'est produite.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -214,5 +214,7 @@
|
||||||
<string name="cancel_current_timer">Cancel current timer</string>
|
<string name="cancel_current_timer">Cancel current timer</string>
|
||||||
<string name="sleep_timer_canceled">Sleep timer canceled.</string>
|
<string name="sleep_timer_canceled">Sleep timer canceled.</string>
|
||||||
<string name="sleep_timer_set">Sleep timer set for %d minutes from now.</string>
|
<string name="sleep_timer_set">Sleep timer set for %d minutes from now.</string>
|
||||||
|
<string name="error_login_empty_addr">Please fill in the server address.</string>
|
||||||
|
<string name="error_unexpected">An unexpected error occurred.</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue