Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java +17 −5 Original line number Original line Diff line number Diff line Loading @@ -36,6 +36,10 @@ import libcore.icu.ICU; public class DateView extends TextView { public class DateView extends TextView { private static final String TAG = "DateView"; private static final String TAG = "DateView"; private final Date mCurrentTime = new Date(); private SimpleDateFormat mDateFormat; private boolean mChangedLocale; private boolean mAttachedToWindow; private boolean mAttachedToWindow; private boolean mWindowVisible; private boolean mWindowVisible; private boolean mUpdating; private boolean mUpdating; Loading @@ -48,6 +52,9 @@ public class DateView extends TextView { || Intent.ACTION_TIME_CHANGED.equals(action) || Intent.ACTION_TIME_CHANGED.equals(action) || Intent.ACTION_TIMEZONE_CHANGED.equals(action) || Intent.ACTION_TIMEZONE_CHANGED.equals(action) || Intent.ACTION_LOCALE_CHANGED.equals(action)) { || Intent.ACTION_LOCALE_CHANGED.equals(action)) { if (Intent.ACTION_LOCALE_CHANGED.equals(action)) { mChangedLocale = true; } updateClock(); updateClock(); } } } } Loading Loading @@ -91,11 +98,16 @@ public class DateView extends TextView { } } protected void updateClock() { protected void updateClock() { if (mDateFormat == null || mChangedLocale) { final String dateFormat = getContext().getString(R.string.system_ui_date_pattern); final String dateFormat = getContext().getString(R.string.system_ui_date_pattern); final Locale l = Locale.getDefault(); final Locale l = Locale.getDefault(); String fmt = ICU.getBestDateTimePattern(dateFormat, l.toString()); final String fmt = ICU.getBestDateTimePattern(dateFormat, l.toString()); SimpleDateFormat sdf = new SimpleDateFormat(fmt, l); mDateFormat = new SimpleDateFormat(fmt, l); setText(sdf.format(new Date())); mChangedLocale = false; } mCurrentTime.setTime(System.currentTimeMillis()); setText(mDateFormat.format(mCurrentTime)); } } private boolean isVisible() { private boolean isVisible() { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/DateView.java +17 −5 Original line number Original line Diff line number Diff line Loading @@ -36,6 +36,10 @@ import libcore.icu.ICU; public class DateView extends TextView { public class DateView extends TextView { private static final String TAG = "DateView"; private static final String TAG = "DateView"; private final Date mCurrentTime = new Date(); private SimpleDateFormat mDateFormat; private boolean mChangedLocale; private boolean mAttachedToWindow; private boolean mAttachedToWindow; private boolean mWindowVisible; private boolean mWindowVisible; private boolean mUpdating; private boolean mUpdating; Loading @@ -48,6 +52,9 @@ public class DateView extends TextView { || Intent.ACTION_TIME_CHANGED.equals(action) || Intent.ACTION_TIME_CHANGED.equals(action) || Intent.ACTION_TIMEZONE_CHANGED.equals(action) || Intent.ACTION_TIMEZONE_CHANGED.equals(action) || Intent.ACTION_LOCALE_CHANGED.equals(action)) { || Intent.ACTION_LOCALE_CHANGED.equals(action)) { if (Intent.ACTION_LOCALE_CHANGED.equals(action)) { mChangedLocale = true; } updateClock(); updateClock(); } } } } Loading Loading @@ -91,11 +98,16 @@ public class DateView extends TextView { } } protected void updateClock() { protected void updateClock() { if (mDateFormat == null || mChangedLocale) { final String dateFormat = getContext().getString(R.string.system_ui_date_pattern); final String dateFormat = getContext().getString(R.string.system_ui_date_pattern); final Locale l = Locale.getDefault(); final Locale l = Locale.getDefault(); String fmt = ICU.getBestDateTimePattern(dateFormat, l.toString()); final String fmt = ICU.getBestDateTimePattern(dateFormat, l.toString()); SimpleDateFormat sdf = new SimpleDateFormat(fmt, l); mDateFormat = new SimpleDateFormat(fmt, l); setText(sdf.format(new Date())); mChangedLocale = false; } mCurrentTime.setTime(System.currentTimeMillis()); setText(mDateFormat.format(mCurrentTime)); } } private boolean isVisible() { private boolean isVisible() { Loading