package com.discord.utilities; import android.content.Context; import android.content.pm.ShortcutManager; import android.graphics.Bitmap; import android.os.Build; import androidx.core.content.pm.ShortcutInfoCompat; import androidx.core.content.pm.ShortcutManagerCompat; import androidx.core.graphics.drawable.IconCompat; import com.discord.utilities.images.MGImagesBitmap; import d0.t.n; import d0.y.b; import d0.z.d.m; import d0.z.d.o; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import kotlin.Pair; import kotlin.Unit; import kotlin.jvm.functions.Function1; /* compiled from: ShareUtils.kt */ public final class ShareUtils$updateDirectShareTargets$5 extends o implements Function1>, ? extends MGImagesBitmap.CloseableBitmaps>, Unit> { public final /* synthetic */ Context $context; /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public ShareUtils$updateDirectShareTargets$5(Context context) { super(1); this.$context = context; } /* Return type fixed from 'java.lang.Object' to match base method */ /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */ @Override // kotlin.jvm.functions.Function1 public /* bridge */ /* synthetic */ Unit invoke(Pair>, ? extends MGImagesBitmap.CloseableBitmaps> pair) { invoke((Pair>, MGImagesBitmap.CloseableBitmaps>) pair); return Unit.a; } /* JADX WARNING: Code restructure failed: missing block: B:33:0x00de, code lost: r1 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:34:0x00df, code lost: d0.y.b.closeFinally(r9, r0); */ /* JADX WARNING: Code restructure failed: missing block: B:35:0x00e2, code lost: throw r1; */ public final void invoke(Pair>, MGImagesBitmap.CloseableBitmaps> pair) { List list = (List) pair.component1(); MGImagesBitmap.CloseableBitmaps component2 = pair.component2(); m.checkNotNullExpressionValue(list, "channelAndIconUriPairs"); LinkedHashMap linkedHashMap = new LinkedHashMap(); for (Object obj : list) { Boolean valueOf = Boolean.valueOf(((ChannelShortcutInfo) ((Pair) obj).component1()).isPinnedOnly()); Object obj2 = linkedHashMap.get(valueOf); if (obj2 == null) { obj2 = new ArrayList(); linkedHashMap.put(valueOf, obj2); } Pair pair2 = (Pair) obj; ChannelShortcutInfo channelShortcutInfo = (ChannelShortcutInfo) pair2.component1(); ((List) obj2).add(ShareUtils.access$toShortcutInfo(ShareUtils.INSTANCE, channelShortcutInfo.getChannel(), this.$context, IconCompat.createWithAdaptiveBitmap((Bitmap) component2.get((Object) ((String) pair2.component2()))), channelShortcutInfo.getRank())); } Object obj3 = linkedHashMap.get(Boolean.FALSE); if (obj3 == null) { obj3 = n.emptyList(); } List list2 = (List) obj3; Object obj4 = linkedHashMap.get(Boolean.TRUE); if (obj4 == null) { obj4 = n.emptyList(); } List list3 = (List) obj4; if (Build.VERSION.SDK_INT >= 25) { ShortcutManager shortcutManager = (ShortcutManager) this.$context.getSystemService(ShortcutManager.class); if (shortcutManager != null) { ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(list2, 10)); for (ShortcutInfoCompat shortcutInfoCompat : list2) { arrayList.add(shortcutInfoCompat.toShortcutInfo()); } shortcutManager.setDynamicShortcuts(arrayList); } } else { ShortcutManagerCompat.removeAllDynamicShortcuts(this.$context); ShortcutManagerCompat.addDynamicShortcuts(this.$context, list2); } ShortcutManagerCompat.updateShortcuts(this.$context, list3); b.closeFinally(component2, null); } }