From 5b6983049db6ca926ddb944188cf8e95871a47ec Mon Sep 17 00:00:00 2001 From: Alon Albert Date: Mon, 7 Feb 2011 12:33:49 -0800 Subject: [PATCH] Use main looper to post start animation commands This is a workaround till we find a better solution. Posting start() on mail looper will make sure the animation starts but animation can stop randomly when the list gets refreshed which happens for example any time the user interacts with the list by check/uncheking boxes. This is because the list rebuilds itself and views gets detached/attached which binds to a new view. The long term solution is to switch to the new animator framework but for now posting on main looper will be consistent with GB behavior. Bug: 3426585 Change-Id: I77f15873bb47ad05113dc914a5d3d6d8af27e2e8 --- .../accounts/SyncStateCheckBoxPreference.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java b/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java index b200eb67d99..4b9ca81b2c1 100644 --- a/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java +++ b/src/com/android/settings/accounts/SyncStateCheckBoxPreference.java @@ -20,6 +20,7 @@ import com.android.settings.R; import android.content.Context; import android.graphics.drawable.AnimationDrawable; +import android.os.Handler; import android.preference.CheckBoxPreference; import android.util.AttributeSet; import android.view.View; @@ -40,7 +41,7 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { * toggling whether the provider will do autosync. */ private boolean mOneTimeSyncMode = false; - + public SyncStateCheckBoxPreference(Context context, AttributeSet attrs) { super(context, attrs); setWidgetLayoutResource(R.layout.preference_widget_sync_toggle); @@ -67,7 +68,7 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { boolean showError; boolean showPending; if (mIsActive) { - syncActiveView.post(new Runnable() { + new Handler(getContext().getMainLooper()).post(new Runnable() { public void run() { anim.start(); } @@ -87,11 +88,11 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { syncFailedView.setVisibility(showError ? View.VISIBLE : View.GONE); syncPendingView.setVisibility((showPending && !mIsActive) ? View.VISIBLE : View.GONE); - + View checkBox = view.findViewById(android.R.id.checkbox); if (mOneTimeSyncMode) { checkBox.setVisibility(View.GONE); - + /* * Override the summary. Fill in the %1$s with the existing summary * (what ends up happening is the old summary is shown on the next @@ -138,7 +139,7 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { mOneTimeSyncMode = oneTimeSyncMode; notifyChanged(); } - + /** * Gets whether the preference is in one-time sync mode. */ @@ -152,7 +153,7 @@ public class SyncStateCheckBoxPreference extends CheckBoxPreference { // checkbox state if (!mOneTimeSyncMode) { super.onClick(); - } + } } public Account getAccount() {