Code formatting fixes.
Bug: 7413861
Change-Id: Ia5207e830c8bddf47469ed6b9769cdc98c82b1a2
diff --git a/src/com/android/alarmclock/DigitalWidgetViewsFactory.java b/src/com/android/alarmclock/DigitalWidgetViewsFactory.java
index dea9aab..5522122 100644
--- a/src/com/android/alarmclock/DigitalWidgetViewsFactory.java
+++ b/src/com/android/alarmclock/DigitalWidgetViewsFactory.java
@@ -91,7 +91,7 @@
now.setTimeInMillis(System.currentTimeMillis());
int myDayOfWeek = now.get(Calendar.DAY_OF_WEEK);
CityObj cityInDb = mCitiesDb.get(cityObj.mCityId);
- String cityTZ = (cityInDb != null) ? cityInDb.mTimeZone:cityObj.mTimeZone;
+ String cityTZ = (cityInDb != null) ? cityInDb.mTimeZone : cityObj.mTimeZone;
now.setTimeZone(TimeZone.getTimeZone(cityTZ));
int cityDayOfWeek = now.get(Calendar.DAY_OF_WEEK);
@@ -101,11 +101,7 @@
clock.setString(clockId2, "setTimeZone", cityObj.mTimeZone);
// Home city or city not in DB , use data from the save selected cities list
- if (cityObj.mCityId == null || cityInDb == null) {
- clock.setTextViewText(labelId, cityObj.mCityName);
- }else {
- clock.setTextViewText(labelId, cityInDb.mCityName);
- }
+ clock.setTextViewText(labelId, Utils.getCityName(cityObj, cityInDb));
if (myDayOfWeek != cityDayOfWeek) {
clock.setTextViewText(dayId, mContext.getString(
diff --git a/src/com/android/deskclock/Utils.java b/src/com/android/deskclock/Utils.java
index 688f3b7..d922cda 100644
--- a/src/com/android/deskclock/Utils.java
+++ b/src/com/android/deskclock/Utils.java
@@ -400,18 +400,18 @@
Resources r = c.getResources();
// Read strings array of name,timezone, id
// make sure the list are the same length
- String [] cities = r.getStringArray(R.array.cities_names);
- String [] timezones = r.getStringArray(R.array.cities_tz);
- String [] ids = r.getStringArray(R.array.cities_id);
+ String[] cities = r.getStringArray(R.array.cities_names);
+ String[] timezones = r.getStringArray(R.array.cities_tz);
+ String[] ids = r.getStringArray(R.array.cities_id);
if (cities.length != timezones.length || ids.length != cities.length) {
Log.wtf("City lists sizes are not the same, cannot use the data");
return null;
- }
- CityObj[] tempList = new CityObj [cities.length];
- for (int i = 0; i < cities.length; i++) {
+ }
+ CityObj[] tempList = new CityObj[cities.length];
+ for (int i = 0; i < cities.length; i++) {
tempList[i] = new CityObj(cities[i], timezones[i], ids[i]);
- }
- // Sort alphabetically
+ }
+ // Sort alphabetically
Arrays.sort(tempList, new Comparator<CityObj> () {
@Override
public int compare(CityObj c1, CityObj c2) {
@@ -421,4 +421,8 @@
});
return tempList;
}
+
+ public static String getCityName(CityObj city, CityObj dbCity) {
+ return (city.mCityId == null || dbCity == null) ? city.mCityName : dbCity.mCityName;
+ }
}
diff --git a/src/com/android/deskclock/worldclock/CitiesActivity.java b/src/com/android/deskclock/worldclock/CitiesActivity.java
index 76a9b4b..02423b5 100644
--- a/src/com/android/deskclock/worldclock/CitiesActivity.java
+++ b/src/com/android/deskclock/worldclock/CitiesActivity.java
@@ -92,7 +92,7 @@
@Override
public int getCount() {
- return (mAllTheCitiesList != null) ? mAllTheCitiesList.length: 0;
+ return (mAllTheCitiesList != null) ? mAllTheCitiesList.length : 0;
}
@Override
@@ -191,7 +191,8 @@
public int getSectionForPosition(int p) {
if (mSectionPositions != null) {
for (int i = 0; i < mSectionPositions.length - 1; i++) {
- if (p >= (Integer)mSectionPositions[i] && p < (Integer)mSectionPositions[i + 1]) {
+ if (p >= (Integer) mSectionPositions[i]
+ && p < (Integer) mSectionPositions[i + 1]) {
return i;
}
}
diff --git a/src/com/android/deskclock/worldclock/WorldClockAdapter.java b/src/com/android/deskclock/worldclock/WorldClockAdapter.java
index 7f3574f..ac94d48 100644
--- a/src/com/android/deskclock/worldclock/WorldClockAdapter.java
+++ b/src/com/android/deskclock/worldclock/WorldClockAdapter.java
@@ -75,7 +75,7 @@
// Read the cities DB so that the names and timezones will be taken from the DB
// and not from the selected list so that change of locale or changes in the DB will
// be reflected.
- CityObj [] cities = Utils.loadCitiesDataBase(context);
+ CityObj[] cities = Utils.loadCitiesDataBase(context);
if (cities != null) {
for (int i = 0; i < cities.length; i ++) {
mCitiesDb.put(cities[i].mCityId, cities [i]);
@@ -239,16 +239,13 @@
}
CityObj cityInDb = mCitiesDb.get(cityObj.mCityId);
// Home city or city not in DB , use data from the save selected cities list
- if (cityObj.mCityId == null || cityInDb == null) {
- name.setText(cityObj.mCityName);
- }else {
- name.setText(cityInDb.mCityName);
- }
+ name.setText(Utils.getCityName(cityObj, cityInDb));
+
final Calendar now = Calendar.getInstance();
now.setTimeZone(TimeZone.getDefault());
int myDayOfWeek = now.get(Calendar.DAY_OF_WEEK);
// Get timezone from cities DB if available
- String cityTZ = (cityInDb != null) ? cityInDb.mTimeZone:cityObj.mTimeZone;
+ String cityTZ = (cityInDb != null) ? cityInDb.mTimeZone : cityObj.mTimeZone;
now.setTimeZone(TimeZone.getTimeZone(cityTZ));
int cityDayOfWeek = now.get(Calendar.DAY_OF_WEEK);
if (myDayOfWeek != cityDayOfWeek) {