Fix IllegalStateException in recyclerview

- Fixed by updating UI in mainthread

Fixes: 142241908
Fixes: 142220754
Test: manual test if it crashes again
Change-Id: Ia83b66d3e60201bc524dbfab69bdeaa5201d38c2
This commit is contained in:
Raff Tsai
2019-10-15 12:34:03 +08:00
parent 94f1ad0bad
commit 40d9986fd7

View File

@@ -32,6 +32,7 @@ import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver; import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart; import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop; import com.android.settingslib.core.lifecycle.events.OnStop;
import com.android.settingslib.utils.ThreadUtils;
/** /**
* Default {@link BasePreferenceController} for {@link SliceView}. It will take {@link Uri} for * Default {@link BasePreferenceController} for {@link SliceView}. It will take {@link Uri} for
@@ -65,8 +66,10 @@ public class SlicePreferenceController extends BasePreferenceController implemen
mUri = uri; mUri = uri;
mLiveData = SliceLiveData.fromUri(mContext, mUri, (int type, Throwable source) -> { mLiveData = SliceLiveData.fromUri(mContext, mUri, (int type, Throwable source) -> {
Log.w(TAG, "Slice may be null. uri = " + uri + ", error = " + type); Log.w(TAG, "Slice may be null. uri = " + uri + ", error = " + type);
ThreadUtils.postOnMainThread(() -> {
onChanged(null); onChanged(null);
}); });
});
//TODO(b/120803703): figure out why we need to remove observer first //TODO(b/120803703): figure out why we need to remove observer first
mLiveData.removeObserver(this); mLiveData.removeObserver(this);