Files
iTartanas/itranvias_code/com/google/maps.android/compose/clustering/ComposeUiClusterRenderer.java
T

638 lines
43 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.google.maps.android.compose.clustering;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.compose.runtime.Composer;
import androidx.compose.runtime.RecomposeScopeImplKt;
import androidx.compose.runtime.ScopeUpdateScope;
import androidx.compose.runtime.State;
import androidx.compose.runtime.internal.ComposableLambda;
import androidx.compose.runtime.internal.ComposableLambdaKt;
import androidx.compose.ui.platform.AbstractComposeView;
import androidx.core.view.ViewCompat;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.maps.android.clustering.Cluster;
import com.google.maps.android.clustering.ClusterItem;
import com.google.maps.android.clustering.ClusterManager;
import com.google.maps.android.clustering.view.DefaultClusterRenderer;
import com.google.maps.android.compose.ComposeUiViewRenderer;
import com.google.maps.android.compose.clustering.ComposeUiClusterRenderer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CancellationException;
import kotlin.Metadata;
import kotlin.NoWhenBranchMatchedException;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.collections.SetsKt;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.functions.Function3;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.channels.ProduceKt;
import kotlinx.coroutines.channels.ProducerScope;
import kotlinx.coroutines.channels.SendChannel;
import kotlinx.coroutines.flow.FlowKt;
/* JADX INFO: compiled from: ClusterRenderer.kt */
/* JADX INFO: loaded from: classes2.dex */
@Metadata(d1 = {"\u0000\u0084\u0001\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010%\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\"\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\b\u0001\u0018\u0000*\b\b\u0000\u0010\u0001*\u00020\u00022\b\u0012\u0004\u0012\u0002H\u00010\u0003:\u0003123B\u0083\u0001\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\u0006\u0010\b\u001a\u00020\t\u0012\f\u0010\n\u001a\b\u0012\u0004\u0012\u00028\u00000\u000b\u0012\f\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000e0\r\u0012%\u0010\u000f\u001a!\u0012\u001d\u0012\u001b\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u0011\u0012\u0004\u0012\u00020\u0012\u0018\u00010\u0010¢\u0006\u0002\b\u00130\r\u0012\u001f\u0010\u0014\u001a\u001b\u0012\u0017\u0012\u0015\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00020\u0012\u0018\u00010\u0010¢\u0006\u0002\b\u00130\\u0006\u0004\b\u0015\u0010\u0016J\u001c\u0010\u001d\u001a\u00020\u00122\u0012\u0010\u001e\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u00110\u001fH\u0016J\u001e\u0010 \u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u001b0\u001f*\b\u0012\u0004\u0012\u00028\u00000\u0011H\u0002J\u0016\u0010!\u001a\u00020\u001c2\f\u0010\"\u001a\b\u0012\u0004\u0012\u00028\u00000\u001bH\u0002J$\u0010#\u001a\u00020\u00122\f\u0010\"\u001a\b\u0012\u0004\u0012\u00028\u00000\u001b2\u0006\u0010$\u001a\u00020%H\u0082@¢\u0006\u0002\u0010&J\u0016\u0010'\u001a\u00020(2\f\u0010)\u001a\b\u0012\u0004\u0012\u00028\u00000\u0011H\u0014J\u001d\u0010*\u001a\u00020\u00122\u0006\u0010+\u001a\u00028\u00002\u0006\u0010,\u001a\u00020-H\u0014¢\u0006\u0002\u0010.J\u0010\u0010/\u001a\u00020(2\u0006\u0010$\u001a\u000200H\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\f\u001a\b\u0012\u0004\u0012\u00020\u000e0\rX\u0082\u0004¢\u0006\u0002\n\u0000R-\u0010\u000f\u001a!\u0012\u001d\u0012\u001b\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u0011\u0012\u0004\u0012\u00020\u0012\u0018\u00010\u0010¢\u0006\u0002\b\u00130\rX\u0082\u0004¢\u0006\u0002\n\u0000R'\u0010\u0014\u001a\u001b\u0012\u0017\u0012\u0015\u0012\u0004\u0012\u00028\u0000\u0012\u0004\u0012\u00020\u0012\u0018\u00010\u0010¢\u0006\u0002\b\u00130\rX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u0018X\u0082\u0004¢\u0006\u0002\n\u0000R \u0010\u0019\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u001b\u0012\u0004\u0012\u00020\u001c0\u001aX\u0082\u0004¢\u0006\u0002\n\u0000¨\u00064"}, d2 = {"Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer;", "T", "Lcom/google/maps/android/clustering/ClusterItem;", "Lcom/google/maps/android/clustering/view/DefaultClusterRenderer;", "context", "Landroid/content/Context;", "scope", "Lkotlinx/coroutines/CoroutineScope;", "map", "Lcom/google/android/gms/maps/GoogleMap;", "clusterManager", "Lcom/google/maps/android/clustering/ClusterManager;", "viewRendererState", "Landroidx/compose/runtime/State;", "Lcom/google/maps/android/compose/ComposeUiViewRenderer;", "clusterContentState", "Lkotlin/Function1;", "Lcom/google/maps/android/clustering/Cluster;", "", "Landroidx/compose/runtime/Composable;", "clusterItemContentState", "<init>", "(Landroid/content/Context;Lkotlinx/coroutines/CoroutineScope;Lcom/google/android/gms/maps/GoogleMap;Lcom/google/maps/android/clustering/ClusterManager;Landroidx/compose/runtime/State;Landroidx/compose/runtime/State;Landroidx/compose/runtime/State;)V", "fakeCanvas", "Landroid/graphics/Canvas;", "keysToViews", "", "Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey;", "Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewInfo;", "onClustersChanged", "clusters", "", "computeViewKeys", "createAndAddView", "key", "collectInvalidationsAndRerender", "view", "Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$InvalidatingComposeView;", "(Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey;Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$InvalidatingComposeView;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "getDescriptorForCluster", "Lcom/google/android/gms/maps/model/BitmapDescriptor;", "cluster", "onBeforeClusterItemRendered", "item", "markerOptions", "Lcom/google/android/gms/maps/model/MarkerOptions;", "(Lcom/google/maps/android/clustering/ClusterItem;Lcom/google/android/gms/maps/model/MarkerOptions;)V", "renderViewToBitmapDescriptor", "Landroidx/compose/ui/platform/AbstractComposeView;", "ViewKey", "ViewInfo", "InvalidatingComposeView", "maps-compose-utils_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public final class ComposeUiClusterRenderer<T extends ClusterItem> extends DefaultClusterRenderer<T> {
public static final int $stable = 8;
private final State<Function3<Cluster<T>, Composer, Integer, Unit>> clusterContentState;
private final State<Function3<T, Composer, Integer, Unit>> clusterItemContentState;
private final Context context;
private final Canvas fakeCanvas;
private final Map<ViewKey<T>, ViewInfo> keysToViews;
private final CoroutineScope scope;
private final State<ComposeUiViewRenderer> viewRendererState;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
/* JADX WARN: Multi-variable type inference failed */
public ComposeUiClusterRenderer(Context context, CoroutineScope scope, GoogleMap map, ClusterManager<T> clusterManager, State<? extends ComposeUiViewRenderer> viewRendererState, State<? extends Function3<? super Cluster<T>, ? super Composer, ? super Integer, Unit>> clusterContentState, State<? extends Function3<? super T, ? super Composer, ? super Integer, Unit>> clusterItemContentState) {
super(context, map, clusterManager);
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(scope, "scope");
Intrinsics.checkNotNullParameter(map, "map");
Intrinsics.checkNotNullParameter(clusterManager, "clusterManager");
Intrinsics.checkNotNullParameter(viewRendererState, "viewRendererState");
Intrinsics.checkNotNullParameter(clusterContentState, "clusterContentState");
Intrinsics.checkNotNullParameter(clusterItemContentState, "clusterItemContentState");
this.context = context;
this.scope = scope;
this.viewRendererState = viewRendererState;
this.clusterContentState = clusterContentState;
this.clusterItemContentState = clusterItemContentState;
this.fakeCanvas = new Canvas();
this.keysToViews = new LinkedHashMap();
}
@Override // com.google.maps.android.clustering.view.DefaultClusterRenderer, com.google.maps.android.clustering.view.ClusterRenderer
public void onClustersChanged(Set<? extends Cluster<T>> clusters) {
Intrinsics.checkNotNullParameter(clusters, "clusters");
super.onClustersChanged(clusters);
ArrayList arrayList = new ArrayList();
Iterator<T> it = clusters.iterator();
while (it.hasNext()) {
CollectionsKt.addAll(arrayList, computeViewKeys((Cluster) it.next()));
}
ArrayList<ViewKey<T>> arrayList2 = arrayList;
Iterator<Map.Entry<ViewKey<T>, ViewInfo>> it2 = this.keysToViews.entrySet().iterator();
while (it2.hasNext()) {
Map.Entry<ViewKey<T>, ViewInfo> next = it2.next();
ViewKey<T> key = next.getKey();
ViewInfo value = next.getValue();
if (!arrayList2.contains(key)) {
it2.remove();
value.getOnRemove().invoke();
}
}
for (ViewKey<T> viewKey : arrayList2) {
if (!this.keysToViews.keySet().contains(viewKey)) {
createAndAddView(viewKey);
}
}
}
private final Set<ViewKey<T>> computeViewKeys(Cluster<T> cluster) {
if (shouldRenderAsCluster(cluster)) {
return SetsKt.setOf(new ViewKey.Cluster(cluster));
}
Collection<T> items = cluster.getItems();
Intrinsics.checkNotNullExpressionValue(items, "getItems(...)");
LinkedHashSet linkedHashSet = new LinkedHashSet();
for (T t : items) {
Intrinsics.checkNotNull(t);
linkedHashSet.add(new ViewKey.Item(t));
}
return linkedHashSet;
}
private final ViewInfo createAndAddView(final ViewKey<T> key) {
ComposableLambda composableLambdaComposableLambdaInstance;
Context context = this.context;
if (key instanceof ViewKey.Cluster) {
composableLambdaComposableLambdaInstance = ComposableLambdaKt.composableLambdaInstance(-231222560, true, new Function2<Composer, Integer, Unit>(this) { // from class: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$createAndAddView$view$1
final /* synthetic */ ComposeUiClusterRenderer<T> this$0;
{
this.this$0 = this;
}
@Override // kotlin.jvm.functions.Function2
public /* bridge */ /* synthetic */ Unit invoke(Composer composer, Integer num) {
invoke(composer, num.intValue());
return Unit.INSTANCE;
}
public final void invoke(Composer composer, int i) {
if ((i & 11) == 2 && composer.getSkipping()) {
composer.skipToGroupEnd();
return;
}
Function3 function3 = (Function3) ((ComposeUiClusterRenderer) this.this$0).clusterContentState.getValue();
if (function3 == null) {
return;
}
function3.invoke(((ComposeUiClusterRenderer.ViewKey.Cluster) key).getCluster(), composer, 8);
}
});
} else {
if (!(key instanceof ViewKey.Item)) {
throw new NoWhenBranchMatchedException();
}
composableLambdaComposableLambdaInstance = ComposableLambdaKt.composableLambdaInstance(-1883693097, true, new Function2<Composer, Integer, Unit>(this) { // from class: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$createAndAddView$view$2
final /* synthetic */ ComposeUiClusterRenderer<T> this$0;
{
this.this$0 = this;
}
@Override // kotlin.jvm.functions.Function2
public /* bridge */ /* synthetic */ Unit invoke(Composer composer, Integer num) {
invoke(composer, num.intValue());
return Unit.INSTANCE;
}
public final void invoke(Composer composer, int i) {
if ((i & 11) == 2 && composer.getSkipping()) {
composer.skipToGroupEnd();
return;
}
Function3 function3 = (Function3) ((ComposeUiClusterRenderer) this.this$0).clusterItemContentState.getValue();
if (function3 == null) {
return;
}
function3.invoke(((ComposeUiClusterRenderer.ViewKey.Item) key).getItem(), composer, 0);
}
});
}
InvalidatingComposeView invalidatingComposeView = new InvalidatingComposeView(context, composableLambdaComposableLambdaInstance);
InvalidatingComposeView invalidatingComposeView2 = invalidatingComposeView;
final ComposeUiViewRenderer.RenderHandle renderHandleStartRenderingView = this.viewRendererState.getValue().startRenderingView(invalidatingComposeView2);
final Job jobLaunch$default = BuildersKt__Builders_commonKt.launch$default(this.scope, null, null, new ComposeUiClusterRenderer$createAndAddView$rerenderJob$1(this, key, invalidatingComposeView, null), 3, null);
ViewInfo viewInfo = new ViewInfo(invalidatingComposeView2, new Function0() { // from class: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$$ExternalSyntheticLambda0
@Override // kotlin.jvm.functions.Function0
public final Object invoke() {
return ComposeUiClusterRenderer.createAndAddView$lambda$5(jobLaunch$default, renderHandleStartRenderingView);
}
});
this.keysToViews.put(key, viewInfo);
return viewInfo;
}
/* JADX INFO: Access modifiers changed from: private */
public static final Unit createAndAddView$lambda$5(Job rerenderJob, ComposeUiViewRenderer.RenderHandle renderHandle) {
Intrinsics.checkNotNullParameter(rerenderJob, "$rerenderJob");
Intrinsics.checkNotNullParameter(renderHandle, "$renderHandle");
Job.DefaultImpls.cancel$default(rerenderJob, (CancellationException) null, 1, (Object) null);
renderHandle.dispose();
return Unit.INSTANCE;
}
/* JADX INFO: renamed from: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$collectInvalidationsAndRerender$2, reason: invalid class name */
/* JADX INFO: compiled from: ClusterRenderer.kt */
@Metadata(d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\u0010\u0000\u001a\u00020\u0001*\b\u0012\u0004\u0012\u00020\u00010\u0002H\n"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/channels/ProducerScope;"}, k = 3, mv = {2, 0, 0}, xi = 48)
@DebugMetadata(c = "com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$collectInvalidationsAndRerender$2", f = "ClusterRenderer.kt", i = {}, l = {136}, m = "invokeSuspend", n = {}, s = {})
static final class AnonymousClass2 extends SuspendLambda implements Function2<ProducerScope<? super Unit>, Continuation<? super Unit>, Object> {
final /* synthetic */ InvalidatingComposeView $view;
private /* synthetic */ Object L$0;
int label;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
AnonymousClass2(InvalidatingComposeView invalidatingComposeView, Continuation<? super AnonymousClass2> continuation) {
super(2, continuation);
this.$view = invalidatingComposeView;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
AnonymousClass2 anonymousClass2 = new AnonymousClass2(this.$view, continuation);
anonymousClass2.L$0 = obj;
return anonymousClass2;
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(ProducerScope<? super Unit> producerScope, Continuation<? super Unit> continuation) {
return ((AnonymousClass2) create(producerScope, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) throws Throwable {
Object coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
int i = this.label;
if (i == 0) {
ResultKt.throwOnFailure(obj);
final ProducerScope producerScope = (ProducerScope) this.L$0;
final Ref.BooleanRef booleanRef = new Ref.BooleanRef();
this.$view.setOnInvalidate(new Function0() { // from class: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$collectInvalidationsAndRerender$2$$ExternalSyntheticLambda0
@Override // kotlin.jvm.functions.Function0
public final Object invoke() {
return ComposeUiClusterRenderer.AnonymousClass2.invokeSuspend$lambda$0(booleanRef, producerScope);
}
});
final InvalidatingComposeView invalidatingComposeView = this.$view;
final InvalidatingComposeView invalidatingComposeView2 = invalidatingComposeView;
if (ViewCompat.isAttachedToWindow(invalidatingComposeView2)) {
InvalidatingComposeView invalidatingComposeView3 = invalidatingComposeView;
if (!ViewCompat.isAttachedToWindow(invalidatingComposeView3)) {
SendChannel.DefaultImpls.close$default(producerScope, null, 1, null);
} else {
invalidatingComposeView3.addOnAttachStateChangeListener(new ComposeUiClusterRenderer$collectInvalidationsAndRerender$2$invokeSuspend$lambda$2$$inlined$doOnDetach$1(invalidatingComposeView3, producerScope));
}
} else {
invalidatingComposeView2.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { // from class: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$collectInvalidationsAndRerender$2$invokeSuspend$$inlined$doOnAttach$1
@Override // android.view.View.OnAttachStateChangeListener
public void onViewDetachedFromWindow(View view) {
}
@Override // android.view.View.OnAttachStateChangeListener
public void onViewAttachedToWindow(View view) {
invalidatingComposeView2.removeOnAttachStateChangeListener(this);
ComposeUiClusterRenderer.InvalidatingComposeView invalidatingComposeView4 = invalidatingComposeView;
if (!ViewCompat.isAttachedToWindow(invalidatingComposeView4)) {
SendChannel.DefaultImpls.close$default(producerScope, null, 1, null);
} else {
invalidatingComposeView4.addOnAttachStateChangeListener(new ComposeUiClusterRenderer$collectInvalidationsAndRerender$2$invokeSuspend$lambda$2$$inlined$doOnDetach$1(invalidatingComposeView4, producerScope));
}
}
});
}
this.label = 1;
if (ProduceKt.awaitClose$default(producerScope, null, this, 1, null) == coroutine_suspended) {
return coroutine_suspended;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
}
return Unit.INSTANCE;
}
/* JADX INFO: Access modifiers changed from: private */
public static final Unit invokeSuspend$lambda$0(Ref.BooleanRef booleanRef, ProducerScope producerScope) {
if (!booleanRef.element) {
BuildersKt__Builders_commonKt.launch$default(producerScope, null, null, new ComposeUiClusterRenderer$collectInvalidationsAndRerender$2$1$1(producerScope, booleanRef, null), 3, null);
booleanRef.element = true;
}
return Unit.INSTANCE;
}
}
/* JADX INFO: Access modifiers changed from: private */
public final Object collectInvalidationsAndRerender(ViewKey<T> viewKey, InvalidatingComposeView invalidatingComposeView, Continuation<? super Unit> continuation) {
Object objCollectLatest = FlowKt.collectLatest(FlowKt.callbackFlow(new AnonymousClass2(invalidatingComposeView, null)), new AnonymousClass3(viewKey, this, invalidatingComposeView, null), continuation);
return objCollectLatest == IntrinsicsKt.getCOROUTINE_SUSPENDED() ? objCollectLatest : Unit.INSTANCE;
}
/* JADX INFO: renamed from: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$collectInvalidationsAndRerender$3, reason: invalid class name */
/* JADX INFO: compiled from: ClusterRenderer.kt */
@Metadata(d1 = {"\u0000\u0010\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u00012\u0015\u0010\u0002\u001a\u00110\u0001¢\u0006\f\b\u0003\u0012\b\b\u0004\u0012\u0004\b\b(\u0005H\n"}, d2 = {"<anonymous>", "", "it", "Lkotlin/ParameterName;", "name", "value"}, k = 3, mv = {2, 0, 0}, xi = 48)
@DebugMetadata(c = "com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$collectInvalidationsAndRerender$3", f = "ClusterRenderer.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
static final class AnonymousClass3 extends SuspendLambda implements Function2<Unit, Continuation<? super Unit>, Object> {
final /* synthetic */ ViewKey<T> $key;
final /* synthetic */ InvalidatingComposeView $view;
int label;
final /* synthetic */ ComposeUiClusterRenderer<T> this$0;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
AnonymousClass3(ViewKey<T> viewKey, ComposeUiClusterRenderer<T> composeUiClusterRenderer, InvalidatingComposeView invalidatingComposeView, Continuation<? super AnonymousClass3> continuation) {
super(2, continuation);
this.$key = viewKey;
this.this$0 = composeUiClusterRenderer;
this.$view = invalidatingComposeView;
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
return new AnonymousClass3(this.$key, this.this$0, this.$view, continuation);
}
@Override // kotlin.jvm.functions.Function2
public final Object invoke(Unit unit, Continuation<? super Unit> continuation) {
return ((AnonymousClass3) create(unit, continuation)).invokeSuspend(Unit.INSTANCE);
}
@Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
public final Object invokeSuspend(Object obj) throws Throwable {
Marker marker;
IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (this.label != 0) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
ResultKt.throwOnFailure(obj);
ViewKey<T> viewKey = this.$key;
if (viewKey instanceof ViewKey.Cluster) {
marker = this.this$0.getMarker(((ViewKey.Cluster) viewKey).getCluster());
} else {
if (!(viewKey instanceof ViewKey.Item)) {
throw new NoWhenBranchMatchedException();
}
marker = this.this$0.getMarker(((ViewKey.Item) viewKey).getItem());
}
if (marker != null) {
marker.setIcon(this.this$0.renderViewToBitmapDescriptor(this.$view));
}
return Unit.INSTANCE;
}
}
@Override // com.google.maps.android.clustering.view.DefaultClusterRenderer
protected BitmapDescriptor getDescriptorForCluster(Cluster<T> cluster) {
Object obj;
ViewInfo viewInfoCreateAndAddView;
Intrinsics.checkNotNullParameter(cluster, "cluster");
if (this.clusterContentState.getValue() == null) {
BitmapDescriptor descriptorForCluster = super.getDescriptorForCluster(cluster);
Intrinsics.checkNotNull(descriptorForCluster);
return descriptorForCluster;
}
Iterator<T> it = this.keysToViews.entrySet().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Object next = it.next();
ViewKey viewKey = (ViewKey) ((Map.Entry) next).getKey();
ViewKey.Cluster cluster2 = viewKey instanceof ViewKey.Cluster ? (ViewKey.Cluster) viewKey : null;
if (Intrinsics.areEqual(cluster2 != null ? cluster2.getCluster() : null, cluster)) {
obj = next;
break;
}
}
Map.Entry entry = (Map.Entry) obj;
if (entry == null || (viewInfoCreateAndAddView = (ViewInfo) entry.getValue()) == null) {
viewInfoCreateAndAddView = createAndAddView((ViewKey) CollectionsKt.first(computeViewKeys(cluster)));
}
return renderViewToBitmapDescriptor(viewInfoCreateAndAddView.getView());
}
@Override // com.google.maps.android.clustering.view.DefaultClusterRenderer
protected void onBeforeClusterItemRendered(T item, MarkerOptions markerOptions) {
Object obj;
ViewInfo viewInfoCreateAndAddView;
Intrinsics.checkNotNullParameter(item, "item");
Intrinsics.checkNotNullParameter(markerOptions, "markerOptions");
super.onBeforeClusterItemRendered(item, markerOptions);
if (this.clusterItemContentState.getValue() != null) {
Iterator<T> it = this.keysToViews.entrySet().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Object next = it.next();
ViewKey viewKey = (ViewKey) ((Map.Entry) next).getKey();
ViewKey.Item item2 = viewKey instanceof ViewKey.Item ? (ViewKey.Item) viewKey : null;
if (Intrinsics.areEqual(item2 != null ? item2.getItem() : null, item)) {
obj = next;
break;
}
}
Map.Entry entry = (Map.Entry) obj;
if (entry == null || (viewInfoCreateAndAddView = (ViewInfo) entry.getValue()) == null) {
viewInfoCreateAndAddView = createAndAddView(new ViewKey.Item(item));
}
markerOptions.icon(renderViewToBitmapDescriptor(viewInfoCreateAndAddView.getView()));
}
}
/* JADX INFO: Access modifiers changed from: private */
public final BitmapDescriptor renderViewToBitmapDescriptor(AbstractComposeView view) {
view.draw(this.fakeCanvas);
ViewParent parent = view.getParent();
Intrinsics.checkNotNull(parent, "null cannot be cast to non-null type android.view.ViewGroup");
ViewGroup viewGroup = (ViewGroup) parent;
view.measure(View.MeasureSpec.makeMeasureSpec(viewGroup.getWidth(), Integer.MIN_VALUE), View.MeasureSpec.makeMeasureSpec(viewGroup.getHeight(), Integer.MIN_VALUE));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
Integer numValueOf = Integer.valueOf(view.getMeasuredWidth());
if (numValueOf.intValue() <= 0) {
numValueOf = null;
}
int iIntValue = numValueOf != null ? numValueOf.intValue() : 1;
Integer numValueOf2 = Integer.valueOf(view.getMeasuredHeight());
Integer num = numValueOf2.intValue() > 0 ? numValueOf2 : null;
Bitmap bitmapCreateBitmap = Bitmap.createBitmap(iIntValue, num != null ? num.intValue() : 1, Bitmap.Config.ARGB_8888);
Intrinsics.checkNotNullExpressionValue(bitmapCreateBitmap, "createBitmap(...)");
view.draw(new Canvas(bitmapCreateBitmap));
BitmapDescriptor bitmapDescriptorFromBitmap = BitmapDescriptorFactory.fromBitmap(bitmapCreateBitmap);
Intrinsics.checkNotNullExpressionValue(bitmapDescriptorFromBitmap, "fromBitmap(...)");
return bitmapDescriptorFromBitmap;
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX INFO: compiled from: ClusterRenderer.kt */
@Metadata(d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b2\u0018\u0000*\b\b\u0001\u0010\u0001*\u00020\u00022\u00020\u0003:\u0002\u0006\u0007B\t\b\u0004¢\u0006\u0004\b\u0004\u0010\u0005\u0082\u0001\u0002\b\\u0006\n"}, d2 = {"Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey;", "T", "Lcom/google/maps/android/clustering/ClusterItem;", "", "<init>", "()V", "Cluster", "Item", "Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey$Cluster;", "Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey$Item;", "maps-compose-utils_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
static abstract class ViewKey<T extends ClusterItem> {
public /* synthetic */ ViewKey(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private ViewKey() {
}
/* JADX INFO: compiled from: ClusterRenderer.kt */
@Metadata(d1 = {"\u00000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0087\b\u0018\u0000*\b\b\u0002\u0010\u0001*\u00020\u00022\b\u0012\u0004\u0012\u0002H\u00010\u0003B\u0015\u0012\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00028\u00020\u0005¢\u0006\u0004\b\u0006\u0010\u0007J\u000f\u0010\n\u001a\b\u0012\u0004\u0012\u00028\u00020\u0005HÆ\u0003J\u001f\u0010\u000b\u001a\b\u0012\u0004\u0012\u00028\u00020\u00002\u000e\b\u0002\u0010\u0004\u001a\b\u0012\u0004\u0012\u00028\u00020\u0005HÇ\u0001J\u0013\u0010\f\u001a\u00020\r2\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fH×\u0003J\t\u0010\u0010\u001a\u00020\u0011H×\u0001J\t\u0010\u0012\u001a\u00020\u0013H×\u0001R\u0017\u0010\u0004\u001a\b\u0012\u0004\u0012\u00028\u00020\u0005¢\u0006\b\n\u0000\u001a\u0004\b\b\u0010\\u0006\u0014"}, d2 = {"Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey$Cluster;", "T", "Lcom/google/maps/android/clustering/ClusterItem;", "Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey;", "cluster", "Lcom/google/maps/android/clustering/Cluster;", "<init>", "(Lcom/google/maps/android/clustering/Cluster;)V", "getCluster", "()Lcom/google/maps/android/clustering/Cluster;", "component1", "copy", "equals", "", "other", "", "hashCode", "", "toString", "", "maps-compose-utils_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public static final /* data */ class Cluster<T extends ClusterItem> extends ViewKey<T> {
public static final int $stable = 8;
private final com.google.maps.android.clustering.Cluster<T> cluster;
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Cluster copy$default(Cluster cluster, com.google.maps.android.clustering.Cluster cluster2, int i, Object obj) {
if ((i & 1) != 0) {
cluster2 = cluster.cluster;
}
return cluster.copy(cluster2);
}
public final com.google.maps.android.clustering.Cluster<T> component1() {
return this.cluster;
}
public final Cluster<T> copy(com.google.maps.android.clustering.Cluster<T> cluster) {
Intrinsics.checkNotNullParameter(cluster, "cluster");
return new Cluster<>(cluster);
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
return (other instanceof Cluster) && Intrinsics.areEqual(this.cluster, ((Cluster) other).cluster);
}
public int hashCode() {
return this.cluster.hashCode();
}
public String toString() {
return "Cluster(cluster=" + this.cluster + ')';
}
public final com.google.maps.android.clustering.Cluster<T> getCluster() {
return this.cluster;
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public Cluster(com.google.maps.android.clustering.Cluster<T> cluster) {
super(null);
Intrinsics.checkNotNullParameter(cluster, "cluster");
this.cluster = cluster;
}
}
/* JADX INFO: compiled from: ClusterRenderer.kt */
@Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0087\b\u0018\u0000*\b\b\u0002\u0010\u0001*\u00020\u00022\b\u0012\u0004\u0012\u0002H\u00010\u0003B\u000f\u0012\u0006\u0010\u0004\u001a\u00028\u0002¢\u0006\u0004\b\u0005\u0010\u0006J\u000e\u0010\n\u001a\u00028\u0002HÆ\u0003¢\u0006\u0002\u0010\bJ\u001e\u0010\u000b\u001a\b\u0012\u0004\u0012\u00028\u00020\u00002\b\b\u0002\u0010\u0004\u001a\u00028\u0002HÇ\u0001¢\u0006\u0002\u0010\fJ\u0013\u0010\r\u001a\u00020\u000e2\b\u0010\u000f\u001a\u0004\u0018\u00010\u0010H×\u0003J\t\u0010\u0011\u001a\u00020\u0012H×\u0001J\t\u0010\u0013\u001a\u00020\u0014H×\u0001R\u0013\u0010\u0004\u001a\u00028\u0002¢\u0006\n\n\u0002\u0010\t\u001a\u0004\b\u0007\u0010\\u0006\u0015"}, d2 = {"Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey$Item;", "T", "Lcom/google/maps/android/clustering/ClusterItem;", "Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey;", "item", "<init>", "(Lcom/google/maps/android/clustering/ClusterItem;)V", "getItem", "()Lcom/google/maps/android/clustering/ClusterItem;", "Lcom/google/maps/android/clustering/ClusterItem;", "component1", "copy", "(Lcom/google/maps/android/clustering/ClusterItem;)Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewKey$Item;", "equals", "", "other", "", "hashCode", "", "toString", "", "maps-compose-utils_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
public static final /* data */ class Item<T extends ClusterItem> extends ViewKey<T> {
public static final int $stable = 0;
private final T item;
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Item copy$default(Item item, ClusterItem clusterItem, int i, Object obj) {
if ((i & 1) != 0) {
clusterItem = item.item;
}
return item.copy(clusterItem);
}
public final T component1() {
return this.item;
}
public final Item<T> copy(T item) {
Intrinsics.checkNotNullParameter(item, "item");
return new Item<>(item);
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
return (other instanceof Item) && Intrinsics.areEqual(this.item, ((Item) other).item);
}
public int hashCode() {
return this.item.hashCode();
}
public String toString() {
return "Item(item=" + this.item + ')';
}
public final T getItem() {
return this.item;
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public Item(T item) {
super(null);
Intrinsics.checkNotNullParameter(item, "item");
this.item = item;
}
}
}
/* JADX INFO: compiled from: ClusterRenderer.kt */
@Metadata(d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\b\u0007\b\u0002\u0018\u00002\u00020\u0001B\u001d\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005¢\u0006\u0004\b\u0007\u0010\bR\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\nR\u0017\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005¢\u0006\b\n\u0000\u001a\u0004\b\u000b\u0010\\u0006\r"}, d2 = {"Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$ViewInfo;", "", "view", "Landroidx/compose/ui/platform/AbstractComposeView;", "onRemove", "Lkotlin/Function0;", "", "<init>", "(Landroidx/compose/ui/platform/AbstractComposeView;Lkotlin/jvm/functions/Function0;)V", "getView", "()Landroidx/compose/ui/platform/AbstractComposeView;", "getOnRemove", "()Lkotlin/jvm/functions/Function0;", "maps-compose-utils_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
private static final class ViewInfo {
private final Function0<Unit> onRemove;
private final AbstractComposeView view;
public ViewInfo(AbstractComposeView view, Function0<Unit> onRemove) {
Intrinsics.checkNotNullParameter(view, "view");
Intrinsics.checkNotNullParameter(onRemove, "onRemove");
this.view = view;
this.onRemove = onRemove;
}
public final AbstractComposeView getView() {
return this.view;
}
public final Function0<Unit> getOnRemove() {
return this.onRemove;
}
}
/* JADX INFO: Access modifiers changed from: private */
/* JADX INFO: compiled from: ClusterRenderer.kt */
@Metadata(d1 = {"\u0000(\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\f\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0002\u0018\u00002\u00020\u0001B\"\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0011\u0010\u0004\u001a\r\u0012\u0004\u0012\u00020\u00060\u0005¢\u0006\u0002\b\u0007¢\u0006\u0004\b\b\u0010\tJ\r\u0010\u0010\u001a\u00020\u0006H\u0017¢\u0006\u0002\u0010\u0011J\u0018\u0010\u0012\u001a\u00020\u00062\u0006\u0010\u0013\u001a\u00020\u00142\u0006\u0010\u0015\u001a\u00020\u0014H\u0016R\u001b\u0010\u0004\u001a\r\u0012\u0004\u0012\u00020\u00060\u0005¢\u0006\u0002\b\u0007X\u0082\u0004¢\u0006\u0004\n\u0002\u0010\nR\"\u0010\u000b\u001a\n\u0012\u0004\u0012\u00020\u0006\u0018\u00010\u0005X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\f\u0010\r\"\u0004\b\u000e\u0010\u000f¨\u0006\u0016"}, d2 = {"Lcom/google/maps/android/compose/clustering/ComposeUiClusterRenderer$InvalidatingComposeView;", "Landroidx/compose/ui/platform/AbstractComposeView;", "context", "Landroid/content/Context;", "content", "Lkotlin/Function0;", "", "Landroidx/compose/runtime/Composable;", "<init>", "(Landroid/content/Context;Lkotlin/jvm/functions/Function2;)V", "Lkotlin/jvm/functions/Function2;", "onInvalidate", "getOnInvalidate", "()Lkotlin/jvm/functions/Function0;", "setOnInvalidate", "(Lkotlin/jvm/functions/Function0;)V", "Content", "(Landroidx/compose/runtime/Composer;I)V", "onDescendantInvalidated", "child", "Landroid/view/View;", "target", "maps-compose-utils_release"}, k = 1, mv = {2, 0, 0}, xi = 48)
static final class InvalidatingComposeView extends AbstractComposeView {
private final Function2<Composer, Integer, Unit> content;
private Function0<Unit> onInvalidate;
/* JADX INFO: Access modifiers changed from: private */
public static final Unit Content$lambda$0(InvalidatingComposeView tmp0_rcvr, int i, Composer composer, int i2) {
Intrinsics.checkNotNullParameter(tmp0_rcvr, "$tmp0_rcvr");
tmp0_rcvr.Content(composer, RecomposeScopeImplKt.updateChangedFlags(i | 1));
return Unit.INSTANCE;
}
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
/* JADX WARN: Multi-variable type inference failed */
public InvalidatingComposeView(Context context, Function2<? super Composer, ? super Integer, Unit> content) {
super(context, null, 0, 6, null);
Intrinsics.checkNotNullParameter(context, "context");
Intrinsics.checkNotNullParameter(content, "content");
this.content = content;
}
public final Function0<Unit> getOnInvalidate() {
return this.onInvalidate;
}
public final void setOnInvalidate(Function0<Unit> function0) {
this.onInvalidate = function0;
}
@Override // androidx.compose.ui.platform.AbstractComposeView
public void Content(Composer composer, final int i) {
Composer composerStartRestartGroup = composer.startRestartGroup(77023790);
this.content.invoke(composerStartRestartGroup, 0);
ScopeUpdateScope scopeUpdateScopeEndRestartGroup = composerStartRestartGroup.endRestartGroup();
if (scopeUpdateScopeEndRestartGroup != null) {
scopeUpdateScopeEndRestartGroup.updateScope(new Function2() { // from class: com.google.maps.android.compose.clustering.ComposeUiClusterRenderer$InvalidatingComposeView$$ExternalSyntheticLambda0
@Override // kotlin.jvm.functions.Function2
public final Object invoke(Object obj, Object obj2) {
return ComposeUiClusterRenderer.InvalidatingComposeView.Content$lambda$0(this.f$0, i, (Composer) obj, ((Integer) obj2).intValue());
}
});
}
}
@Override // android.view.ViewGroup, android.view.ViewParent
public void onDescendantInvalidated(View child, View target) {
Intrinsics.checkNotNullParameter(child, "child");
Intrinsics.checkNotNullParameter(target, "target");
super.onDescendantInvalidated(child, target);
Function0<Unit> function0 = this.onInvalidate;
if (function0 != null) {
function0.invoke();
}
}
}
}