package com.discord.utilities; import android.graphics.Bitmap; import com.discord.utilities.colors.RepresentativeColors; import com.discord.utilities.images.MGImages; import com.discord.utilities.images.MGImagesBitmap; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1; import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2; import d0.o; import d0.z.d.m; import j0.k.b; import j0.l.e.k; import java.util.Map; import java.util.concurrent.TimeUnit; import kotlin.Pair; import rx.Observable; /* compiled from: ShareUtils.kt */ /* loaded from: classes.dex */ public final class ShareUtils$loadAdaptiveBitmaps$1 implements b> { public final /* synthetic */ int $fillMargins; public final /* synthetic */ int $fullBitmapSize; public final /* synthetic */ int $iconSize; /* compiled from: ShareUtils.kt */ /* renamed from: com.discord.utilities.ShareUtils$loadAdaptiveBitmaps$1$1 reason: invalid class name */ /* loaded from: classes.dex */ public static final class AnonymousClass1 implements b, Observable>> { public final /* synthetic */ RepresentativeColors $representativeColors; /* compiled from: ShareUtils.kt */ /* renamed from: com.discord.utilities.ShareUtils$loadAdaptiveBitmaps$1$1$1 reason: invalid class name and collision with other inner class name */ /* loaded from: classes.dex */ public static final class C02151 implements b> { public final /* synthetic */ Bitmap $bitmap; public final /* synthetic */ String $url; public C02151(String str, Bitmap bitmap) { this.$url = str; this.$bitmap = bitmap; } public final Pair call(Integer num) { String str = this.$url; MGImages mGImages = MGImages.INSTANCE; Bitmap bitmap = this.$bitmap; ShareUtils$loadAdaptiveBitmaps$1 shareUtils$loadAdaptiveBitmaps$1 = ShareUtils$loadAdaptiveBitmaps$1.this; int i = shareUtils$loadAdaptiveBitmaps$1.$iconSize; int i2 = shareUtils$loadAdaptiveBitmaps$1.$fullBitmapSize; return o.to(str, mGImages.centerBitmapInTransparentBitmap(bitmap, i, i, i2, i2, shareUtils$loadAdaptiveBitmaps$1.$fillMargins, num != null ? num.intValue() : 0)); } } public AnonymousClass1(RepresentativeColors representativeColors) { this.$representativeColors = representativeColors; } @Override // j0.k.b public /* bridge */ /* synthetic */ Observable> call(Map.Entry entry) { return call2((Map.Entry) entry); } /* renamed from: call reason: avoid collision after fix types in other method */ public final Observable> call2(Map.Entry entry) { Observable observable; String key = entry.getKey(); Bitmap value = entry.getValue(); if (value.getWidth() <= 0 || value.getHeight() <= 0 || value.getPixel(0, 0) != 0) { observable = new k<>(0); } else { RepresentativeColors.handleBitmap$default(this.$representativeColors, key, value, null, 4, null); Observable G = this.$representativeColors.observeRepresentativeColor(key).y(ObservableExtensionsKt$filterNull$1.INSTANCE).G(ObservableExtensionsKt$filterNull$2.INSTANCE); m.checkNotNullExpressionValue(G, "filter { it != null }.map { it!! }"); observable = G.z().c0(2L, TimeUnit.SECONDS).M(ShareUtils$loadAdaptiveBitmaps$1$1$representativeColor$1.INSTANCE); } return observable.G(new C02151(key, value)); } } /* compiled from: ShareUtils.kt */ /* renamed from: com.discord.utilities.ShareUtils$loadAdaptiveBitmaps$1$2 reason: invalid class name */ /* loaded from: classes.dex */ public static final class AnonymousClass2 implements b, MGImagesBitmap.CloseableBitmaps> { public final /* synthetic */ MGImagesBitmap.CloseableBitmaps $iconBitmaps; public AnonymousClass2(MGImagesBitmap.CloseableBitmaps closeableBitmaps) { this.$iconBitmaps = closeableBitmaps; } /* renamed from: call reason: avoid collision after fix types in other method */ public final MGImagesBitmap.CloseableBitmaps call2(Map map) { this.$iconBitmaps.close(); m.checkNotNullExpressionValue(map, "bitmaps"); return new MGImagesBitmap.CloseableBitmaps(map, false); } @Override // j0.k.b public /* bridge */ /* synthetic */ MGImagesBitmap.CloseableBitmaps call(Map map) { return call2((Map) map); } } public ShareUtils$loadAdaptiveBitmaps$1(int i, int i2, int i3) { this.$iconSize = i; this.$fullBitmapSize = i2; this.$fillMargins = i3; } public final Observable call(MGImagesBitmap.CloseableBitmaps closeableBitmaps) { Observable n = Observable.B(closeableBitmaps.entrySet()).n(new AnonymousClass1(new RepresentativeColors())); m.checkNotNullExpressionValue(n, "Observable.from(iconBitm… }\n }"); return ObservableExtensionsKt.toMap(n).G(new AnonymousClass2(closeableBitmaps)); } }