140 lines
6.9 KiB
Java
140 lines
6.9 KiB
Java
package com.discord.widgets.chat.input.sticker;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import c.q.a.k.a;
|
|
import com.discord.api.sticker.Sticker;
|
|
import com.discord.app.AppComponent;
|
|
import com.discord.databinding.StickerPickerStickerItemBinding;
|
|
import com.discord.rlottie.RLottieImageView;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.views.sticker.StickerView;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import d0.z.d.m;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlinx.coroutines.Job;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
import rx.subjects.BehaviorSubject;
|
|
/* compiled from: StickerAdapterViewHolders.kt */
|
|
public final class StickerViewHolder extends MGRecyclerViewHolder<WidgetStickerAdapter, MGRecyclerDataPayload> {
|
|
private final AppComponent appComponent;
|
|
private final StickerPickerStickerItemBinding binding;
|
|
private final BehaviorSubject<Boolean> recyclerScrollingWithinThresholdSubject;
|
|
private Subscription scrollingSpeedSubscription;
|
|
private final int type;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public StickerViewHolder(int i, WidgetStickerAdapter widgetStickerAdapter, BehaviorSubject<Boolean> behaviorSubject, AppComponent appComponent) {
|
|
super(2131558671, widgetStickerAdapter);
|
|
m.checkNotNullParameter(widgetStickerAdapter, "adapter");
|
|
m.checkNotNullParameter(appComponent, "appComponent");
|
|
this.type = i;
|
|
this.recyclerScrollingWithinThresholdSubject = behaviorSubject;
|
|
this.appComponent = appComponent;
|
|
View view = this.itemView;
|
|
StickerView stickerView = (StickerView) view.findViewById(2131365091);
|
|
if (stickerView != null) {
|
|
StickerPickerStickerItemBinding stickerPickerStickerItemBinding = new StickerPickerStickerItemBinding((FrameLayout) view, stickerView);
|
|
m.checkNotNullExpressionValue(stickerPickerStickerItemBinding, "StickerPickerStickerItemBinding.bind(itemView)");
|
|
this.binding = stickerPickerStickerItemBinding;
|
|
return;
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(2131365091)));
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ StickerViewHolder(int i, WidgetStickerAdapter widgetStickerAdapter, BehaviorSubject behaviorSubject, AppComponent appComponent, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(i, widgetStickerAdapter, (i2 & 4) != 0 ? null : behaviorSubject, appComponent);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureSticker(StickerViewHolder stickerViewHolder, MGRecyclerDataPayload mGRecyclerDataPayload) {
|
|
stickerViewHolder.configureSticker(mGRecyclerDataPayload);
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetStickerAdapter access$getAdapter$p(StickerViewHolder stickerViewHolder) {
|
|
return (WidgetStickerAdapter) stickerViewHolder.adapter;
|
|
}
|
|
|
|
public static final /* synthetic */ StickerPickerStickerItemBinding access$getBinding$p(StickerViewHolder stickerViewHolder) {
|
|
return stickerViewHolder.binding;
|
|
}
|
|
|
|
public static final /* synthetic */ Subscription access$getScrollingSpeedSubscription$p(StickerViewHolder stickerViewHolder) {
|
|
return stickerViewHolder.scrollingSpeedSubscription;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setScrollingSpeedSubscription$p(StickerViewHolder stickerViewHolder, Subscription subscription) {
|
|
stickerViewHolder.scrollingSpeedSubscription = subscription;
|
|
}
|
|
|
|
private final void configureSticker(MGRecyclerDataPayload mGRecyclerDataPayload) {
|
|
Sticker sticker;
|
|
StickerItem stickerItem = (StickerItem) (!(mGRecyclerDataPayload instanceof StickerItem) ? null : mGRecyclerDataPayload);
|
|
if (stickerItem != null && (sticker = stickerItem.getSticker()) != null) {
|
|
this.binding.b.c(sticker, 0);
|
|
this.binding.b.setOnClickListener(new StickerViewHolder$configureSticker$1(this, mGRecyclerDataPayload));
|
|
}
|
|
}
|
|
|
|
public final void cancelLoading() {
|
|
StickerView stickerView = this.binding.b;
|
|
Job job = stickerView.l;
|
|
if (job != null) {
|
|
a.k(job, null, 1, null);
|
|
}
|
|
stickerView.i.f99c.clearAnimation();
|
|
Subscription subscription = this.scrollingSpeedSubscription;
|
|
if (subscription != null) {
|
|
subscription.unsubscribe();
|
|
}
|
|
this.scrollingSpeedSubscription = null;
|
|
}
|
|
|
|
public final AppComponent getAppComponent() {
|
|
return this.appComponent;
|
|
}
|
|
|
|
public final BehaviorSubject<Boolean> getRecyclerScrollingWithinThresholdSubject() {
|
|
return this.recyclerScrollingWithinThresholdSubject;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerViewHolder
|
|
public Subscription getSubscription() {
|
|
return this.binding.b.getSubscription();
|
|
}
|
|
|
|
public final int getType() {
|
|
return this.type;
|
|
}
|
|
|
|
public void onConfigure(int i, MGRecyclerDataPayload mGRecyclerDataPayload) {
|
|
m.checkNotNullParameter(mGRecyclerDataPayload, "data");
|
|
super.onConfigure(i, (int) mGRecyclerDataPayload);
|
|
if (this.recyclerScrollingWithinThresholdSubject != null) {
|
|
StickerView stickerView = this.binding.b;
|
|
RLottieImageView rLottieImageView = stickerView.i.f99c;
|
|
m.checkNotNullExpressionValue(rLottieImageView, "binding.stickerViewLottie");
|
|
rLottieImageView.setVisibility(8);
|
|
SimpleDraweeView simpleDraweeView = stickerView.i.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.stickerViewImageview");
|
|
simpleDraweeView.setVisibility(8);
|
|
stickerView.i.b.setImageDrawable(null);
|
|
ImageView imageView = stickerView.i.d;
|
|
m.checkNotNullExpressionValue(imageView, "binding.stickerViewPlaceholder");
|
|
imageView.setVisibility(0);
|
|
Observable<Boolean> s2 = this.recyclerScrollingWithinThresholdSubject.s();
|
|
m.checkNotNullExpressionValue(s2, "recyclerScrollingWithinT… .distinctUntilChanged()");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(s2, this.appComponent, null, 2, null), StickerViewHolder.class, (Context) null, new StickerViewHolder$onConfigure$2(this), (Function1) null, (Function0) null, (Function0) null, new StickerViewHolder$onConfigure$1(this, mGRecyclerDataPayload), 58, (Object) null);
|
|
return;
|
|
}
|
|
configureSticker(mGRecyclerDataPayload);
|
|
}
|
|
}
|