mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-19 13:56:28 +00:00
Prepare ListView loading
This commit is contained in:
parent
9d2d76a606
commit
8e4c07f924
@ -3,11 +3,16 @@ package fr.unix_experience.owncloud_sms.activities.restore_sms;
|
|||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import fr.unix_experience.owncloud_sms.R;
|
import fr.unix_experience.owncloud_sms.R;
|
||||||
|
import fr.unix_experience.owncloud_sms.engine.OCSMSOwnCloudClient;
|
||||||
|
import fr.unix_experience.owncloud_sms.exceptions.OCSyncException;
|
||||||
|
|
||||||
public class ContactListActivity extends ListActivity {
|
public class ContactListActivity extends ListActivity {
|
||||||
|
|
||||||
|
static AccountManager _accountMgr;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -19,9 +24,10 @@ public class ContactListActivity extends ListActivity {
|
|||||||
// accountName cannot be null, devel error
|
// accountName cannot be null, devel error
|
||||||
assert accountName != null;
|
assert accountName != null;
|
||||||
|
|
||||||
final AccountManager _accountMgr = AccountManager.get(getBaseContext());
|
_accountMgr = AccountManager.get(getBaseContext());
|
||||||
final Account[] myAccountList =
|
final Account[] myAccountList =
|
||||||
_accountMgr.getAccountsByType(getString(R.string.account_type));
|
_accountMgr.getAccountsByType(getString(R.string.account_type));
|
||||||
|
|
||||||
for (final Account element : myAccountList) {
|
for (final Account element : myAccountList) {
|
||||||
if (element.name.equals(accountName)) {
|
if (element.name.equals(accountName)) {
|
||||||
loadContacts(element);
|
loadContacts(element);
|
||||||
@ -32,6 +38,26 @@ public class ContactListActivity extends ListActivity {
|
|||||||
|
|
||||||
// This function fetch contacts from the ownCloud instance and generate the list activity
|
// This function fetch contacts from the ownCloud instance and generate the list activity
|
||||||
private void loadContacts(final Account account) {
|
private void loadContacts(final Account account) {
|
||||||
|
// Create client
|
||||||
|
final String ocURI = _accountMgr.getUserData(account, "ocURI");
|
||||||
|
if (ocURI == null) {
|
||||||
|
// @TODO: Handle the problem
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Uri serverURI = Uri.parse(ocURI);
|
||||||
|
|
||||||
|
final OCSMSOwnCloudClient _client = new OCSMSOwnCloudClient(getBaseContext(),
|
||||||
|
serverURI, _accountMgr.getUserData(account, "ocLogin"),
|
||||||
|
_accountMgr.getPassword(account));
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (_client.getServerAPIVersion() < 2) {
|
||||||
|
// @TODO: handle error
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (final OCSyncException e) {
|
||||||
|
// @TODO: handle error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user