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

Commit c665c08f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sc_reverts_for_b_183104573" into sc-dev

* changes:
  Revert "Correct recycling to take setViewId into account."
  Revert "Ensure the view being recycled has been inflated before."
parents 82a38b09 b96f77af
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -520,7 +520,9 @@ public class AppWidgetHostView extends FrameLayout {
                return;
            }
            int layoutId = rvToApply.getLayoutId();
            if (rvToApply.canRecycleView(mView)) {
            // If our stale view has been prepared to match active, and the new
            // layout matches, try recycling it
            if (content == null && layoutId == mLayoutId) {
                try {
                    rvToApply.reapply(mContext, mView, mInteractionHandler, mCurrentSize,
                            mColorResources);
+4 −17
Original line number Diff line number Diff line
@@ -2196,7 +2196,7 @@ public class RemoteViews implements Parcelable, Filter {
                int recycledViewIndex = findViewIndexToRecycle(target, rvToApply);
                if (recycledViewIndex >= 0) {
                    View child = target.getChildAt(recycledViewIndex);
                    if (rvToApply.canRecycleView(child)) {
                    if (getViewLayoutId(child) == rvToApply.getLayoutId()) {
                        if (nextChild < recycledViewIndex) {
                            target.removeViews(nextChild, recycledViewIndex - nextChild);
                        }
@@ -2254,7 +2254,7 @@ public class RemoteViews implements Parcelable, Filter {
                    // application are placed before.
                    ViewTree recycled = target.mChildren.get(recycledViewIndex);
                    // We can only recycle the view if the layout id is the same.
                    if (rvToApply.canRecycleView(recycled.mRoot)) {
                    if (getViewLayoutId(recycled.mRoot) == rvToApply.getLayoutId()) {
                        if (recycledViewIndex > nextChild) {
                            target.removeChildren(nextChild, recycledViewIndex - nextChild);
                        }
@@ -3726,8 +3726,7 @@ public class RemoteViews implements Parcelable, Filter {
     *
     * The {@code stableId} will be used to identify a potential view to recycled when the remote
     * view is inflated. Views can be re-used if inserted in the same order, potentially with
     * some views appearing / disappearing. To be recycled the view must not change the layout
     * used to inflate it or its view id (see {@link RemoteViews#setViewId}).
     * some views appearing / disappearing.
     *
     * Note: if a view is re-used, all the actions will be re-applied on it. However, its properties
     * are not reset, so what was applied in previous round will have an effect. As a view may be
@@ -5117,7 +5116,6 @@ public class RemoteViews implements Parcelable, Filter {
        View v = inflater.inflate(rv.getLayoutId(), parent, false);
        if (mViewId != View.NO_ID) {
            v.setId(mViewId);
            v.setTagInternal(R.id.remote_views_override_id, mViewId);
        }
        v.setTagInternal(R.id.widget_frame, rv.getLayoutId());
        return v;
@@ -5337,17 +5335,6 @@ public class RemoteViews implements Parcelable, Filter {
        reapply(context, v, handler, size, colorResources, true);
    }

    /** @hide */
    public boolean canRecycleView(View v) {
        Integer previousLayout = (Integer) v.getTag(R.id.widget_frame);
        if (previousLayout == null) {
            return false;
        }
        Integer overrideIdTag = (Integer) v.getTag(R.id.remote_views_override_id);
        int overrideId = overrideIdTag == null ? View.NO_ID : overrideIdTag;
        return previousLayout == getLayoutId() && mViewId == overrideId;
    }

    // Note: topLevel should be true only for calls on the topLevel RemoteViews, internal calls
    // should set it to false.
    private void reapply(Context context, View v, InteractionHandler handler, SizeF size,
@@ -5360,7 +5347,7 @@ public class RemoteViews implements Parcelable, Filter {
        // (orientation or size), we throw an exception, since the layouts may be completely
        // unrelated.
        if (hasMultipleLayouts()) {
            if (!rvToApply.canRecycleView(v)) {
            if ((Integer) v.getTag(R.id.widget_frame) != rvToApply.getLayoutId()) {
                throw new RuntimeException("Attempting to re-apply RemoteViews to a view that" +
                        " that does not share the same root layout id.");
            }
+1 −4
Original line number Diff line number Diff line
@@ -253,7 +253,4 @@

  <!-- View tag associating a view with its stable id for potential recycling. -->
  <item type="id" name = "remote_views_stable_id" />

  <!-- View tag associating a view with its overridden id, to ensure valid recycling only. -->
  <item type="id" name="remote_views_override_id" />
</resources>
+0 −2
Original line number Diff line number Diff line
@@ -4323,8 +4323,6 @@

  <java-symbol type="id" name="remote_views_next_child" />
  <java-symbol type="id" name="remote_views_stable_id" />
  <java-symbol type="id" name="remote_views_override_id" />

  <!-- View and control prompt -->
  <java-symbol type="drawable" name="ic_accessibility_24dp" />
  <java-symbol type="string" name="view_and_control_notification_title" />