184 lines
9.3 KiB
Java
184 lines
9.3 KiB
Java
package com.discord.widgets.chat.list;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.g0;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetChatListBinding;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.chat.input.AppFlexInputViewModel;
|
|
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapter;
|
|
import com.discord.widgets.chat.list.adapter.WidgetChatListAdapterEventsHandler;
|
|
import com.discord.widgets.chat.list.model.WidgetChatListModel;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import kotlin.Lazy;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.functions.Action0;
|
|
/* compiled from: WidgetChatList.kt */
|
|
public final class WidgetChatList extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetChatList.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChatListBinding;", 0)};
|
|
private WidgetChatListAdapter adapter;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding(this, WidgetChatList$binding$2.INSTANCE, new WidgetChatList$binding$3(this));
|
|
private RecyclerView.ItemAnimator defaultItemAnimator;
|
|
private final Lazy flexInputViewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(AppFlexInputViewModel.class), new WidgetChatList$appActivityViewModels$$inlined$activityViewModels$1(this), new g0(new WidgetChatList$flexInputViewModel$2(this)));
|
|
|
|
public WidgetChatList() {
|
|
super(2131558924);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetChatList widgetChatList, WidgetChatListModel widgetChatListModel) {
|
|
widgetChatList.configureUI(widgetChatListModel);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChatListAdapter access$getAdapter$p(WidgetChatList widgetChatList) {
|
|
return widgetChatList.adapter;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$scrollTo(WidgetChatList widgetChatList, long j) {
|
|
widgetChatList.scrollTo(j);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setAdapter$p(WidgetChatList widgetChatList, WidgetChatListAdapter widgetChatListAdapter) {
|
|
widgetChatList.adapter = widgetChatListAdapter;
|
|
}
|
|
|
|
private final void addThreadSpineItemDecoration(WidgetChatListAdapter widgetChatListAdapter) {
|
|
getBinding().b.addItemDecoration(new ThreadSpineItemDecoration(requireContext(), widgetChatListAdapter));
|
|
}
|
|
|
|
private final void configureExistingAdapter(WidgetChatListAdapter widgetChatListAdapter) {
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
widgetChatListAdapter.setFragmentManager(parentFragmentManager);
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatListRecycler");
|
|
widgetChatListAdapter.setRecycler(recyclerView);
|
|
LinearLayoutManager layoutManager = ((WidgetChatListAdapter) MGRecyclerAdapter.Companion.configure(widgetChatListAdapter)).getLayoutManager();
|
|
if (layoutManager != null) {
|
|
layoutManager.setReverseLayout(true);
|
|
}
|
|
}
|
|
|
|
private final void configureUI(WidgetChatListModel widgetChatListModel) {
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatListRecycler");
|
|
int i = 0;
|
|
if (!(widgetChatListModel != null)) {
|
|
i = 8;
|
|
}
|
|
recyclerView.setVisibility(i);
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null && widgetChatListModel != null && widgetChatListAdapter != null) {
|
|
widgetChatListAdapter.setData(widgetChatListModel);
|
|
}
|
|
}
|
|
|
|
private final void createAdapter() {
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatListRecycler");
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
WidgetChatListAdapter widgetChatListAdapter = new WidgetChatListAdapter(recyclerView, this, parentFragmentManager, new WidgetChatListAdapterEventsHandler(this, getFlexInputViewModel(), null, null, null, null, null, 124, null), getFlexInputViewModel(), ClockFactory.get());
|
|
WidgetChatListAdapter widgetChatListAdapter2 = (WidgetChatListAdapter) MGRecyclerAdapter.Companion.configure(widgetChatListAdapter);
|
|
LinearLayoutManager layoutManager = widgetChatListAdapter.getLayoutManager();
|
|
if (layoutManager != null) {
|
|
layoutManager.setReverseLayout(true);
|
|
}
|
|
addThreadSpineItemDecoration(widgetChatListAdapter);
|
|
this.adapter = widgetChatListAdapter;
|
|
}
|
|
|
|
private final WidgetChatListBinding getBinding() {
|
|
return (WidgetChatListBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final AppFlexInputViewModel getFlexInputViewModel() {
|
|
return (AppFlexInputViewModel) this.flexInputViewModel$delegate.getValue();
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
private final void scrollTo(long j) {
|
|
WidgetChatList$scrollTo$onCompleted$1 widgetChatList$scrollTo$onCompleted$1 = WidgetChatList$scrollTo$onCompleted$1.INSTANCE;
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter == null) {
|
|
widgetChatList$scrollTo$onCompleted$1.mo1invoke();
|
|
} else if (widgetChatListAdapter != null) {
|
|
if (widgetChatList$scrollTo$onCompleted$1 != null) {
|
|
widgetChatList$scrollTo$onCompleted$1 = new WidgetChatList$sam$rx_functions_Action0$0(widgetChatList$scrollTo$onCompleted$1);
|
|
}
|
|
widgetChatListAdapter.scrollToMessageId(j, (Action0) widgetChatList$scrollTo$onCompleted$1);
|
|
}
|
|
}
|
|
|
|
public final void disableItemAnimations() {
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatListRecycler");
|
|
recyclerView.setItemAnimator(null);
|
|
}
|
|
|
|
public final void enableItemAnimations() {
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatListRecycler");
|
|
recyclerView.setItemAnimator(this.defaultItemAnimator);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment, androidx.fragment.app.Fragment
|
|
public void onPause() {
|
|
super.onPause();
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null) {
|
|
widgetChatListAdapter.onPause();
|
|
}
|
|
WidgetChatListAdapter widgetChatListAdapter2 = this.adapter;
|
|
if (widgetChatListAdapter2 != null) {
|
|
widgetChatListAdapter2.disposeHandlers();
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
setRetainInstance(true);
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null) {
|
|
configureExistingAdapter(widgetChatListAdapter);
|
|
} else {
|
|
createAdapter();
|
|
}
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
WidgetChatListAdapter widgetChatListAdapter = this.adapter;
|
|
if (widgetChatListAdapter != null) {
|
|
widgetChatListAdapter.setHandlers();
|
|
}
|
|
WidgetChatListAdapter widgetChatListAdapter2 = this.adapter;
|
|
if (widgetChatListAdapter2 != null) {
|
|
widgetChatListAdapter2.onResume();
|
|
}
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(ObservableExtensionsKt.computationLatest(WidgetChatListModel.Companion.get()), this, this.adapter), WidgetChatList.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatList$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(StoreStream.Companion.getMessagesLoader().getScrollTo(), this, null, 2, null), WidgetChatList.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChatList$onViewBoundOrOnResume$2(this), 62, (Object) null);
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatListRecycler");
|
|
this.defaultItemAnimator = recyclerView.getItemAnimator();
|
|
}
|
|
}
|