493 lines
25 KiB
Java
493 lines
25 KiB
Java
package com.discord.widgets.channels;
|
|
|
|
import android.content.Context;
|
|
import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.PopupMenu;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.DrawableRes;
|
|
import androidx.core.view.ViewKt;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.lifecycle.Lifecycle;
|
|
import c.a.d.f0;
|
|
import c.a.d.h0;
|
|
import c.d.b.a.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.R;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetChannelTopicBinding;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.utilities.channel.GuildChannelIconType;
|
|
import com.discord.utilities.channel.GuildChannelIconUtilsKt;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.textprocessing.AstRenderer;
|
|
import com.discord.utilities.textprocessing.MessageRenderContext;
|
|
import com.discord.utilities.view.text.LinkifiedTextView;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.channels.WidgetChannelTopicViewModel;
|
|
import com.facebook.drawee.span.DraweeSpanStringBuilder;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.google.android.material.badge.BadgeDrawable;
|
|
import d0.g0.t;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import kotlin.Lazy;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetChannelTopic.kt */
|
|
public final class WidgetChannelTopic extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.a0(WidgetChannelTopic.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChannelTopicBinding;", 0)};
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelTopic$binding$2.INSTANCE, null, 2, null);
|
|
private boolean isDm;
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: WidgetChannelTopic.kt */
|
|
public static final class RenderedTopic {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int MAX_LINES = 40;
|
|
public static final int MIN_LINES = 2;
|
|
private final int autoLinkMask;
|
|
private final CharSequence channelName;
|
|
private final CharSequence topic;
|
|
|
|
/* compiled from: WidgetChannelTopic.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public RenderedTopic() {
|
|
this(null, null, 0, 7, null);
|
|
}
|
|
|
|
public RenderedTopic(CharSequence charSequence, CharSequence charSequence2, int i) {
|
|
this.channelName = charSequence;
|
|
this.topic = charSequence2;
|
|
this.autoLinkMask = i;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ RenderedTopic(CharSequence charSequence, CharSequence charSequence2, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this((i2 & 1) != 0 ? "" : charSequence, (i2 & 2) != 0 ? null : charSequence2, (i2 & 4) != 0 ? 0 : i);
|
|
}
|
|
|
|
public static /* synthetic */ RenderedTopic copy$default(RenderedTopic renderedTopic, CharSequence charSequence, CharSequence charSequence2, int i, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
charSequence = renderedTopic.channelName;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
charSequence2 = renderedTopic.topic;
|
|
}
|
|
if ((i2 & 4) != 0) {
|
|
i = renderedTopic.autoLinkMask;
|
|
}
|
|
return renderedTopic.copy(charSequence, charSequence2, i);
|
|
}
|
|
|
|
public final CharSequence component1() {
|
|
return this.channelName;
|
|
}
|
|
|
|
public final CharSequence component2() {
|
|
return this.topic;
|
|
}
|
|
|
|
public final int component3() {
|
|
return this.autoLinkMask;
|
|
}
|
|
|
|
public final RenderedTopic copy(CharSequence charSequence, CharSequence charSequence2, int i) {
|
|
return new RenderedTopic(charSequence, charSequence2, i);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof RenderedTopic)) {
|
|
return false;
|
|
}
|
|
RenderedTopic renderedTopic = (RenderedTopic) obj;
|
|
return m.areEqual(this.channelName, renderedTopic.channelName) && m.areEqual(this.topic, renderedTopic.topic) && this.autoLinkMask == renderedTopic.autoLinkMask;
|
|
}
|
|
|
|
public final int getAutoLinkMask() {
|
|
return this.autoLinkMask;
|
|
}
|
|
|
|
public final CharSequence getChannelName() {
|
|
return this.channelName;
|
|
}
|
|
|
|
public final CharSequence getTopic() {
|
|
return this.topic;
|
|
}
|
|
|
|
public int hashCode() {
|
|
CharSequence charSequence = this.channelName;
|
|
int i = 0;
|
|
int hashCode = (charSequence != null ? charSequence.hashCode() : 0) * 31;
|
|
CharSequence charSequence2 = this.topic;
|
|
if (charSequence2 != null) {
|
|
i = charSequence2.hashCode();
|
|
}
|
|
return ((hashCode + i) * 31) + this.autoLinkMask;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder P = a.P("RenderedTopic(channelName=");
|
|
P.append(this.channelName);
|
|
P.append(", topic=");
|
|
P.append(this.topic);
|
|
P.append(", autoLinkMask=");
|
|
return a.z(P, this.autoLinkMask, ")");
|
|
}
|
|
}
|
|
|
|
public WidgetChannelTopic() {
|
|
super(R.layout.widget_channel_topic);
|
|
WidgetChannelTopic$viewModel$2 widgetChannelTopic$viewModel$2 = WidgetChannelTopic$viewModel$2.INSTANCE;
|
|
f0 f0Var = new f0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetChannelTopicViewModel.class), new WidgetChannelTopic$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetChannelTopic$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureEllipsis(WidgetChannelTopic widgetChannelTopic) {
|
|
widgetChannelTopic.configureEllipsis();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetChannelTopic widgetChannelTopic, WidgetChannelTopicViewModel.ViewState viewState) {
|
|
widgetChannelTopic.configureUI(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChannelTopicBinding access$getBinding$p(WidgetChannelTopic widgetChannelTopic) {
|
|
return widgetChannelTopic.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChannelTopicViewModel access$getViewModel$p(WidgetChannelTopic widgetChannelTopic) {
|
|
return widgetChannelTopic.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleEvent(WidgetChannelTopic widgetChannelTopic, WidgetChannelTopicViewModel.Event event) {
|
|
widgetChannelTopic.handleEvent(event);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onClickMore(WidgetChannelTopic widgetChannelTopic, WidgetChannelTopicViewModel.ViewState viewState) {
|
|
widgetChannelTopic.onClickMore(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onToggleTopicExpansionState(WidgetChannelTopic widgetChannelTopic) {
|
|
widgetChannelTopic.onToggleTopicExpansionState();
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:6:0x001c, code lost:
|
|
if ((r2.length() > 0) == true) goto L_0x0020;
|
|
*/
|
|
private final void configureChannelTopicTitle(RenderedTopic renderedTopic) {
|
|
LinkifiedTextView linkifiedTextView = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.channelTopicTitle");
|
|
CharSequence topic = renderedTopic.getTopic();
|
|
boolean z2 = true;
|
|
int i = 0;
|
|
if (topic != null) {
|
|
}
|
|
z2 = false;
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
linkifiedTextView.setVisibility(i);
|
|
LinkifiedTextView linkifiedTextView2 = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.channelTopicTitle");
|
|
linkifiedTextView2.setAutoLinkMask(renderedTopic.getAutoLinkMask());
|
|
CharSequence topic2 = renderedTopic.getTopic();
|
|
if (topic2 instanceof DraweeSpanStringBuilder) {
|
|
getBinding().g.setDraweeSpanStringBuilder((DraweeSpanStringBuilder) topic2);
|
|
return;
|
|
}
|
|
LinkifiedTextView linkifiedTextView3 = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView3, "binding.channelTopicTitle");
|
|
linkifiedTextView3.setText(topic2);
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:11:0x005c */
|
|
private final void configureEllipsis() {
|
|
boolean z2;
|
|
Lifecycle lifecycle = getLifecycle();
|
|
m.checkNotNullExpressionValue(lifecycle, "lifecycle");
|
|
if (lifecycle.getCurrentState().isAtLeast(Lifecycle.State.INITIALIZED)) {
|
|
getBinding().d.setOnClickListener(new WidgetChannelTopic$configureEllipsis$1(this));
|
|
ImageView imageView = getBinding().d;
|
|
m.checkNotNullExpressionValue(imageView, "binding.channelTopicEllipsis");
|
|
int i = 0;
|
|
if (!this.isDm) {
|
|
LinkifiedTextView linkifiedTextView = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.channelTopicTitle");
|
|
if (linkifiedTextView.getLineCount() > 2) {
|
|
LinkifiedTextView linkifiedTextView2 = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView2, "binding.channelTopicTitle");
|
|
if (linkifiedTextView2.getMaxLines() != 40) {
|
|
z2 = true;
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
imageView.setVisibility(i);
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
if (!z2) {
|
|
}
|
|
imageView.setVisibility(i);
|
|
}
|
|
}
|
|
|
|
private final void configureUI(WidgetChannelTopicViewModel.ViewState viewState) {
|
|
RenderedTopic renderedTopic;
|
|
boolean z2;
|
|
int i = 8;
|
|
boolean z3 = true;
|
|
if (viewState instanceof WidgetChannelTopicViewModel.ViewState.NoChannel) {
|
|
View view = getView();
|
|
if (view != null) {
|
|
ViewKt.setVisible(view, false);
|
|
}
|
|
ImageView imageView = getBinding().e;
|
|
m.checkNotNullExpressionValue(imageView, "binding.channelTopicMoreIcon");
|
|
imageView.setVisibility(8);
|
|
setChannelIcon(GuildChannelIconUtilsKt.mapGuildChannelTypeToIcon(GuildChannelIconType.Text.INSTANCE));
|
|
renderedTopic = new RenderedTopic(null, null, 0, 7, null);
|
|
} else if (viewState instanceof WidgetChannelTopicViewModel.ViewState.Guild) {
|
|
View view2 = getView();
|
|
if (view2 != null) {
|
|
ViewKt.setVisible(view2, true);
|
|
}
|
|
ImageView imageView2 = getBinding().e;
|
|
m.checkNotNullExpressionValue(imageView2, "binding.channelTopicMoreIcon");
|
|
imageView2.setVisibility(8);
|
|
setChannelIcon(GuildChannelIconUtilsKt.mapGuildChannelTypeToIcon(((WidgetChannelTopicViewModel.ViewState.Guild) viewState).getChannelIconType()));
|
|
if (viewState instanceof WidgetChannelTopicViewModel.ViewState.Guild.DefaultTopic) {
|
|
renderedTopic = getRenderedTopicForDefaultTopic((WidgetChannelTopicViewModel.ViewState.Guild.DefaultTopic) viewState);
|
|
} else {
|
|
Objects.requireNonNull(viewState, "null cannot be cast to non-null type com.discord.widgets.channels.WidgetChannelTopicViewModel.ViewState.Guild.Topic");
|
|
renderedTopic = getRenderedTopicForTopic((WidgetChannelTopicViewModel.ViewState.Guild.Topic) viewState);
|
|
}
|
|
} else if (viewState instanceof WidgetChannelTopicViewModel.ViewState.DM) {
|
|
View view3 = getView();
|
|
if (view3 != null) {
|
|
ViewKt.setVisible(view3, true);
|
|
}
|
|
ImageView imageView3 = getBinding().e;
|
|
m.checkNotNullExpressionValue(imageView3, "binding.channelTopicMoreIcon");
|
|
imageView3.setVisibility(0);
|
|
setChannelIcon(R.drawable.ic_direct_message_header);
|
|
WidgetChannelTopicViewModel.ViewState.DM dm = (WidgetChannelTopicViewModel.ViewState.DM) viewState;
|
|
getBinding().b.configure(dm.getGuildMembers());
|
|
renderedTopic = new RenderedTopic(dm.getRecipientName(), null, 0, 6, null);
|
|
} else if (viewState instanceof WidgetChannelTopicViewModel.ViewState.GDM) {
|
|
View view4 = getView();
|
|
if (view4 != null) {
|
|
ViewKt.setVisible(view4, true);
|
|
}
|
|
ImageView imageView4 = getBinding().e;
|
|
m.checkNotNullExpressionValue(imageView4, "binding.channelTopicMoreIcon");
|
|
imageView4.setVisibility(0);
|
|
WidgetChannelTopicViewModel.ViewState.GDM gdm = (WidgetChannelTopicViewModel.ViewState.GDM) viewState;
|
|
setChannelIconForGDM(gdm.getChannel());
|
|
renderedTopic = getRenderedTopicForGDM(gdm);
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
configureChannelTopicTitle(renderedTopic);
|
|
boolean z4 = viewState instanceof WidgetChannelTopicViewModel.ViewState.DM;
|
|
if (z4) {
|
|
Objects.requireNonNull(viewState, "null cannot be cast to non-null type com.discord.widgets.channels.WidgetChannelTopicViewModel.ViewState.DM");
|
|
WidgetChannelTopicViewModel.ViewState.DM dm2 = (WidgetChannelTopicViewModel.ViewState.DM) viewState;
|
|
Set<String> recipientNicknames = dm2.getRecipientNicknames();
|
|
List<GuildMember> guildMembers = dm2.getGuildMembers();
|
|
if (!(guildMembers instanceof Collection) || !guildMembers.isEmpty()) {
|
|
Iterator<T> it = guildMembers.iterator();
|
|
while (true) {
|
|
if (it.hasNext()) {
|
|
if (((GuildMember) it.next()).hasAvatar()) {
|
|
z2 = true;
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
getBinding().b.setOnClickListener(new WidgetChannelTopic$configureUI$1(this, viewState));
|
|
UserAkaView userAkaView = getBinding().b;
|
|
m.checkNotNullExpressionValue(userAkaView, "binding.channelAka");
|
|
userAkaView.setVisibility(!(recipientNicknames == null || recipientNicknames.isEmpty()) || z2 ? 0 : 8);
|
|
} else {
|
|
UserAkaView userAkaView2 = getBinding().b;
|
|
m.checkNotNullExpressionValue(userAkaView2, "binding.channelAka");
|
|
userAkaView2.setVisibility(8);
|
|
}
|
|
this.isDm = z4;
|
|
LinkifiedTextView linkifiedTextView = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.channelTopicTitle");
|
|
CharSequence topic = renderedTopic.getTopic();
|
|
if ((topic == null || t.isBlank(topic)) || z4) {
|
|
z3 = false;
|
|
}
|
|
if (z3) {
|
|
i = 0;
|
|
}
|
|
linkifiedTextView.setVisibility(i);
|
|
configureEllipsis();
|
|
TextView textView = getBinding().f;
|
|
m.checkNotNullExpressionValue(textView, "binding.channelTopicName");
|
|
textView.setText(renderedTopic.getChannelName());
|
|
getBinding().e.setOnClickListener(new WidgetChannelTopic$configureUI$2(this, viewState));
|
|
}
|
|
|
|
private final WidgetChannelTopicBinding getBinding() {
|
|
return (WidgetChannelTopicBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final RenderedTopic getRenderedTopicForDefaultTopic(WidgetChannelTopicViewModel.ViewState.Guild.DefaultTopic defaultTopic) {
|
|
return new RenderedTopic(AnimatableValueParser.z0(defaultTopic.getChannel(), requireContext(), false), "", 0);
|
|
}
|
|
|
|
private final RenderedTopic getRenderedTopicForGDM(WidgetChannelTopicViewModel.ViewState.GDM gdm) {
|
|
return new RenderedTopic(AnimatableValueParser.z0(gdm.getChannel(), requireContext(), false), null, 0, 4, null);
|
|
}
|
|
|
|
private final RenderedTopic getRenderedTopicForTopic(WidgetChannelTopicViewModel.ViewState.Guild.Topic topic) {
|
|
LinkifiedTextView linkifiedTextView = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.channelTopicTitle");
|
|
Context context = linkifiedTextView.getContext();
|
|
m.checkNotNullExpressionValue(context, "binding.channelTopicTitle.context");
|
|
DraweeSpanStringBuilder render = AstRenderer.render(topic.getAst(), new MessageRenderContext(context, 0, topic.getAllowAnimatedEmojis(), topic.getUserNames(), topic.getChannelNames(), topic.getRoles(), 0, null, WidgetChannelTopic$getRenderedTopicForTopic$renderContext$1.INSTANCE, 0, 0, new WidgetChannelTopic$getRenderedTopicForTopic$renderContext$2(getViewModel()), null, null, 14016, null));
|
|
return new RenderedTopic(AnimatableValueParser.z0(topic.getChannel(), requireContext(), false), render, (render.length() > 200 || topic.isLinkifyConflicting()) ? 0 : 15);
|
|
}
|
|
|
|
private final WidgetChannelTopicViewModel getViewModel() {
|
|
return (WidgetChannelTopicViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void handleEvent(WidgetChannelTopicViewModel.Event event) {
|
|
if (event instanceof WidgetChannelTopicViewModel.Event.FocusFirstElement) {
|
|
getBinding().f.sendAccessibilityEvent(8);
|
|
}
|
|
}
|
|
|
|
private final void onClickMore(WidgetChannelTopicViewModel.ViewState viewState) {
|
|
if (viewState instanceof WidgetChannelTopicViewModel.ViewState.GDM) {
|
|
WidgetChannelTopicViewModel.ViewState.GDM gdm = (WidgetChannelTopicViewModel.ViewState.GDM) viewState;
|
|
showContextMenu(true, gdm.getChannelId(), AnimatableValueParser.z0(gdm.getChannel(), requireContext(), false), gdm.getDeveloperModeEnabled());
|
|
} else if (viewState instanceof WidgetChannelTopicViewModel.ViewState.DM) {
|
|
WidgetChannelTopicViewModel.ViewState.DM dm = (WidgetChannelTopicViewModel.ViewState.DM) viewState;
|
|
showContextMenu$default(this, false, dm.getChannelId(), null, dm.getDeveloperModeEnabled(), 4, null);
|
|
}
|
|
}
|
|
|
|
private final void onToggleTopicExpansionState() {
|
|
WidgetChannelTopic$onToggleTopicExpansionState$1 widgetChannelTopic$onToggleTopicExpansionState$1 = new WidgetChannelTopic$onToggleTopicExpansionState$1(this);
|
|
LinkifiedTextView linkifiedTextView = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.channelTopicTitle");
|
|
if (linkifiedTextView.getMaxLines() != 40) {
|
|
widgetChannelTopic$onToggleTopicExpansionState$1.invoke(40);
|
|
} else {
|
|
widgetChannelTopic$onToggleTopicExpansionState$1.invoke(2);
|
|
}
|
|
}
|
|
|
|
private final void setChannelIcon(@DrawableRes int i) {
|
|
getBinding().f1748c.setImageResource(i);
|
|
SimpleDraweeView simpleDraweeView = getBinding().f1748c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.channelTopicChannelIcon");
|
|
ViewGroup.LayoutParams layoutParams = simpleDraweeView.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
|
|
marginLayoutParams.setMargins(marginLayoutParams.leftMargin, marginLayoutParams.topMargin, DimenUtils.dpToPixels(4), marginLayoutParams.bottomMargin);
|
|
}
|
|
|
|
private final void setChannelIconForGDM(Channel channel) {
|
|
SimpleDraweeView simpleDraweeView = getBinding().f1748c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.channelTopicChannelIcon");
|
|
IconUtils.setIcon$default(simpleDraweeView, IconUtils.getForChannel$default(channel, null, 2, null), (int) R.dimen.avatar_size_large, (Function1) null, (MGImages.ChangeDetector) null, 24, (Object) null);
|
|
SimpleDraweeView simpleDraweeView2 = getBinding().f1748c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.channelTopicChannelIcon");
|
|
ViewGroup.LayoutParams layoutParams = simpleDraweeView2.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
|
|
marginLayoutParams.setMargins(marginLayoutParams.leftMargin, marginLayoutParams.topMargin, DimenUtils.dpToPixels(8), marginLayoutParams.bottomMargin);
|
|
}
|
|
|
|
private final void showContextMenu(boolean z2, long j, CharSequence charSequence, boolean z3) {
|
|
ImageView imageView = getBinding().e;
|
|
m.checkNotNullExpressionValue(imageView, "binding.channelTopicMoreIcon");
|
|
PopupMenu popupMenu = new PopupMenu(imageView.getContext(), getBinding().e, BadgeDrawable.BOTTOM_START);
|
|
popupMenu.inflate(R.menu.menu_private_channel_sidebar);
|
|
popupMenu.getMenu().findItem(R.id.menu_private_channel_sidebar_pinned_messages).setOnMenuItemClickListener(new WidgetChannelTopic$showContextMenu$1(this, j));
|
|
MenuItem findItem = popupMenu.getMenu().findItem(R.id.menu_private_channel_sidebar_copy_id);
|
|
m.checkNotNullExpressionValue(findItem, "copyChannelIdAction");
|
|
findItem.setVisible(z3);
|
|
findItem.setOnMenuItemClickListener(new WidgetChannelTopic$showContextMenu$2(this, j));
|
|
MenuItem findItem2 = popupMenu.getMenu().findItem(R.id.menu_private_channel_sidebar_customize_gorup);
|
|
m.checkNotNullExpressionValue(findItem2, "customizeGroupAction");
|
|
findItem2.setVisible(z2);
|
|
findItem2.setOnMenuItemClickListener(new WidgetChannelTopic$showContextMenu$3(this, j));
|
|
MenuItem findItem3 = popupMenu.getMenu().findItem(R.id.menu_private_channel_sidebar_close);
|
|
if (z2) {
|
|
findItem3.setTitle(R.string.leave_group_dm);
|
|
findItem3.setOnMenuItemClickListener(new WidgetChannelTopic$showContextMenu$4(this, charSequence));
|
|
} else {
|
|
findItem3.setTitle(R.string.close_dm);
|
|
findItem3.setOnMenuItemClickListener(new WidgetChannelTopic$showContextMenu$5(this));
|
|
}
|
|
popupMenu.show();
|
|
}
|
|
|
|
public static /* synthetic */ void showContextMenu$default(WidgetChannelTopic widgetChannelTopic, boolean z2, long j, CharSequence charSequence, boolean z3, int i, Object obj) {
|
|
if ((i & 4) != 0) {
|
|
charSequence = null;
|
|
}
|
|
widgetChannelTopic.showContextMenu(z2, j, charSequence, (i & 8) != 0 ? false : z3);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
getBinding().g.setOnClickListener(new WidgetChannelTopic$onViewBound$1(this));
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().listenForEvents(), this, null, 2, null), WidgetChannelTopic.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelTopic$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
Observable<WidgetChannelTopicViewModel.ViewState> r = getViewModel().observeViewState().r();
|
|
m.checkNotNullExpressionValue(r, "viewModel\n .obser… .distinctUntilChanged()");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(r, this, null, 2, null), WidgetChannelTopic.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelTopic$onViewBoundOrOnResume$2(this), 62, (Object) null);
|
|
LinkifiedTextView linkifiedTextView = getBinding().g;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.channelTopicTitle");
|
|
linkifiedTextView.setMaxLines(2);
|
|
}
|
|
}
|