1948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson/* 2948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * Copyright (C) 2012 The Android Open Source Project 3948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * 4948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * Licensed under the Apache License, Version 2.0 (the "License"); 5948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * you may not use this file except in compliance with the License. 6948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * You may obtain a copy of the License at 7948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * 8948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * http://www.apache.org/licenses/LICENSE-2.0 9948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * 10948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * Unless required by applicable law or agreed to in writing, software 11948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * distributed under the License is distributed on an "AS IS" BASIS, 12948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * See the License for the specific language governing permissions and 14948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson * limitations under the License. 15948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson */ 16948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 17948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelsonpackage com.android.deskclock.worldclock; 18948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 19948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelsonimport android.content.SharedPreferences; 20948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 21948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelsonpublic class CityObj { 22948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 23948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson private static final String CITY_NAME = "city_name_"; 24948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson private static final String CITY_TIME_ZONE = "city_tz_"; 25ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson private static final String CITY_ID = "city_id_"; 26948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 27948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson public String mCityName; 28948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson public String mTimeZone; 29ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson public String mCityId; 3057cb1dbcead54ff08e8f07e727d0b1c842301440rachelzhang public boolean isHeader; 31948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 32ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson public CityObj(String name, String timezone, String id) { 33948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson mCityName = name; 34948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson mTimeZone = timezone; 35ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson mCityId = id; 36948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson } 37948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 38421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas @Override 39421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas public String toString() { 40421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas return "CityObj{" + 41421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas "name=" + mCityName + 42421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas ", timezone=" + mTimeZone + 43421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas ", id=" + mCityId + 44421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas '}'; 45421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas } 46421ad69ae79290b1ccca6316217b0ffdc48ac377Robyn Coultas 47ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson public CityObj(SharedPreferences prefs, int index) { 48ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson mCityName = prefs.getString(CITY_NAME + index, null); 49ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson mTimeZone = prefs.getString(CITY_TIME_ZONE + index, null); 50ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson mCityId = prefs.getString(CITY_ID + index, null); 51948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson } 52948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson 53ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson public void saveCityToSharedPrefs(SharedPreferences.Editor editor, int index) { 54ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson editor.putString (CITY_NAME + index, mCityName); 55ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson editor.putString (CITY_TIME_ZONE + index, mTimeZone); 56ef08487b5fec499811774e78ac0e556634ebd29aIsaac Katzenelson editor.putString (CITY_ID + index, mCityId); 57948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson } 58948edb548f26c6aef3d918d01d80ea37570da41dIsaac Katzenelson} 59