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 
17 package com.android.deskclock.worldclock;
18 
19 import android.content.SharedPreferences;
20 
21 public class CityObj {
22 
23     private static final String CITY_NAME = "city_name_";
24     private static final String CITY_TIME_ZONE = "city_tz_";
25     private static final String CITY_ID = "city_id_";
26 
27     public String mCityName;
28     public String mTimeZone;
29     public String mCityId;
30     public boolean isHeader;
31 
CityObj(String name, String timezone, String id)32     public CityObj(String name, String timezone, String id) {
33         mCityName = name;
34         mTimeZone = timezone;
35         mCityId = id;
36     }
37 
38     @Override
toString()39     public String toString() {
40         return "CityObj{" +
41                 "name=" + mCityName +
42                 ", timezone=" + mTimeZone +
43                 ", id=" + mCityId +
44                 '}';
45     }
46 
CityObj(SharedPreferences prefs, int index)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 
saveCityToSharedPrefs(SharedPreferences.Editor editor, int index)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