CityObj.java revision ef08487b5fec499811774e78ac0e556634ebd29a
1/*
2 * Copyright (C) 2012 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.deskclock.worldclock;
18
19import android.content.SharedPreferences;
20import android.os.Parcel;
21import android.os.Parcelable;
22import android.util.Log;
23import android.view.View;
24
25import java.util.ArrayList;
26import java.util.HashSet;
27import java.util.Set;
28
29public class CityObj {
30
31    private static final String TAG = "CityObj";
32    private static final String CITY_NAME = "city_name_";
33    private static final String CITY_TIME_ZONE = "city_tz_";
34    private static final String CITY_ID = "city_id_";
35
36    public String mCityName;
37    public String mTimeZone;
38    public String mCityId;
39
40    public CityObj(String name, String timezone, String id) {
41        mCityName = name;
42        mTimeZone = timezone;
43        mCityId = id;
44    }
45
46
47    public CityObj(SharedPreferences prefs, int index) {
48        mCityName = prefs.getString(CITY_NAME + index, null);
49        mTimeZone = prefs.getString(CITY_TIME_ZONE + index, null);
50        mCityId = prefs.getString(CITY_ID + index, null);
51    }
52
53    public void saveCityToSharedPrefs(SharedPreferences.Editor editor, int index) {
54        editor.putString (CITY_NAME + index, mCityName);
55        editor.putString (CITY_TIME_ZONE + index, mTimeZone);
56        editor.putString (CITY_ID + index, mCityId);
57    }
58
59}
60