Fix content observer in SliceView

showSlice was being called which would clear the content observer, instead
specify slice and reinflate within setSlice(uri) method.

Test: Have a slice, call notifyContentChanged on the uri, note that it
      updates

Change-Id: I5ce8af2867114b9d053f1623bc4a47dfabe961fc
This commit is contained in:
Mady Mellor
2017-11-03 13:30:43 -07:00
parent 97a0ae3a49
commit 603e779aa5

View File

@@ -210,11 +210,15 @@ public class SliceView extends ViewGroup {
validate(sliceUri);
Slice s = Slice.bindSlice(mContext.getContentResolver(), sliceUri);
if (s != null) {
if (mObserver != null) {
getContext().getContentResolver().unregisterContentObserver(mObserver);
}
mObserver = new SliceObserver(new Handler(Looper.getMainLooper()));
if (isAttachedToWindow()) {
registerSlice(sliceUri);
}
showSlice(s);
mCurrentSlice = s;
reinflate();
}
return s != null;
}