Merge "Addressing issues associated RemoteViewsAdapter's service crashes / disconnects"

This commit is contained in:
Adam Cohen
2010-12-17 12:19:46 -08:00
committed by Android (Google) Code Review
4 changed files with 18 additions and 18 deletions

View File

@ -5184,6 +5184,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
public void onRemoteAdapterConnected() {
if (mRemoteAdapter != mAdapter) {
setAdapter(mRemoteAdapter);
} else if (mRemoteAdapter != null) {
mRemoteAdapter.superNotifyDataSetChanged();
}
}
@ -5191,10 +5193,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* Called back when the adapter disconnects from the RemoteViewsService.
*/
public void onRemoteAdapterDisconnected() {
if (mRemoteAdapter == mAdapter) {
mRemoteAdapter = null;
setAdapter(null);
}
// If the remote adapter disconnects, we keep it around
// since the currently displayed items are still cached.
// Further, we want the service to eventually reconnect
// when necessary, as triggered by this view requesting
// items from the Adapter.
}
/**

View File

@ -964,6 +964,8 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
public void onRemoteAdapterConnected() {
if (mRemoteViewsAdapter != mAdapter) {
setAdapter(mRemoteViewsAdapter);
} else if (mRemoteViewsAdapter != null) {
mRemoteViewsAdapter.superNotifyDataSetChanged();
}
}
@ -971,10 +973,11 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
* Called back when the adapter disconnects from the RemoteViewsService.
*/
public void onRemoteAdapterDisconnected() {
if (mRemoteViewsAdapter != mAdapter) {
mRemoteViewsAdapter = null;
setAdapter(mRemoteViewsAdapter);
}
// If the remote adapter disconnects, we keep it around
// since the currently displayed items are still cached.
// Further, we want the service to eventually reconnect
// when necessary, as triggered by this view requesting
// items from the Adapter.
}
public void advance() {

View File

@ -103,7 +103,7 @@ public class ListView extends AbsListView {
Drawable mDivider;
int mDividerHeight;
Drawable mOverScrollHeader;
Drawable mOverScrollFooter;
@ -1535,7 +1535,6 @@ public class ListView extends AbsListView {
// reset the focus restoration
View focusLayoutRestoreDirectChild = null;
// Don't put header or footer views into the Recycler. Those are
// already cached in mHeaderViews;
if (dataChanged) {

View File

@ -148,11 +148,6 @@ public class RemoteViewsAdapter extends BaseAdapter {
adapter.mMainQueue.removeMessages(0);
adapter.mWorkerQueue.removeMessages(0);
// Clear the cache (the meta data will be re-requested on service re-connection)
synchronized (adapter.mCache) {
adapter.mCache.reset();
}
final RemoteAdapterConnectionCallback callback = adapter.mCallback.get();
if (callback != null) {
callback.onRemoteAdapterDisconnected();
@ -335,8 +330,8 @@ public class RemoteViewsAdapter extends BaseAdapter {
// Compose the loading view text
TextView loadingTextView = (TextView) mLayoutInflater.inflate(
com.android.internal.R.layout.remote_views_adapter_default_loading_view,
layout, false);
com.android.internal.R.layout.remote_views_adapter_default_loading_view,
layout, false);
loadingTextView.setHeight(mFirstViewHeight);
loadingTextView.setTag(new Integer(0));
@ -880,7 +875,7 @@ public class RemoteViewsAdapter extends BaseAdapter {
// a chance to update itself and return new meta data associated with the new data.
}
private void superNotifyDataSetChanged() {
void superNotifyDataSetChanged() {
super.notifyDataSetChanged();
}