Translate message details projection to correct coordinate system.

This commit is contained in:
Alex Hart
2021-09-30 13:00:06 -03:00
committed by GitHub
parent eb6ef3d005
commit 9bcb1bad8e
3 changed files with 13 additions and 29 deletions

View File

@@ -95,9 +95,12 @@ class RecyclerViewColorizer(private val recyclerView: RecyclerView) {
for (i in 0 until parent.childCount) {
val child = parent.getChildAt(i)
if (child != null && child is Colorizable) {
child.colorizerProjections.forEach {
c.drawPath(it.path, holePunchPaint)
if (child != null) {
val holder = parent.getChildViewHolder(child)
if (holder is Colorizable) {
holder.colorizerProjections.forEach {
c.drawPath(it.path, holePunchPaint)
}
}
}
}

View File

@@ -43,6 +43,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;
final class MessageHeaderViewHolder extends RecyclerView.ViewHolder implements GiphyMp4Playable, Colorizable {
private final TextView sentDate;
@@ -55,7 +56,6 @@ final class MessageHeaderViewHolder extends RecyclerView.ViewHolder implements G
private final ViewStub updateStub;
private final ViewStub sentStub;
private final ViewStub receivedStub;
private final ClipProjectionDrawable clipProjectionDrawable;
private final Colorizer colorizer;
private GlideRequests glideRequests;
@@ -77,9 +77,6 @@ final class MessageHeaderViewHolder extends RecyclerView.ViewHolder implements G
updateStub = itemView.findViewById(R.id.message_details_header_message_view_update);
sentStub = itemView.findViewById(R.id.message_details_header_message_view_sent_multimedia);
receivedStub = itemView.findViewById(R.id.message_details_header_message_view_received_multimedia);
clipProjectionDrawable = new ClipProjectionDrawable(itemView.getBackground());
itemView.setBackground(clipProjectionDrawable);
}
void bind(@NonNull LifecycleOwner lifecycleOwner, @Nullable ConversationMessage conversationMessage, boolean running) {
@@ -225,13 +222,11 @@ final class MessageHeaderViewHolder extends RecyclerView.ViewHolder implements G
@Override
public void showProjectionArea() {
conversationItem.showProjectionArea();
updateProjections();
}
@Override
public void hideProjectionArea() {
conversationItem.hideProjectionArea();
updateProjections();
}
@Override
@@ -256,23 +251,10 @@ final class MessageHeaderViewHolder extends RecyclerView.ViewHolder implements G
@Override
public @NonNull List<Projection> getColorizerProjections() {
List<Projection> projections = conversationItem.getColorizerProjections();
updateProjections();
return projections;
}
private void updateProjections() {
Set<Projection> projections = new HashSet<>();
if (canPlayContent()) {
projections.add(conversationItem.getGiphyMp4PlayableProjection((ViewGroup) itemView));
}
projections.addAll(Stream.of(conversationItem.getColorizerProjections())
.map(p -> Projection.translateFromRootToDescendantCoords(p, itemView))
.toList());
clipProjectionDrawable.setProjections(projections);
return conversationItem.getColorizerProjections()
.stream()
.map(p -> Projection.translateFromRootToDescendantCoords(p, (ViewGroup) itemView.getParent()))
.collect(Collectors.toList());
}
private class ExpiresUpdater implements Runnable {