Loading core/java/android/widget/RemoteViews.java +25 −23 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.reflect.Method; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; Loading Loading @@ -812,29 +813,8 @@ public class RemoteViews implements Parcelable, Filter { AdapterView<?> av = (AdapterView<?>) target; // The PendingIntent template is stored in the view's tag. OnItemClickListener listener = (parent, view, position, id) -> { // The view should be a frame layout if (view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) view; // AdapterViews contain their children in a frame // so we need to go one layer deeper here. if (parent instanceof AdapterViewAnimator) { vg = (ViewGroup) vg.getChildAt(0); } if (vg == null) return; RemoteResponse response = null; int childCount = vg.getChildCount(); for (int i = 0; i < childCount; i++) { Object tag = vg.getChildAt(i).getTag(R.id.fillInIntent); if (tag instanceof RemoteResponse) { response = (RemoteResponse) tag; break; } } if (response == null) return; RemoteResponse response = findRemoteResponseTag(view); response.handleViewInteraction(view, handler); } }; av.setOnItemClickListener(listener); av.setTag(pendingIntentTemplate); Loading @@ -845,6 +825,28 @@ public class RemoteViews implements Parcelable, Filter { } } @Nullable private RemoteResponse findRemoteResponseTag(@Nullable View rootView) { if (rootView == null) return null; ArrayDeque<View> viewsToCheck = new ArrayDeque<>(); viewsToCheck.addLast(rootView); while (!viewsToCheck.isEmpty()) { View view = viewsToCheck.removeFirst(); Object tag = view.getTag(R.id.fillInIntent); if (tag instanceof RemoteResponse) return (RemoteResponse) tag; if (!(view instanceof ViewGroup)) continue; ViewGroup viewGroup = (ViewGroup) view; for (int i = 0; i < viewGroup.getChildCount(); i++) { viewsToCheck.addLast(viewGroup.getChildAt(i)); } } return null; } @Override public int getActionTag() { return SET_PENDING_INTENT_TEMPLATE_TAG; Loading Loading
core/java/android/widget/RemoteViews.java +25 −23 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.reflect.Method; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; Loading Loading @@ -812,29 +813,8 @@ public class RemoteViews implements Parcelable, Filter { AdapterView<?> av = (AdapterView<?>) target; // The PendingIntent template is stored in the view's tag. OnItemClickListener listener = (parent, view, position, id) -> { // The view should be a frame layout if (view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) view; // AdapterViews contain their children in a frame // so we need to go one layer deeper here. if (parent instanceof AdapterViewAnimator) { vg = (ViewGroup) vg.getChildAt(0); } if (vg == null) return; RemoteResponse response = null; int childCount = vg.getChildCount(); for (int i = 0; i < childCount; i++) { Object tag = vg.getChildAt(i).getTag(R.id.fillInIntent); if (tag instanceof RemoteResponse) { response = (RemoteResponse) tag; break; } } if (response == null) return; RemoteResponse response = findRemoteResponseTag(view); response.handleViewInteraction(view, handler); } }; av.setOnItemClickListener(listener); av.setTag(pendingIntentTemplate); Loading @@ -845,6 +825,28 @@ public class RemoteViews implements Parcelable, Filter { } } @Nullable private RemoteResponse findRemoteResponseTag(@Nullable View rootView) { if (rootView == null) return null; ArrayDeque<View> viewsToCheck = new ArrayDeque<>(); viewsToCheck.addLast(rootView); while (!viewsToCheck.isEmpty()) { View view = viewsToCheck.removeFirst(); Object tag = view.getTag(R.id.fillInIntent); if (tag instanceof RemoteResponse) return (RemoteResponse) tag; if (!(view instanceof ViewGroup)) continue; ViewGroup viewGroup = (ViewGroup) view; for (int i = 0; i < viewGroup.getChildCount(); i++) { viewsToCheck.addLast(viewGroup.getChildAt(i)); } } return null; } @Override public int getActionTag() { return SET_PENDING_INTENT_TEMPLATE_TAG; Loading