Merge "Add null check for handler on Clock view" into qt-qpr1-dev
This commit is contained in:
@@ -34,6 +34,7 @@ import android.text.format.DateFormat;
|
|||||||
import android.text.style.CharacterStyle;
|
import android.text.style.CharacterStyle;
|
||||||
import android.text.style.RelativeSizeSpan;
|
import android.text.style.RelativeSizeSpan;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -67,6 +68,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
|
|||||||
DarkReceiver, ConfigurationListener {
|
DarkReceiver, ConfigurationListener {
|
||||||
|
|
||||||
public static final String CLOCK_SECONDS = "clock_seconds";
|
public static final String CLOCK_SECONDS = "clock_seconds";
|
||||||
|
private static final String TAG = "StatusBarClock";
|
||||||
private static final String CLOCK_SUPER_PARCELABLE = "clock_super_parcelable";
|
private static final String CLOCK_SUPER_PARCELABLE = "clock_super_parcelable";
|
||||||
private static final String CURRENT_USER_ID = "current_user_id";
|
private static final String CURRENT_USER_ID = "current_user_id";
|
||||||
private static final String VISIBLE_BY_POLICY = "visible_by_policy";
|
private static final String VISIBLE_BY_POLICY = "visible_by_policy";
|
||||||
@@ -228,9 +230,18 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
Handler handler = getHandler();
|
||||||
|
if (handler == null) {
|
||||||
|
Log.e(TAG,
|
||||||
|
"Received intent, but handler is null - still attached to window? Window "
|
||||||
|
+ "token: "
|
||||||
|
+ getWindowToken());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)) {
|
if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)) {
|
||||||
String tz = intent.getStringExtra("time-zone");
|
String tz = intent.getStringExtra("time-zone");
|
||||||
getHandler().post(() -> {
|
handler.post(() -> {
|
||||||
mCalendar = Calendar.getInstance(TimeZone.getTimeZone(tz));
|
mCalendar = Calendar.getInstance(TimeZone.getTimeZone(tz));
|
||||||
if (mClockFormat != null) {
|
if (mClockFormat != null) {
|
||||||
mClockFormat.setTimeZone(mCalendar.getTimeZone());
|
mClockFormat.setTimeZone(mCalendar.getTimeZone());
|
||||||
@@ -238,14 +249,14 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
|
|||||||
});
|
});
|
||||||
} else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
|
} else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
|
||||||
final Locale newLocale = getResources().getConfiguration().locale;
|
final Locale newLocale = getResources().getConfiguration().locale;
|
||||||
getHandler().post(() -> {
|
handler.post(() -> {
|
||||||
if (!newLocale.equals(mLocale)) {
|
if (!newLocale.equals(mLocale)) {
|
||||||
mLocale = newLocale;
|
mLocale = newLocale;
|
||||||
mClockFormatString = ""; // force refresh
|
mClockFormatString = ""; // force refresh
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getHandler().post(() -> updateClock());
|
handler.post(() -> updateClock());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user