1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2025-06-22 07:16:38 +00:00

Refresh layout for phone list is now okay

This commit is contained in:
Loic Blot 2015-08-09 23:40:52 +02:00
parent d0bd844c48
commit c733997aaa
2 changed files with 22 additions and 10 deletions

View File

@ -1,5 +1,6 @@
package fr.unix_experience.owncloud_sms.activities.remote_account; package fr.unix_experience.owncloud_sms.activities.remote_account;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import android.accounts.Account; import android.accounts.Account;
@ -19,6 +20,7 @@ public class ContactListActivity extends ListActivity implements ASyncContactLoa
static AccountManager _accountMgr; static AccountManager _accountMgr;
ContactListAdapter adapter; ContactListAdapter adapter;
SwipeRefreshLayout _layout; SwipeRefreshLayout _layout;
ArrayList<String> objects;
@Override @Override
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
@ -36,11 +38,11 @@ public class ContactListActivity extends ListActivity implements ASyncContactLoa
_accountMgr.getAccountsByType(getString(R.string.account_type)); _accountMgr.getAccountsByType(getString(R.string.account_type));
// Init view // Init view
ArrayList<String> objects = new ArrayList<String>(); objects = new ArrayList<String>();
setContentView(R.layout.restore_activity_contactlist); setContentView(R.layout.restore_activity_contactlist);
_layout = (SwipeRefreshLayout) findViewById(R.id.contactlist_swipe_container); _layout = (SwipeRefreshLayout) findViewById(R.id.contactlist_swipe_container);
//_layout.setOnRefreshListener(this);
_layout.setColorScheme(android.R.color.holo_blue_bright, _layout.setColorScheme(android.R.color.holo_blue_bright,
android.R.color.holo_green_light, android.R.color.holo_green_light,
android.R.color.holo_orange_light, android.R.color.holo_orange_light,
@ -56,17 +58,25 @@ public class ContactListActivity extends ListActivity implements ASyncContactLoa
for (final Account element : myAccountList) { for (final Account element : myAccountList) {
if (element.name.equals(accountName)) { if (element.name.equals(accountName)) {
// Load "contacts"
new ContactLoadTask(element, getBaseContext(), adapter, objects).execute(); new ContactLoadTask(element, getBaseContext(), adapter, objects).execute();
// Add refresh handler
_layout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
_layout.setRefreshing(true);
(new Handler()).postDelayed(new Runnable() {
@Override
public void run() {
_layout.setRefreshing(false);
new ContactLoadTask(element, getBaseContext(), adapter, objects).execute();
}
}, 3000);
}
});
return; return;
} }
} }
} }
/*@Override public void onRefresh() {
new Handler().postDelayed(new Runnable() {
@Override public void run() {
_layout.setRefreshing(false);
}
}, 5000);
}*/
} }

View File

@ -50,6 +50,8 @@ public interface ASyncContactLoad {
serverURI, _accountMgr.getUserData(_account, "ocLogin"), serverURI, _accountMgr.getUserData(_account, "ocLogin"),
_accountMgr.getPassword(_account)); _accountMgr.getPassword(_account));
// Remove all objects, due to refreshing handling
_objects.clear();
try { try {
if (_client.getServerAPIVersion() < 2) { if (_client.getServerAPIVersion() < 2) {
_objects.add(_context.getString(R.string.err_proto_v2)); _objects.add(_context.getString(R.string.err_proto_v2));