Skip to content
Snippets Groups Projects
Commit bcdd859f authored by Pinyao Ting's avatar Pinyao Ting
Browse files

Fix actions for player integration in RemoteViews

Click handlers needs to be re-added each time a new document was passed
to the player.

Bug: 26162947
Test: atest RemoteViewsTest
Change-Id: Ib4e0f5d117554b71e5751a345034380f796ae303
parent f8894145
No related branches found
No related tags found
No related merge requests found
......@@ -3874,7 +3874,7 @@ public class RemoteViews implements Parcelable, Filter {
}
}
private static class SetDrawInstructionAction extends Action {
private class SetDrawInstructionAction extends Action {
@Nullable
private final DrawInstructions mInstructions;
......@@ -3909,6 +3909,15 @@ public class RemoteViews implements Parcelable, Filter {
}
try (ByteArrayInputStream is = new ByteArrayInputStream(bytes.get(0))) {
player.setDocument(new RemoteComposeDocument(is));
player.addClickListener((viewId, metadata) -> {
mActions.forEach(action -> {
if (viewId == action.mViewId
&& action instanceof SetOnClickResponse setOnClickResponse) {
setOnClickResponse.mResponse.handleViewInteraction(
player, params.handler);
}
});
});
} catch (IOException e) {
Log.e(LOG_TAG, "Failed to render draw instructions", e);
}
......@@ -6051,16 +6060,6 @@ public class RemoteViews implements Parcelable, Filter {
RemoteViews rvToApply = getRemoteViewsToApply(context, size);
View result = inflateView(context, rvToApply, directParent,
params.applyThemeResId, params.colorResources);
if (result instanceof RemoteComposePlayer player) {
player.addClickListener((viewId, metadata) -> {
mActions.forEach(action -> {
if (viewId == action.mViewId
&& action instanceof SetOnClickResponse setOnClickResponse) {
setOnClickResponse.mResponse.handleViewInteraction(player, params.handler);
}
});
});
}
rvToApply.performApply(result, rootParent, params);
return result;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment