package com.discord.widgets.channels.list; import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.view.View; import android.view.ViewGroup; import android.view.ViewStub; import android.widget.FrameLayout; import android.widget.TextView; import androidx.activity.result.ActivityResultLauncher; import androidx.appcompat.widget.Toolbar; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; import b.d.b.a.a; import com.discord.R; import com.discord.api.guild.GuildFeature; import com.discord.app.AppFragment; import com.discord.databinding.WidgetChannelsListBinding; import com.discord.models.guild.Guild; import com.discord.stores.StoreNavigation; import com.discord.stores.StoreStream; import com.discord.utilities.color.ColorCompat; import com.discord.utilities.color.ColorCompatKt; import com.discord.utilities.dimen.DimenUtils; import com.discord.utilities.drawable.DrawableCompat; import com.discord.utilities.hubs.HubUtilsKt; import com.discord.utilities.icon.IconUtils; import com.discord.utilities.images.MGImages; import com.discord.utilities.mg_recycler.MGRecyclerAdapter; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.widgets.friends.EmptyFriendsStateView; import com.discord.widgets.status.WidgetGlobalStatusIndicatorState; import com.discord.widgets.tabs.BottomNavViewObserver; import com.facebook.drawee.view.SimpleDraweeView; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import d0.z.d.m; import java.util.Objects; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; import rx.Observable; /* compiled from: WidgetChannelsList.kt */ public final class WidgetChannelsList extends AppFragment { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetChannelsList.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChannelsListBinding;", 0)}; public static final String ANALYTICS_SOURCE = "Channels List"; public static final float BANNER_TEXT_SHADOW_DX = 0.0f; public static final float BANNER_TEXT_SHADOW_DY = 4.0f; public static final float BANNER_TEXT_SHADOW_RADIUS = 1.0f; public static final Companion Companion = new Companion(null); private final ActivityResultLauncher activityResult = HubUtilsKt.getAddServerActivityResultHandler(this); private WidgetChannelsListAdapter adapter; private final MGImages.DistinctChangeDetector bannerChangeDetector = new MGImages.DistinctChangeDetector(); private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelsList$binding$2.INSTANCE, null, 2, null); private final BottomNavViewObserver bottomNavViewObserver = BottomNavViewObserver.Companion.getINSTANCE(); private WidgetChannelListUnreads channelListUnreads; private final WidgetGlobalStatusIndicatorState globalStatusIndicatorStateObserver = WidgetGlobalStatusIndicatorState.Provider.get(); private boolean isCollapsed; private Long selectedGuildId; private final StoreNavigation storeNavigation = StoreStream.Companion.getNavigation(); /* compiled from: WidgetChannelsList.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } } public WidgetChannelsList() { super(R.layout.widget_channels_list); } public static final /* synthetic */ void access$ackPremiumGuildHint(WidgetChannelsList widgetChannelsList) { widgetChannelsList.ackPremiumGuildHint(); } public static final /* synthetic */ void access$configureHeaderColors(WidgetChannelsList widgetChannelsList, Guild guild, boolean z2) { widgetChannelsList.configureHeaderColors(guild, z2); } public static final /* synthetic */ void access$configureHeaderIcons(WidgetChannelsList widgetChannelsList, Guild guild, boolean z2) { widgetChannelsList.configureHeaderIcons(guild, z2); } public static final /* synthetic */ void access$configureUI(WidgetChannelsList widgetChannelsList, WidgetChannelListModel widgetChannelListModel) { widgetChannelsList.configureUI(widgetChannelListModel); } public static final /* synthetic */ ActivityResultLauncher access$getActivityResult$p(WidgetChannelsList widgetChannelsList) { return widgetChannelsList.activityResult; } public static final /* synthetic */ WidgetChannelsListAdapter access$getAdapter$p(WidgetChannelsList widgetChannelsList) { WidgetChannelsListAdapter widgetChannelsListAdapter = widgetChannelsList.adapter; if (widgetChannelsListAdapter == null) { m.throwUninitializedPropertyAccessException("adapter"); } return widgetChannelsListAdapter; } public static final /* synthetic */ WidgetChannelsListBinding access$getBinding$p(WidgetChannelsList widgetChannelsList) { return widgetChannelsList.getBinding(); } public static final /* synthetic */ WidgetChannelListUnreads access$getChannelListUnreads$p(WidgetChannelsList widgetChannelsList) { return widgetChannelsList.channelListUnreads; } public static final /* synthetic */ Long access$getSelectedGuildId$p(WidgetChannelsList widgetChannelsList) { return widgetChannelsList.selectedGuildId; } public static final /* synthetic */ StoreNavigation access$getStoreNavigation$p(WidgetChannelsList widgetChannelsList) { return widgetChannelsList.storeNavigation; } public static final /* synthetic */ void access$handleGlobalStatusIndicatorState(WidgetChannelsList widgetChannelsList, WidgetGlobalStatusIndicatorState.State state) { widgetChannelsList.handleGlobalStatusIndicatorState(state); } public static final /* synthetic */ boolean access$isCollapsed$p(WidgetChannelsList widgetChannelsList) { return widgetChannelsList.isCollapsed; } public static final /* synthetic */ void access$setAdapter$p(WidgetChannelsList widgetChannelsList, WidgetChannelsListAdapter widgetChannelsListAdapter) { widgetChannelsList.adapter = widgetChannelsListAdapter; } public static final /* synthetic */ void access$setChannelListUnreads$p(WidgetChannelsList widgetChannelsList, WidgetChannelListUnreads widgetChannelListUnreads) { widgetChannelsList.channelListUnreads = widgetChannelListUnreads; } public static final /* synthetic */ void access$setCollapsed$p(WidgetChannelsList widgetChannelsList, boolean z2) { widgetChannelsList.isCollapsed = z2; } public static final /* synthetic */ void access$setSelectedGuildId$p(WidgetChannelsList widgetChannelsList, Long l) { widgetChannelsList.selectedGuildId = l; } private final void ackPremiumGuildHint() { StoreStream.Companion.getNux().setPremiumGuildHintGuildId(null); } private final void configureBottomNavSpace() { ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(this.bottomNavViewObserver.observeHeight(), this, null, 2, null), WidgetChannelsList.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelsList$configureBottomNavSpace$1(this), 62, (Object) null); } private final void configureHeaderColors(Guild guild, boolean z2) { getBinding().g.setTextColor(getTintColor(requireContext(), guild, this.isCollapsed)); getBinding().g.setShadowLayer(1.0f, 0.0f, 4.0f, (!z2 || this.isCollapsed) ? ColorCompat.getThemedColor(this, (int) R.attr.colorBackgroundSecondary) : ColorCompat.getColor(this, (int) R.color.black_alpha_80)); FrameLayout frameLayout = getBinding().e; m.checkNotNullExpressionValue(frameLayout, "binding.channelsListBannerForeground"); int i = 0; if (!(z2 && !this.isCollapsed)) { i = 8; } frameLayout.setVisibility(i); } /* JADX WARNING: Removed duplicated region for block: B:43:0x00c3 */ /* JADX WARNING: Removed duplicated region for block: B:44:0x00c5 */ /* JADX WARNING: Removed duplicated region for block: B:47:0x00e2 */ /* JADX WARNING: Removed duplicated region for block: B:48:0x00ee */ private final void configureHeaderIcons(Guild guild, boolean z2) { int i; Drawable drawable; if (guild != null) { if (guild.getFeatures().contains(GuildFeature.VERIFIED)) { i = getBinding().f2253b.a() ? R.drawable.ic_verified_badge : R.drawable.ic_verified_badge_banner; } else if (guild.getFeatures().contains(GuildFeature.PARTNERED)) { i = getBinding().f2253b.a() ? R.drawable.ic_partnered_badge : R.drawable.ic_partnered_badge_banner; } else if (guild.getPremiumTier() == 0 && guild.getPremiumSubscriptionCount() > 0) { i = getBinding().f2253b.a() ? R.drawable.ic_guild_nitro_progress : R.drawable.ic_guild_nitro_progress_banner; } else if (guild.getPremiumTier() == 1) { i = getBinding().f2253b.a() ? R.drawable.ic_guild_badge_premium_tier_1 : R.drawable.ic_guild_badge_premium_tier_1_banner; } else if (guild.getPremiumTier() == 2) { i = getBinding().f2253b.a() ? R.drawable.ic_guild_badge_premium_tier_2 : R.drawable.ic_guild_badge_premium_tier_2_banner; } else if (guild.getPremiumTier() == 3) { i = getBinding().f2253b.a() ? R.drawable.ic_guild_badge_premium_tier_3 : R.drawable.ic_guild_badge_premium_tier_3_banner; } TextView textView = getBinding().g; Drawable drawable2 = i != 0 ? null : ContextCompat.getDrawable(requireContext(), i); drawable = ContextCompat.getDrawable(requireContext(), DrawableCompat.getThemedDrawableRes$default(requireContext(), (int) R.attr.ic_more, 0, 2, (Object) null)); if (drawable == null) { ColorCompatKt.setTint(drawable, getTintColor(requireContext(), guild, z2), false); } else { drawable = null; } textView.setCompoundDrawablesWithIntrinsicBounds(drawable2, (Drawable) null, drawable, (Drawable) null); } i = 0; TextView textView = getBinding().g; if (i != 0) { } drawable = ContextCompat.getDrawable(requireContext(), DrawableCompat.getThemedDrawableRes$default(requireContext(), (int) R.attr.ic_more, 0, 2, (Object) null)); if (drawable == null) { } textView.setCompoundDrawablesWithIntrinsicBounds(drawable2, (Drawable) null, drawable, (Drawable) null); } private final void configureUI(WidgetChannelListModel widgetChannelListModel) { Guild selectedGuild = widgetChannelListModel.getSelectedGuild(); String str = null; boolean z2 = true; int i = 0; boolean z3 = (selectedGuild != null ? selectedGuild.getBanner() : null) != null; EmptyFriendsStateView emptyFriendsStateView = getBinding().p; m.checkNotNullExpressionValue(emptyFriendsStateView, "binding.widgetChannelsListEmptyFriendsStateView"); emptyFriendsStateView.setVisibility(widgetChannelListModel.getShowEmptyState() ? 0 : 8); RecyclerView recyclerView = getBinding().c; m.checkNotNullExpressionValue(recyclerView, "binding.channelsList"); recyclerView.setVisibility(widgetChannelListModel.getShowEmptyState() ? 4 : 0); if (!m.areEqual(this.selectedGuildId, selectedGuild != null ? Long.valueOf(selectedGuild.getId()) : null)) { if (z3) { getBinding().c.scrollToPosition(0); getBinding().f2253b.setExpanded(true); configureHeaderColors(widgetChannelListModel.getSelectedGuild(), true); } Long valueOf = selectedGuild != null ? Long.valueOf(selectedGuild.getId()) : null; this.selectedGuildId = valueOf; if (valueOf != null) { long longValue = valueOf.longValue(); WidgetChannelsListAdapter widgetChannelsListAdapter = this.adapter; if (widgetChannelsListAdapter == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter.setSelectedGuildId(longValue); } } WidgetChannelsListAdapter widgetChannelsListAdapter2 = this.adapter; if (widgetChannelsListAdapter2 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter2.setData(widgetChannelListModel.getItems()); CollapsingToolbarLayout collapsingToolbarLayout = getBinding().n; m.checkNotNullExpressionValue(collapsingToolbarLayout, "binding.collapsingToolbar"); collapsingToolbarLayout.setVisibility(widgetChannelListModel.isGuildSelected() ? 0 : 8); CollapsingToolbarLayout collapsingToolbarLayout2 = getBinding().n; m.checkNotNullExpressionValue(collapsingToolbarLayout2, "binding.collapsingToolbar"); ViewGroup.LayoutParams layoutParams = collapsingToolbarLayout2.getLayoutParams(); if (!(layoutParams instanceof AppBarLayout.LayoutParams)) { layoutParams = null; } AppBarLayout.LayoutParams layoutParams2 = (AppBarLayout.LayoutParams) layoutParams; if (layoutParams2 != null) { layoutParams2.setScrollFlags((!widgetChannelListModel.isGuildSelected() || !z3) ? 0 : 5); } Toolbar toolbar = getBinding().j; m.checkNotNullExpressionValue(toolbar, "binding.channelsListPrivateChannelsHeader"); toolbar.setVisibility(!widgetChannelListModel.isGuildSelected() && !widgetChannelListModel.getShowEmptyState() ? 0 : 8); TextView textView = getBinding().k; m.checkNotNullExpressionValue(textView, "binding.channelsListSearch"); textView.setVisibility(widgetChannelListModel.isGuildSelected() ^ true ? 0 : 8); getBinding().g.setOnClickListener(new WidgetChannelsList$configureUI$3(this, selectedGuild)); TextView textView2 = getBinding().g; m.checkNotNullExpressionValue(textView2, "binding.channelsListHeader"); if (selectedGuild != null) { str = selectedGuild.getName(); } textView2.setText(str); configureHeaderIcons(selectedGuild, false); SimpleDraweeView simpleDraweeView = getBinding().d; m.checkNotNullExpressionValue(simpleDraweeView, "binding.channelsListBanner"); simpleDraweeView.setVisibility(z3 ? 0 : 8); FrameLayout frameLayout = getBinding().e; m.checkNotNullExpressionValue(frameLayout, "binding.channelsListBannerForeground"); if (!z3 || this.isCollapsed) { z2 = false; } frameLayout.setVisibility(z2 ? 0 : 8); if (z3) { SimpleDraweeView simpleDraweeView2 = getBinding().d; ViewGroup.LayoutParams layoutParams3 = simpleDraweeView2.getLayoutParams(); Objects.requireNonNull(layoutParams3, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams"); ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams3; marginLayoutParams.bottomMargin = !widgetChannelListModel.getStartsWithPaddedElement() ? DimenUtils.dpToPixels(8) : 0; simpleDraweeView2.setLayoutParams(marginLayoutParams); boolean canHaveAnimatedBanner = selectedGuild != null ? selectedGuild.canHaveAnimatedBanner() : false; m.checkNotNullExpressionValue(simpleDraweeView2, "this"); MGImages.setImage$default(simpleDraweeView2, IconUtils.INSTANCE.getBannerForGuild(selectedGuild, Integer.valueOf(simpleDraweeView2.getResources().getDimensionPixelSize(R.dimen.nav_panel_width)), canHaveAnimatedBanner), 0, 0, false, null, this.bannerChangeDetector, 60, null); } getBinding().f2253b.setOnPercentCollapsedCallback(new WidgetChannelsList$configureUI$5(this, selectedGuild, widgetChannelListModel, z3)); ConstraintLayout constraintLayout = getBinding().h; m.checkNotNullExpressionValue(constraintLayout, "binding.channelsListPremiumGuildHint"); if (!widgetChannelListModel.getShowPremiumGuildHint()) { i = 8; } constraintLayout.setVisibility(i); } private final WidgetChannelsListBinding getBinding() { return (WidgetChannelsListBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final int getTintColor(Context context, Guild guild, boolean z2) { return ((guild != null ? guild.getBanner() : null) == null || z2) ? ColorCompat.getThemedColor(context, (int) R.attr.colorInteractiveActive) : ColorCompat.getColor(context, (int) R.color.white); } private final void handleGlobalStatusIndicatorState(WidgetGlobalStatusIndicatorState.State state) { if (state.isCustomBackground()) { unroundPanelCorners(); } else { roundPanelCorners(); } } private final void roundPanelCorners() { float dpToPixels = (float) DimenUtils.dpToPixels(8); getBinding().o.updateTopLeftRadius(dpToPixels); getBinding().o.updateTopRightRadius(dpToPixels); } private final void unroundPanelCorners() { getBinding().o.updateTopLeftRadius(0.0f); getBinding().o.updateTopRightRadius(0.0f); } @Override // com.discord.app.AppFragment public void onViewBound(View view) { m.checkNotNullParameter(view, "view"); super.onViewBound(view); getBinding().p.updateView(ANALYTICS_SOURCE); MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion; RecyclerView recyclerView = getBinding().c; m.checkNotNullExpressionValue(recyclerView, "binding.channelsList"); FragmentManager parentFragmentManager = getParentFragmentManager(); m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager"); WidgetChannelsListAdapter widgetChannelsListAdapter = (WidgetChannelsListAdapter) companion.configure(new WidgetChannelsListAdapter(recyclerView, parentFragmentManager)); this.adapter = widgetChannelsListAdapter; if (widgetChannelsListAdapter == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter.setOnSelectChannel(new WidgetChannelsList$onViewBound$1(this)); WidgetChannelsListAdapter widgetChannelsListAdapter2 = this.adapter; if (widgetChannelsListAdapter2 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter2.setOnSelectChannelOptions(new WidgetChannelsList$onViewBound$2(this)); WidgetChannelsListAdapter widgetChannelsListAdapter3 = this.adapter; if (widgetChannelsListAdapter3 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter3.setOnCallChannel(new WidgetChannelsList$onViewBound$3(this)); WidgetChannelsListAdapter widgetChannelsListAdapter4 = this.adapter; if (widgetChannelsListAdapter4 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter4.setOnSelectGuildRoleSubscriptionLockedChannel(new WidgetChannelsList$onViewBound$4(this)); WidgetChannelsListAdapter widgetChannelsListAdapter5 = this.adapter; if (widgetChannelsListAdapter5 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter5.setOnCollapseCategory(new WidgetChannelsList$onViewBound$5(this)); WidgetChannelsListAdapter widgetChannelsListAdapter6 = this.adapter; if (widgetChannelsListAdapter6 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter6.setOnSelectInvite(new WidgetChannelsList$onViewBound$6(this)); WidgetChannelsListAdapter widgetChannelsListAdapter7 = this.adapter; if (widgetChannelsListAdapter7 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter7.setOnSelectUserOptions(new WidgetChannelsList$onViewBound$7(this)); WidgetChannelsListAdapter widgetChannelsListAdapter8 = this.adapter; if (widgetChannelsListAdapter8 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter8.setOnViewGuildScheduledEvents(new WidgetChannelsList$onViewBound$8(this)); WidgetChannelsListAdapter widgetChannelsListAdapter9 = this.adapter; if (widgetChannelsListAdapter9 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter9.setOnViewGuildRoleSubscriptions(new WidgetChannelsList$onViewBound$9(this)); WidgetChannelsListAdapter widgetChannelsListAdapter10 = this.adapter; if (widgetChannelsListAdapter10 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter10.setOnAddServer(new WidgetChannelsList$onViewBound$10(this)); getBinding().k.setOnClickListener(new WidgetChannelsList$onViewBound$11(this)); getBinding().c.setHasFixedSize(false); RecyclerView recyclerView2 = getBinding().c; m.checkNotNullExpressionValue(recyclerView2, "binding.channelsList"); recyclerView2.setItemAnimator(null); ViewStub viewStub = getBinding().m; m.checkNotNullExpressionValue(viewStub, "binding.channelsListUnreadsStub"); RecyclerView recyclerView3 = getBinding().c; m.checkNotNullExpressionValue(recyclerView3, "binding.channelsList"); this.channelListUnreads = new WidgetChannelListUnreads(viewStub, recyclerView3, getBinding().f2253b, new WidgetChannelsList$onViewBound$12(this), 0, 0, false, 112, null); WidgetChannelsListAdapter widgetChannelsListAdapter11 = this.adapter; if (widgetChannelsListAdapter11 == null) { m.throwUninitializedPropertyAccessException("adapter"); } widgetChannelsListAdapter11.setOnUpdated(new WidgetChannelsList$onViewBound$13(this)); getBinding().i.setOnClickListener(new WidgetChannelsList$onViewBound$14(this)); getBinding().l.setOnClickListener(new WidgetChannelsList$onViewBound$15(this)); ViewCompat.setAccessibilityHeading(getBinding().g, true); ViewCompat.setAccessibilityHeading(getBinding().f, true); } @Override // com.discord.app.AppFragment public void onViewBoundOrOnResume() { super.onViewBoundOrOnResume(); Observable computationLatest = ObservableExtensionsKt.computationLatest(WidgetChannelListModel.Companion.get()); WidgetChannelsListAdapter widgetChannelsListAdapter = this.adapter; if (widgetChannelsListAdapter == null) { m.throwUninitializedPropertyAccessException("adapter"); } ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(computationLatest, this, widgetChannelsListAdapter), WidgetChannelsList.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelsList$onViewBoundOrOnResume$1(this), 62, (Object) null); if (getMostRecentIntent().getBooleanExtra("com.discord.intent.extra.EXTRA_OPEN_PANEL", false)) { StoreNavigation.setNavigationPanelAction$default(this.storeNavigation, StoreNavigation.PanelAction.OPEN, null, 2, null); getMostRecentIntent().removeExtra("com.discord.intent.extra.EXTRA_OPEN_PANEL"); } configureBottomNavSpace(); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(this.globalStatusIndicatorStateObserver.observeState(), this, null, 2, null), WidgetChannelsList.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelsList$onViewBoundOrOnResume$2(this), 62, (Object) null); } }