mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-25 16:56:23 +00:00
Handle API call errors when getting phone numbers
This commit is contained in:
parent
597044cdc8
commit
fd7abccb42
@ -37,7 +37,7 @@ public class ContactListAdapter extends ArrayAdapter<String> {
|
||||
if (element != null) {
|
||||
final TextView label = (TextView) v.findViewById(_fieldId);
|
||||
if (label != null) {
|
||||
label.setText(element + " >");
|
||||
label.setText(element);
|
||||
label.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
|
@ -1,17 +1,18 @@
|
||||
package fr.unix_experience.owncloud_sms.engine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import fr.unix_experience.owncloud_sms.R;
|
||||
import fr.unix_experience.owncloud_sms.adapters.ContactListAdapter;
|
||||
import fr.unix_experience.owncloud_sms.exceptions.OCSyncException;
|
||||
|
||||
@ -51,24 +52,23 @@ public interface ASyncContactLoad {
|
||||
|
||||
try {
|
||||
if (_client.getServerAPIVersion() < 2) {
|
||||
// @TODO: handle error
|
||||
_objects.add(_context.getString(R.string.err_proto_v2));
|
||||
return false;
|
||||
}
|
||||
|
||||
JSONArray phoneNumbers = _client.getServerPhoneNumbers();
|
||||
Log.d(TAG, phoneNumbers.toString());
|
||||
for (int i = 0; i < phoneNumbers.length(); i++) {
|
||||
String phone = phoneNumbers.getString(i);
|
||||
_objects.add(phone);
|
||||
}
|
||||
|
||||
// Sort phone numbers
|
||||
Collections.sort(_objects);
|
||||
} catch (JSONException e) {
|
||||
// @TODO: handle error
|
||||
e.printStackTrace();
|
||||
_objects.add(_context.getString(R.string.err_fetch_phonelist));
|
||||
return false;
|
||||
} catch (final OCSyncException e) {
|
||||
// @TODO: handle error
|
||||
e.printStackTrace();
|
||||
_objects.add(_context.getString(e.getErrorId()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -158,5 +158,7 @@ Contributors and issue\'s reporters</string>
|
||||
<string name="err_sync_no_connection_available">Error #16: No data connection available</string>
|
||||
<string name="err_sync_account_unparsable">Error #17: malformed account. Please reconfigure it</string>
|
||||
<string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: OcSMS app is not installed or ownCloud awaiting for an upgrade</string>
|
||||
<string name="err_fetch_phonelist">Invalid phonelist received from server.</string>
|
||||
<string name="err_proto_v2">Server doesn\'t support this feature. Ensure server version is at least 1.6.</string>
|
||||
|
||||
</resources>
|
||||
|
@ -118,4 +118,6 @@ Les contributeurs et rapporteurs de bugs</string>
|
||||
<string name="err_sync_no_connection_available">Erreur #16: Aucune connexion data disponible</string>
|
||||
<string name="err_sync_account_unparsable">Error #17: Compte mal configuré. Merci de bien vouloir le reconfigurer.</string>
|
||||
<string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: L\'application OcSMS n\'est pas installée ou ownCloud attend d\'être mis à niveau.</string>
|
||||
<string name="err_fetch_phonelist">La liste de numéros reçue depuis le serveur est invalide.</string>
|
||||
<string name="err_proto_v2">Le serveur ne supporte pas cette fonctionnalité. Assurez vous que le serveur est au moins en version 1.6.</string>
|
||||
</resources>
|
||||
|
@ -168,6 +168,8 @@ Contributors and issue\'s reporters</string>
|
||||
<string name="err_sync_no_connection_available">Error #16: No data connection available</string>
|
||||
<string name="err_sync_account_unparsable">Error #17: malformed account. Please reconfigure it</string>
|
||||
<string name="err_sync_ocsms_not_installed_or_oc_upgrade_required">Error #18: OcSMS app is not installed or ownCloud awaiting for an upgrade</string>
|
||||
<string name="err_fetch_phonelist">Invalid phonelist received from server.</string>
|
||||
<string name="err_proto_v2">Server doesn\'t support this feature. Ensure server version is at least 1.6.</string>
|
||||
|
||||
<string name="title_activity_main">MainActivity</string>
|
||||
<string name="title_section1">Section 1</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user