223 lines
11 KiB
Java
223 lines
11 KiB
Java
package com.discord.widgets.channels.invite;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.appcompat.widget.AppCompatImageView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.h0;
|
|
import c.a.d.j0;
|
|
import c.a.d.o;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.AppBottomSheet;
|
|
import com.discord.chips_view.ChipsView;
|
|
import com.discord.databinding.GroupInviteFriendsBottomSheetBinding;
|
|
import com.discord.models.user.User;
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
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.channels.invite.GroupInviteFriendsSheetViewModel;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.Objects;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
/* compiled from: GroupInviteFriendsSheet.kt */
|
|
public final class GroupInviteFriendsSheet extends AppBottomSheet {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(GroupInviteFriendsSheet.class, "binding", "getBinding()Lcom/discord/databinding/GroupInviteFriendsBottomSheetBinding;", 0)};
|
|
public static final float BOTTOM_SHEET_HEIGHT_PERCENT = 0.9f;
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final long NO_CHANNEL_ID = -1;
|
|
private GroupInviteFriendsSheetAdapter adapter;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, GroupInviteFriendsSheet$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: GroupInviteFriendsSheet.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static /* synthetic */ GroupInviteFriendsSheet show$default(Companion companion, FragmentManager fragmentManager, long j, String str, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
j = -1;
|
|
}
|
|
return companion.show(fragmentManager, j, str);
|
|
}
|
|
|
|
public final GroupInviteFriendsSheet show(FragmentManager fragmentManager, long j, String str) {
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
m.checkNotNullParameter(str, "source");
|
|
GroupInviteFriendsSheet groupInviteFriendsSheet = new GroupInviteFriendsSheet();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putLong("com.discord.intent.extra.EXTRA_CHANNEL_ID", j);
|
|
if (j == -1) {
|
|
AnalyticsTracker.openModal$default("DM Group Create", str, null, 4, null);
|
|
} else {
|
|
AnalyticsTracker.openModal$default("DM Group Add", str, null, 4, null);
|
|
}
|
|
groupInviteFriendsSheet.setArguments(bundle);
|
|
groupInviteFriendsSheet.show(fragmentManager, GroupInviteFriendsSheet.class.getSimpleName());
|
|
return groupInviteFriendsSheet;
|
|
}
|
|
}
|
|
|
|
/* compiled from: GroupInviteFriendsSheet.kt */
|
|
public static final class UserDataContract implements ChipsView.a {
|
|
private final String displayString;
|
|
private final User modelUser;
|
|
|
|
public UserDataContract(User user) {
|
|
m.checkNotNullParameter(user, "modelUser");
|
|
this.modelUser = user;
|
|
this.displayString = user.getUsername();
|
|
}
|
|
|
|
@Override // com.discord.chips_view.ChipsView.a
|
|
public String getDisplayString() {
|
|
return this.displayString;
|
|
}
|
|
|
|
public final User getModelUser() {
|
|
return this.modelUser;
|
|
}
|
|
}
|
|
|
|
public GroupInviteFriendsSheet() {
|
|
super(false, 1, null);
|
|
GroupInviteFriendsSheet$viewModel$2 groupInviteFriendsSheet$viewModel$2 = new GroupInviteFriendsSheet$viewModel$2(this);
|
|
h0 h0Var = new h0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(GroupInviteFriendsSheetViewModel.class), new GroupInviteFriendsSheet$appViewModels$$inlined$viewModels$1(h0Var), new j0(groupInviteFriendsSheet$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ GroupInviteFriendsSheetViewModel access$getViewModel$p(GroupInviteFriendsSheet groupInviteFriendsSheet) {
|
|
return groupInviteFriendsSheet.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleEvent(GroupInviteFriendsSheet groupInviteFriendsSheet, GroupInviteFriendsSheetViewModel.Event event) {
|
|
groupInviteFriendsSheet.handleEvent(event);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$updateView(GroupInviteFriendsSheet groupInviteFriendsSheet, GroupInviteFriendsSheetViewModel.ViewState viewState) {
|
|
groupInviteFriendsSheet.updateView(viewState);
|
|
}
|
|
|
|
private final GroupInviteFriendsBottomSheetBinding getBinding() {
|
|
return (GroupInviteFriendsBottomSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final GroupInviteFriendsSheetViewModel getViewModel() {
|
|
return (GroupInviteFriendsSheetViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void handleEvent(GroupInviteFriendsSheetViewModel.Event event) {
|
|
if (event instanceof GroupInviteFriendsSheetViewModel.Event.ChannelFull) {
|
|
o.i(this, 2131889155, 0, 4);
|
|
}
|
|
}
|
|
|
|
private final void resizeSheetHeight() {
|
|
ConstraintLayout constraintLayout = getBinding().d;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.root");
|
|
if (!ViewCompat.isLaidOut(constraintLayout) || constraintLayout.isLayoutRequested()) {
|
|
constraintLayout.addOnLayoutChangeListener(new GroupInviteFriendsSheet$resizeSheetHeight$$inlined$doOnLayout$1(this));
|
|
} else {
|
|
ViewGroup.LayoutParams layoutParams = constraintLayout.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.LayoutParams");
|
|
Resources resources = getResources();
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
|
layoutParams.height = (int) (((float) resources.getDisplayMetrics().heightPixels) * 0.9f);
|
|
constraintLayout.setLayoutParams(layoutParams);
|
|
}
|
|
getBinding().f1611c.requestLayout();
|
|
}
|
|
|
|
private final void scrollToTopIfDeletingChar(int i, int i2) {
|
|
if (i < i2) {
|
|
getBinding().f1611c.smoothScrollToPosition(0);
|
|
}
|
|
}
|
|
|
|
private final void updateView(GroupInviteFriendsSheetViewModel.ViewState viewState) {
|
|
GroupInviteFriendsSheetAdapter groupInviteFriendsSheetAdapter = this.adapter;
|
|
if (groupInviteFriendsSheetAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
int itemCount = groupInviteFriendsSheetAdapter.getItemCount();
|
|
GroupInviteFriendsSheetAdapter groupInviteFriendsSheetAdapter2 = this.adapter;
|
|
if (groupInviteFriendsSheetAdapter2 == null) {
|
|
m.throwUninitializedPropertyAccessException("adapter");
|
|
}
|
|
groupInviteFriendsSheetAdapter2.setData(viewState.getFriendItems());
|
|
scrollToTopIfDeletingChar(itemCount, viewState.getFriendItems().size());
|
|
AppCompatImageView appCompatImageView = getBinding().e;
|
|
m.checkNotNullExpressionValue(appCompatImageView, "binding.searchIcon");
|
|
appCompatImageView.setVisibility(viewState.getShowSearchIcon() ? 0 : 8);
|
|
Iterator<User> it = viewState.getCheckedUsers().iterator();
|
|
while (it.hasNext()) {
|
|
User next = it.next();
|
|
ChipsView chipsView = getBinding().b;
|
|
String username = next.getUsername();
|
|
Uri parse = Uri.parse(IconUtils.getForUser$default(next, false, null, 6, null));
|
|
Long valueOf = Long.valueOf(next.getId());
|
|
m.checkNotNullExpressionValue(next, "user");
|
|
chipsView.b(username, parse, valueOf, new UserDataContract(next));
|
|
}
|
|
ChipsView chipsView2 = getBinding().b;
|
|
HashSet<User> checkedUsers = viewState.getCheckedUsers();
|
|
ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(checkedUsers, 10));
|
|
for (User user : checkedUsers) {
|
|
arrayList.add(Long.valueOf(user.getId()));
|
|
}
|
|
chipsView2.e(arrayList);
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet
|
|
public int getContentViewResId() {
|
|
return 2131558513;
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), GroupInviteFriendsSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new GroupInviteFriendsSheet$onResume$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeEvents(), this), GroupInviteFriendsSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new GroupInviteFriendsSheet$onResume$2(this), 62, (Object) null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
|
|
public void onViewCreated(View view, Bundle bundle) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewCreated(view, bundle);
|
|
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
|
|
RecyclerView recyclerView = getBinding().f1611c;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.recyclerView");
|
|
this.adapter = (GroupInviteFriendsSheetAdapter) companion.configure(new GroupInviteFriendsSheetAdapter(recyclerView, new GroupInviteFriendsSheet$onViewCreated$1(this)));
|
|
ChipsView chipsView = getBinding().b;
|
|
Objects.requireNonNull(chipsView, "null cannot be cast to non-null type com.discord.chips_view.ChipsView<com.discord.primitives.UserId /* = kotlin.Long */, com.discord.widgets.channels.invite.GroupInviteFriendsSheet.UserDataContract>");
|
|
chipsView.setChipDeletedListener(new GroupInviteFriendsSheet$onViewCreated$2(this));
|
|
getBinding().b.setTextChangedListener(new GroupInviteFriendsSheet$onViewCreated$3(this));
|
|
setBottomSheetCollapsedStateDisabled();
|
|
resizeSheetHeight();
|
|
}
|
|
}
|