summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorSam Blitzstein <sblitz@google.com>2013-04-23 11:17:47 -0700
committerSam Blitzstein <sblitz@google.com>2013-04-26 00:31:38 -0700
commit96e8dde991e426d0cd44f5b4eb76118fd7374ac0 (patch)
tree09718a593ba5c78bd2ac5a5b98cc5f1b916645be /src/com/android
parent68b7501838847263cd6adf78cd1bec6b90393db9 (diff)
downloadandroid_frameworks_opt_timezonepicker-96e8dde991e426d0cd44f5b4eb76118fd7374ac0.tar.gz
android_frameworks_opt_timezonepicker-96e8dde991e426d0cd44f5b4eb76118fd7374ac0.tar.bz2
android_frameworks_opt_timezonepicker-96e8dde991e426d0cd44f5b4eb76118fd7374ac0.zip
Remove any empty space by resizing the dialog dynamically.
Also a few small bug fixes and tweaks. Bug: 8697117 Change-Id: If6e4f77df8e5c1cb09dddc4da5105ec050181c55
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/timezonepicker/TimeZoneData.java6
-rw-r--r--src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java9
-rw-r--r--src/com/android/timezonepicker/TimeZoneResultAdapter.java10
3 files changed, 21 insertions, 4 deletions
diff --git a/src/com/android/timezonepicker/TimeZoneData.java b/src/com/android/timezonepicker/TimeZoneData.java
index c6eeeaa..6ef0e01 100644
--- a/src/com/android/timezonepicker/TimeZoneData.java
+++ b/src/com/android/timezonepicker/TimeZoneData.java
@@ -267,7 +267,11 @@ public class TimeZoneData {
for (int i = 0; i < length; i++) {
TimeZoneInfo tzi = mTimeZonesById.get(ids[i]);
- tzi.mDisplayName = labels[i];
+ if (tzi != null) {
+ tzi.mDisplayName = labels[i];
+ } else {
+ Log.e(TAG, "Could not find timezone with label: "+labels[i]);
+ }
}
}
diff --git a/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java b/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
index fab1e8a..31317d1 100644
--- a/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
+++ b/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
@@ -262,9 +262,9 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
* and symbols).
*
* For example:
- * isStartingInitialsFor("UA", "United Arb Emirates") would return true
+ * isStartingInitialsFor("UA", "United Arab Emirates") would return true
* isStartingInitialsFor("US", "U.S. Virgin Island") would return true
-
+ *
* @param prefixString
* @param string
* @return
@@ -291,6 +291,11 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
wasWordBreak = false;
}
}
+
+ // Special case for "USA". Note that both strings have been turned to lowercase already.
+ if (prefixString.equals("usa") && string.equals("united states")) {
+ return true;
+ }
return false;
}
diff --git a/src/com/android/timezonepicker/TimeZoneResultAdapter.java b/src/com/android/timezonepicker/TimeZoneResultAdapter.java
index efc275e..4708ad9 100644
--- a/src/com/android/timezonepicker/TimeZoneResultAdapter.java
+++ b/src/com/android/timezonepicker/TimeZoneResultAdapter.java
@@ -40,6 +40,7 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
private static final String TAG = "TimeZoneResultAdapter";
private static final boolean DEBUG = false;
private static final int VIEW_TAG_TIME_ZONE = R.id.time_zone;
+ private static final int EMPTY_INDEX = -100;
/** SharedPref name and key for recent time zones */
private static final String SHARED_PREFS_NAME = "com.android.calendar_preferences";
@@ -130,6 +131,7 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
switch (filterType) {
case TimeZoneFilterTypeAdapter.FILTER_TYPE_EMPTY:
+ mFilteredTimeZoneIndices[mFilteredTimeZoneLength++] = EMPTY_INDEX;
break;
case TimeZoneFilterTypeAdapter.FILTER_TYPE_NONE:
// Show the default/current value first
@@ -265,7 +267,13 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
- if (v == null) {
+ if (mFilteredTimeZoneIndices[position] == EMPTY_INDEX) {
+ v = mInflater.inflate(R.layout.empty_time_zone_item, null);
+ return v;
+ }
+
+ // We'll need to re-inflate the view if it was null, or if it was used as an empty item.
+ if (v == null || v.findViewById(R.id.empty_item) != null) {
v = mInflater.inflate(R.layout.time_zone_item, null);
ViewHolder.setupViewHolder(v);
}