From a048161b7f241741e4ef75dbfaae75bd8ba5f241 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Mon, 21 Jan 2013 13:30:41 -0800 Subject: [PATCH] Bug 832773 - Fix Send Tab button enabling logic. r=rnewman a=nonlibxul --- .../activities/ClientRecordArrayAdapter.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mobile/android/base/sync/setup/activities/ClientRecordArrayAdapter.java b/mobile/android/base/sync/setup/activities/ClientRecordArrayAdapter.java index 4f57177499b9..64a1d0e7f3cd 100644 --- a/mobile/android/base/sync/setup/activities/ClientRecordArrayAdapter.java +++ b/mobile/android/base/sync/setup/activities/ClientRecordArrayAdapter.java @@ -24,7 +24,6 @@ public class ClientRecordArrayAdapter extends ArrayAdapter { public static final String LOG_TAG = "ClientRecArrayAdapter"; private boolean[] checkedItems; - private int numCheckedGUIDs; private SendTabActivity sendTabActivity; public ClientRecordArrayAdapter(Context context, @@ -37,7 +36,6 @@ public class ClientRecordArrayAdapter extends ArrayAdapter { public synchronized void setClientRecordList(final Collection clientRecordList) { this.clear(); this.checkedItems = new boolean[clientRecordList.size()]; - this.numCheckedGUIDs = 0; for (ClientRecord clientRecord : clientRecordList) { this.add(clientRecord); } @@ -72,10 +70,8 @@ public class ClientRecordArrayAdapter extends ArrayAdapter { } checkedItems[position] = checked; - numCheckedGUIDs += checked ? 1 : -1; - if (numCheckedGUIDs <= 0) { - sendTabActivity.enableSend(numCheckedGUIDs > 0); - } + sendTabActivity.enableSend(getNumCheckedGUIDs() > 0); + return true; } @@ -118,6 +114,11 @@ public class ClientRecordArrayAdapter extends ArrayAdapter { return row; } + /** + * Get list of checked GUIDs. + * + * @return non-null list. + */ public synchronized List getCheckedGUIDs() { final List guids = new ArrayList(); for (int i = 0; i < checkedItems.length; i++) { @@ -128,7 +129,18 @@ public class ClientRecordArrayAdapter extends ArrayAdapter { return guids; } + /** + * Get number of checked GUIDs. + * + * @return non-negative integer. + */ public synchronized int getNumCheckedGUIDs() { + int numCheckedGUIDs = 0; + for (int i = 0; i < checkedItems.length; i++) { + if (checkedItems[i]) { + numCheckedGUIDs += 1; + } + } return numCheckedGUIDs; }