mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2026-08-21 21:32:58 +00:00
Remote account interface improvements
This commit is contained in:
+6
-8
@@ -43,7 +43,7 @@ public class ContactListActivity extends Activity implements ASyncContactLoad {
|
||||
ContactListActivity._accountMgr = AccountManager.get(getBaseContext());
|
||||
Account[] myAccountList =
|
||||
ContactListActivity._accountMgr.getAccountsByType(getString(R.string.account_type));
|
||||
|
||||
|
||||
// Init view
|
||||
objects = new ArrayList<>();
|
||||
setContentView(R.layout.restore_activity_contactlist);
|
||||
@@ -54,19 +54,18 @@ public class ContactListActivity extends Activity implements ASyncContactLoad {
|
||||
android.R.color.holo_green_light,
|
||||
android.R.color.holo_orange_light,
|
||||
android.R.color.holo_red_light);
|
||||
|
||||
|
||||
adapter = new ContactListAdapter(getBaseContext(),
|
||||
android.R.layout.simple_spinner_item,
|
||||
objects,
|
||||
R.layout.contact_list_item,
|
||||
R.id.contactname, this);
|
||||
|
||||
|
||||
final Spinner sp = (Spinner) findViewById(R.id.contact_spinner);
|
||||
final LinearLayout contactInfos = (LinearLayout) findViewById(R.id.contactinfos_layout);
|
||||
final ProgressBar contactProgressBar = (ProgressBar) findViewById(R.id.contactlist_pgbar);
|
||||
final TextView contactPhoneList = (TextView) findViewById(R.id.contact_phonelist);
|
||||
|
||||
sp.setVisibility(View.INVISIBLE);
|
||||
contactInfos.setVisibility(View.INVISIBLE);
|
||||
|
||||
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@@ -139,22 +138,21 @@ public class ContactListActivity extends Activity implements ASyncContactLoad {
|
||||
if (element.name.equals(accountName)) {
|
||||
// Load "contacts"
|
||||
contactProgressBar.setVisibility(View.VISIBLE);
|
||||
sp.setVisibility(View.INVISIBLE);
|
||||
new ContactLoadTask(element, getBaseContext(), adapter, objects, _layout, contactProgressBar, sp).execute();
|
||||
new ContactLoadTask(element, getBaseContext(), adapter, objects, _layout, contactProgressBar, contactInfos).execute();
|
||||
|
||||
// Add refresh handler
|
||||
_layout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
_layout.setRefreshing(true);
|
||||
sp.setVisibility(View.INVISIBLE);
|
||||
contactInfos.setVisibility(View.INVISIBLE);
|
||||
contactProgressBar.setVisibility(View.VISIBLE);
|
||||
(new Handler()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
objects.clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
new ContactLoadTask(element, getBaseContext(), adapter, objects, _layout, contactProgressBar, sp).execute();
|
||||
new ContactLoadTask(element, getBaseContext(), adapter, objects, _layout, contactProgressBar, contactInfos).execute();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import android.os.AsyncTask;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -32,11 +32,11 @@ public interface ASyncContactLoad {
|
||||
private final ArrayList<String> _objects;
|
||||
private final SwipeRefreshLayout _layout;
|
||||
private final ProgressBar _pg;
|
||||
private final Spinner _contactSpinner;
|
||||
private final LinearLayout _contactLayout;
|
||||
|
||||
public ContactLoadTask(Account account, Context context,
|
||||
ContactListAdapter adapter, ArrayList<String> objects, SwipeRefreshLayout layout,
|
||||
ProgressBar pg, Spinner sp) {
|
||||
ProgressBar pg, LinearLayout sp) {
|
||||
if (ContactLoadTask._accountMgr == null) {
|
||||
ContactLoadTask._accountMgr = AccountManager.get(context);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public interface ASyncContactLoad {
|
||||
_objects = objects;
|
||||
_layout = layout;
|
||||
_pg = pg;
|
||||
_contactSpinner = sp;
|
||||
_contactLayout = sp;
|
||||
}
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
@@ -141,8 +141,8 @@ public interface ASyncContactLoad {
|
||||
_pg.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if (_contactSpinner != null) {
|
||||
_contactSpinner.setVisibility(View.VISIBLE);
|
||||
if (_contactLayout != null) {
|
||||
_contactLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user