aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2009-06-10 16:34:57 +0000
committerKenny Root <kenny@the-b.org>2009-06-10 16:34:57 +0000
commitc2646e8120c71d6bb0695da070547a193c485cb6 (patch)
treee16588c1e5444b4170a10095d0a12b1904c64f24
parent5730cd751eba90d5bb33babb41425586dbcc30b1 (diff)
downloadconnectbot-c2646e8120c71d6bb0695da070547a193c485cb6.tar.gz
connectbot-c2646e8120c71d6bb0695da070547a193c485cb6.tar.bz2
connectbot-c2646e8120c71d6bb0695da070547a193c485cb6.zip
Remove some allocations from the ListAdapter image state setting
git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@279 df292f66-193f-0410-a5fc-6d59da041ff2
-rw-r--r--src/org/connectbot/HostListActivity.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/org/connectbot/HostListActivity.java b/src/org/connectbot/HostListActivity.java
index 571780d..7f36eb7 100644
--- a/src/org/connectbot/HostListActivity.java
+++ b/src/org/connectbot/HostListActivity.java
@@ -342,10 +342,8 @@ public class HostListActivity extends ListActivity {
help.setIntent(new Intent(HostListActivity.this, HelpActivity.class));
return true;
-
}
-
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
@@ -442,6 +440,10 @@ public class HostListActivity extends ListActivity {
public final static int STATE_UNKNOWN = 1, STATE_CONNECTED = 2, STATE_DISCONNECTED = 3;
+ private final int[] stateChecked;
+ private final int[] stateExpanded;
+ private final int[] stateNone;
+
class ViewHolder {
public TextView nickname;
public TextView caption;
@@ -457,6 +459,10 @@ public class HostListActivity extends ListActivity {
red = context.getResources().getColorStateList(R.color.red);
green = context.getResources().getColorStateList(R.color.green);
blue = context.getResources().getColorStateList(R.color.blue);
+
+ stateNone = new int[] { };
+ stateChecked = new int[] { android.R.attr.state_checked };
+ stateExpanded = new int[] { android.R.attr.state_expanded };
}
/**
@@ -507,13 +513,13 @@ public class HostListActivity extends ListActivity {
switch (this.getConnectedState(host)) {
case STATE_UNKNOWN:
- holder.icon.setImageState(new int[] { }, true);
+ holder.icon.setImageState(stateNone, true);
break;
case STATE_CONNECTED:
- holder.icon.setImageState(new int[] { android.R.attr.state_checked }, true);
+ holder.icon.setImageState(stateChecked, true);
break;
case STATE_DISCONNECTED:
- holder.icon.setImageState(new int[] { android.R.attr.state_expanded }, true);
+ holder.icon.setImageState(stateExpanded, true);
break;
}