Detect empty server addresses
If the app detects an empty server URL, it will change it to the default server address.
This commit is contained in:
parent
02f7b5b444
commit
cff137eded
|
@ -92,11 +92,16 @@ public class TriviaQuery implements Serializable {
|
|||
// Load custom server URL.
|
||||
Context c = PluckApplication.getAppContext();
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c);
|
||||
String key = c.getResources().getString(R.string.pref_network_server);
|
||||
String serverKey = c.getResources().getString(R.string.pref_network_server);
|
||||
// Load default server URL in case the player did not specify a custom server URL.
|
||||
String defaultServer = c.getResources().getString(R.string.pref_network_server_default);
|
||||
String base = sp.getString(serverKey, defaultServer) + "?"; // append "?" to the end of the URL so we can specify GET parameters.
|
||||
|
||||
String base = sp.getString(key, defaultServer) + "?"; // append "?" to the end of the URL so we can specify GET parameters.
|
||||
// Check if the custom server URL preference was empty. If it was, change it to the default URL.
|
||||
if (base.equals("?")){
|
||||
base = defaultServer + "?";
|
||||
sp.edit().putString(serverKey, defaultServer).commit();
|
||||
}
|
||||
|
||||
url.append(base);
|
||||
url.append("amount=").append(this.amount);
|
||||
|
|
Loading…
Reference in New Issue