Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1470396 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Add null check for handler on Clock view" into qt-qpr1-dev am: 410b9a75

Change-Id: I5eab49b0e613135762971dba609c17d77d03961d
parents d114664c 410b9a75
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.text.format.DateFormat;
import android.text.style.CharacterStyle;
import android.text.style.RelativeSizeSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.widget.TextView;
@@ -67,6 +68,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
        DarkReceiver, ConfigurationListener {

    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 CURRENT_USER_ID = "current_user_id";
    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
        public void onReceive(Context context, Intent intent) {
            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)) {
                String tz = intent.getStringExtra("time-zone");
                getHandler().post(() -> {
                handler.post(() -> {
                    mCalendar = Calendar.getInstance(TimeZone.getTimeZone(tz));
                    if (mClockFormat != null) {
                        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)) {
                final Locale newLocale = getResources().getConfiguration().locale;
                getHandler().post(() -> {
                handler.post(() -> {
                    if (!newLocale.equals(mLocale)) {
                        mLocale = newLocale;
                        mClockFormatString = ""; // force refresh
                    }
                });
            }
            getHandler().post(() -> updateClock());
            handler.post(() -> updateClock());
        }
    };