blob: def5036ae18d3373aa81d0a7fd91716468102d1e [file] [log] [blame]
The Android Open Source Projectde2d9f52008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings;
18
19import android.app.ListActivity;
20import android.content.Intent;
21import android.os.Bundle;
22import android.view.View;
23import android.widget.ArrayAdapter;
24import android.widget.ListView;
25
26import java.util.HashMap;
27import java.util.List;
28import java.util.Map;
29
30public class ZonePicker extends ListActivity {
31
32 private ArrayAdapter<CharSequence> mFilterAdapter;
33
34 @Override
35 public void onCreate(Bundle icicle) {
36 super.onCreate(icicle);
37 mFilterAdapter = ArrayAdapter.createFromResource(this,
38 R.array.timezone_filters, android.R.layout.simple_list_item_1);
39 setListAdapter(mFilterAdapter);
40 }
41
42 protected void addItem(List<Map> data, String name, String zone) {
43 HashMap temp = new HashMap();
44 temp.put("title", name);
45 temp.put("zone", zone);
46 data.add(temp);
47 }
48
49 @Override
50 protected void onListItemClick(ListView l, View v, int position, long id) {
51 String filter = (String) mFilterAdapter.getItem(position);
52 // If All is chosen, reset the filter
53 if (filter.equals("All")) {
54 filter = null;
55 }
56 Intent zoneList = new Intent();
57 zoneList.setClass(this, ZoneList.class);
58 zoneList.putExtra("filter", filter);
59
60 startActivityForResult(zoneList, 0);
61 }
62
63 @Override
64 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
65 // If subactivity has resulted in a timezone selection, close this act.
66 if (resultCode == RESULT_OK) {
67 finish();
68 }
69 }
70}