summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorJames Kung <kingkung@google.com>2013-04-15 16:53:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-04-15 16:53:01 +0000
commitff072e1dd75b339efcfbba22e8f14096a6c112cc (patch)
tree317e17a5c6bd4de4e8a570f7714c3b28b9a2ff76 /src/com/android
parentc297924da6427a460045e892a2b829e9a021a6c4 (diff)
parent852a8427f0ba0790fa2b7fd1bddba374f03953c6 (diff)
downloadandroid_frameworks_opt_timezonepicker-ff072e1dd75b339efcfbba22e8f14096a6c112cc.tar.gz
android_frameworks_opt_timezonepicker-ff072e1dd75b339efcfbba22e8f14096a6c112cc.tar.bz2
android_frameworks_opt_timezonepicker-ff072e1dd75b339efcfbba22e8f14096a6c112cc.zip
Merge "Removing headers from all filter types" into jb-mr2-dev
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java154
-rw-r--r--src/com/android/timezonepicker/TimeZoneResultAdapter.java18
2 files changed, 10 insertions, 162 deletions
diff --git a/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java b/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
index c08f073..65bd530 100644
--- a/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
+++ b/src/com/android/timezonepicker/TimeZoneFilterTypeAdapter.java
@@ -35,10 +35,9 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
public static final int FILTER_TYPE_EMPTY = -1;
public static final int FILTER_TYPE_NONE = 0;
- public static final int FILTER_TYPE_TIME = 1;
- public static final int FILTER_TYPE_COUNTRY = 2;
- public static final int FILTER_TYPE_STATE = 3;
- public static final int FILTER_TYPE_GMT = 4;
+ public static final int FILTER_TYPE_COUNTRY = 1;
+ public static final int FILTER_TYPE_STATE = 2;
+ public static final int FILTER_TYPE_GMT = 3;
public interface OnSetFilterListener {
void onSetFilter(int filterType, String str, int time);
@@ -48,26 +47,21 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
int filterType;
String str;
int time;
-
- TextView typeTextView;
TextView strTextView;
static void setupViewHolder(View v) {
ViewHolder vh = new ViewHolder();
- vh.typeTextView = (TextView) v.findViewById(R.id.type);
vh.strTextView = (TextView) v.findViewById(R.id.value);
v.setTag(vh);
}
}
class FilterTypeResult {
- boolean showLabel;
int type;
String constraint;
public int time;
- public FilterTypeResult(boolean showLabel, int type, String constraint, int time) {
- this.showLabel = showLabel;
+ public FilterTypeResult(int type, String constraint, int time) {
this.type = type;
this.constraint = constraint;
this.time = time;
@@ -96,16 +90,6 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
}
@Override
- public boolean areAllItemsEnabled() {
- return false;
- }
-
- @Override
- public boolean isEnabled(int position) {
- return !mLiveResults.get(position).showLabel;
- }
-
- @Override
public int getCount() {
return mLiveResultsCount;
}
@@ -142,29 +126,6 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
vh.filterType = filter.type;
vh.str = filter.constraint;
vh.time = filter.time;
-
- if (filter.showLabel) {
- int resId;
- switch (filter.type) {
- case FILTER_TYPE_GMT:
- resId = R.string.gmt_offset;
- break;
- case FILTER_TYPE_TIME:
- resId = R.string.local_time;
- break;
- case FILTER_TYPE_COUNTRY:
- resId = R.string.country;
- break;
- default:
- throw new IllegalArgumentException();
- }
- vh.typeTextView.setText(resId);
- vh.typeTextView.setVisibility(View.VISIBLE);
- vh.strTextView.setVisibility(View.GONE);
- } else {
- vh.typeTextView.setVisibility(View.GONE);
- vh.strTextView.setVisibility(View.VISIBLE);
- }
vh.strTextView.setText(filter.constraint);
return v;
}
@@ -239,17 +200,11 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
boolean positiveOnly = prefixString.length() > startParsePosition
&& prefixString.charAt(startParsePosition) == '+';
handleSearchByGmt(filtered, num, positiveOnly);
-
- // Search by time
- if (!gmtOnly) {
- handleSearchByTime(filtered, num);
- }
}
// ////////////////////////////////////////
// Search by country
// ////////////////////////////////////////
- boolean first = true;
for (String country : mTimeZoneData.mTimeZonesByCountry.keySet()) {
// TODO Perf - cache toLowerCase()?
if (!TextUtils.isEmpty(country)) {
@@ -257,32 +212,12 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
if (lowerCaseCountry.startsWith(prefixString)
|| (lowerCaseCountry.charAt(0) == prefixString.charAt(0) &&
isStartingInitialsFor(prefixString, lowerCaseCountry))) {
- FilterTypeResult r;
- r = new FilterTypeResult(false, FILTER_TYPE_COUNTRY, country, 0);
- filtered.add(r);
+ filtered.add(new FilterTypeResult(FILTER_TYPE_COUNTRY, country, 0));
}
}
}
// ////////////////////////////////////////
- // Search by time zone name
- // ////////////////////////////////////////
-// first = true;
-// for (String timeZoneName : mTimeZoneData.mTimeZoneNames) {
-// // TODO Perf - cache toLowerCase()?
-// if (timeZoneName.toLowerCase().startsWith(prefixString)) {
-// FilterTypeResult r;
-// if (first) {
-// r = new FilterTypeResult(true, FILTER_TYPE_TIME_ZONE, null, 0);
-// filtered.add(r);
-// first = false;
-// }
-// r = new FilterTypeResult(false, FILTER_TYPE_TIME_ZONE, timeZoneName, 0);
-// filtered.add(r);
-// }
-// }
-
- // ////////////////////////////////////////
// TODO Search by state
// ////////////////////////////////////////
Log.e(TAG, "performFiltering <<<< " + filtered.size() + "[" + prefix + "]");
@@ -331,85 +266,22 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
return false;
}
- /**
- * @param filtered
- * @param num
- */
- private void handleSearchByTime(ArrayList<FilterTypeResult> filtered, int num) {
- int originalResultCount = filtered.size();
- // Separator
- FilterTypeResult r = new FilterTypeResult(true, FILTER_TYPE_TIME, null, 0);
- filtered.add(r);
-
- long now = System.currentTimeMillis();
-
- boolean[] hasTz = new boolean[24];
-
- // TODO make this faster
- for (TimeZoneInfo tzi : mTimeZoneData.mTimeZones) {
- int localHr = tzi.getLocalHr(now);
- hasTz[localHr] = true;
- }
-
- if (hasTz[num]) {
- r = new FilterTypeResult(false, FILTER_TYPE_TIME,
- Integer.toString(num), num);
- filtered.add(r);
- }
-
- int start = Integer.MAX_VALUE;
- int end = Integer.MIN_VALUE;
- if (TimeZoneData.is24HourFormat) {
- switch (num) {
- case 1:
- start = 10;
- end = 23;
- break;
- case 2:
- start = 20;
- end = 23;
- break;
- }
- } else if (num == 1) {
- start = 10;
- end = 12;
- }
-
- for (int i = start; i < end; i++) {
- if (hasTz[i]) {
- r = new FilterTypeResult(false, FILTER_TYPE_TIME,
- Integer.toString(i), i);
- filtered.add(r);
- }
- }
-
- // Nothing was added except for the separator. Let's remove it.
- if (filtered.size() == originalResultCount + 1) {
- filtered.remove(originalResultCount);
- }
- }
-
private void handleSearchByGmt(ArrayList<FilterTypeResult> filtered, int num,
boolean positiveOnly) {
- FilterTypeResult r;
- int originalResultCount = filtered.size();
-
- // Separator
- r = new FilterTypeResult(true, FILTER_TYPE_GMT, null, 0);
- filtered.add(r);
+ FilterTypeResult r;
if (num >= 0) {
if (num == 1) {
for (int i = 19; i >= 10; i--) {
if (mTimeZoneData.hasTimeZonesInHrOffset(i)) {
- r = new FilterTypeResult(false, FILTER_TYPE_GMT, "GMT+" + i, i);
+ r = new FilterTypeResult(FILTER_TYPE_GMT, "GMT+" + i, i);
filtered.add(r);
}
}
}
if (mTimeZoneData.hasTimeZonesInHrOffset(num)) {
- r = new FilterTypeResult(false, FILTER_TYPE_GMT, "GMT+" + num, num);
+ r = new FilterTypeResult(FILTER_TYPE_GMT, "GMT+" + num, num);
filtered.add(r);
}
num *= -1;
@@ -417,25 +289,19 @@ public class TimeZoneFilterTypeAdapter extends BaseAdapter implements Filterable
if (!positiveOnly && num != 0) {
if (mTimeZoneData.hasTimeZonesInHrOffset(num)) {
- r = new FilterTypeResult(false, FILTER_TYPE_GMT, "GMT" + num, num);
+ r = new FilterTypeResult(FILTER_TYPE_GMT, "GMT" + num, num);
filtered.add(r);
}
if (num == -1) {
for (int i = -10; i >= -19; i--) {
if (mTimeZoneData.hasTimeZonesInHrOffset(i)) {
- r = new FilterTypeResult(false, FILTER_TYPE_GMT, "GMT" + i, i);
+ r = new FilterTypeResult(FILTER_TYPE_GMT, "GMT" + i, i);
filtered.add(r);
}
}
}
}
-
- // Nothing was added except for the separator. Let's remove it.
- if (filtered.size() == originalResultCount + 1) {
- filtered.remove(originalResultCount);
- }
- return;
}
/**
diff --git a/src/com/android/timezonepicker/TimeZoneResultAdapter.java b/src/com/android/timezonepicker/TimeZoneResultAdapter.java
index 3000602..2b57f39 100644
--- a/src/com/android/timezonepicker/TimeZoneResultAdapter.java
+++ b/src/com/android/timezonepicker/TimeZoneResultAdapter.java
@@ -135,24 +135,6 @@ public class TimeZoneResultAdapter extends BaseAdapter implements OnItemClickLis
}
}
break;
- case TimeZoneFilterTypeAdapter.FILTER_TYPE_TIME:
- // TODO make this faster
- long now = System.currentTimeMillis();
- for (TimeZoneInfo tzi : mTimeZoneData.mTimeZones) {
- int localHr = tzi.getLocalHr(now);
- boolean match = localHr == time;
- if (!match && !TimeZoneData.is24HourFormat) {
- // PM + noon cases
- if ((time + 12 == localHr) || (time == 12 && localHr == 0)) {
- match = true;
- }
- }
- if (match) {
- mFilteredTimeZoneIndices[mFilteredTimeZoneLength++] = idx;
- }
- idx++;
- }
- break;
case TimeZoneFilterTypeAdapter.FILTER_TYPE_COUNTRY:
ArrayList<Integer> tzIds = mTimeZoneData.mTimeZonesByCountry.get(str);
if (tzIds != null) {