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

Commit 4e2affec authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Fixing issue where notifyDataSetChanged was not properly being called...

Merge "Fixing issue where notifyDataSetChanged was not properly being called while not loading items."
parents ea7ee3f4 6364f2bb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -339,7 +339,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
        return new ViewGroup.LayoutParams(0, 0);
    }

    private void refreshChildren() {
    void refreshChildren() {
        for (int i = mCurrentWindowStart; i <= mCurrentWindowEnd; i++) {
            int index = modulo(i, mNumActiveViews);

+32 −48
Original line number Diff line number Diff line
@@ -601,19 +601,6 @@ public class RemoteViewsAdapter extends BaseAdapter {
        mWorkerQueue.post(new Runnable() {
            @Override
            public void run() {
                boolean isDataDirty = false;

                // If the data set has changed, then notify the remote factory so that it can
                // update its internals first.
                final RemoteViewsMetaData metaData = mCache.getMetaData();
                synchronized (metaData) {
                    isDataDirty = metaData.isDataDirty;
                    metaData.isDataDirty = false;
                }
                if (isDataDirty) {
                    completeNotifyDataSetChanged();
                }

                // Get the next index to load
                int position = -1;
                synchronized (mCache) {
@@ -843,18 +830,9 @@ public class RemoteViewsAdapter extends BaseAdapter {
    }

    public void notifyDataSetChanged() {
        final RemoteViewsMetaData metaData = mCache.getMetaData();
        synchronized (metaData) {
            // Set flag to calls the remote factory's onDataSetChanged() on the next worker loop
            metaData.isDataDirty = true;
        }

        // Note: we do not call super.notifyDataSetChanged() until the RemoteViewsFactory has had
        // a chance to update itself, and return new meta data associated with the new data.  After
        // which completeNotifyDataSetChanged() is called.
    }

    private void completeNotifyDataSetChanged() {
        mWorkerQueue.post(new Runnable() {
            @Override
            public void run() {
                // Complete the actual notifyDataSetChanged() call initiated earlier
                if (mServiceConnection.isConnected()) {
                    IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
@@ -863,7 +841,8 @@ public class RemoteViewsAdapter extends BaseAdapter {
                    } catch (Exception e) {
                        Log.e(TAG, "Error in updateNotifyDataSetChanged(): " + e.getMessage());

                // Return early to prevent from further being notified (since nothing has changed)
                        // Return early to prevent from further being notified (since nothing has
                        // changed)
                        return;
                    }
                }
@@ -884,6 +863,11 @@ public class RemoteViewsAdapter extends BaseAdapter {
                    }
                });
            }
        });

        // Note: we do not call super.notifyDataSetChanged() until the RemoteViewsFactory has had
        // a chance to update itself and return new meta data associated with the new data.
    }

    private void superNotifyDataSetChanged() {
        super.notifyDataSetChanged();
+1 −0
Original line number Diff line number Diff line
@@ -776,6 +776,7 @@ public class StackView extends AdapterViewAnimator {
                mWhichChild = 0;

            showOnly(mWhichChild, true, true);
            refreshChildren();
        }

        final int childCount = getChildCount();