discord-jadx/app/src/main/java/com/discord/widgets/notice/NoticePopup.java

112 lines
5.5 KiB
Java

package com.discord.widgets.notice;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import androidx.core.view.ViewCompat;
import c.p.a.b;
import c.p.a.g;
import c.p.a.i;
import com.discord.api.sticker.Sticker;
import com.discord.app.AppComponent;
import com.discord.stores.StoreNotices;
import com.discord.stores.StoreStream;
import com.discord.widgets.home.WidgetHome;
import d0.e0.c;
import d0.z.d.a0;
import d0.z.d.m;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Objects;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
/* compiled from: NoticePopup.kt */
public final class NoticePopup {
private static final int DEFAULT_AUTO_DISMISS_PERIOD_SECONDS = 5;
public static final NoticePopup INSTANCE = new NoticePopup();
private NoticePopup() {
}
public static final /* synthetic */ void access$cancelCountdown(NoticePopup noticePopup, ValueAnimator valueAnimator) {
noticePopup.cancelCountdown(valueAnimator);
}
public static final /* synthetic */ void access$dismiss(NoticePopup noticePopup, String str) {
noticePopup.dismiss(str);
}
public static final /* synthetic */ ValueAnimator access$getAutoDismissAnimator(NoticePopup noticePopup, Integer num, Function0 function0) {
return noticePopup.getAutoDismissAnimator(num, function0);
}
private final void cancelCountdown(ValueAnimator valueAnimator) {
if (valueAnimator != null) {
valueAnimator.cancel();
}
if (valueAnimator != null) {
valueAnimator.end();
}
}
private final void dismiss(String str) {
ViewGroup viewGroup;
b bVar;
WeakReference<ViewGroup> weakReference = i.a;
if (weakReference != null && (viewGroup = weakReference.get()) != null) {
m.checkNotNullExpressionValue(viewGroup, "it");
int childCount = viewGroup.getChildCount();
if (childCount >= 0) {
int i = 0;
while (true) {
if (viewGroup.getChildAt(i) instanceof b) {
View childAt = viewGroup.getChildAt(i);
Objects.requireNonNull(childAt, "null cannot be cast to non-null type com.tapadoo.alerter.Alert");
bVar = (b) childAt;
} else {
bVar = null;
}
if (!(bVar == null || bVar.getWindowToken() == null)) {
ViewCompat.animate(bVar).alpha(0.0f).withEndAction(new g(bVar));
}
if (i == childCount) {
break;
}
i++;
}
}
}
StoreNotices.markSeen$default(StoreStream.Companion.getNotices(), str, 0, 2, null);
}
public static /* synthetic */ void enqueue$default(NoticePopup noticePopup, String str, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, Drawable drawable, String str2, Drawable drawable2, List list, String str3, Integer num, Drawable drawable3, Integer num2, List list2, Function1 function1, Function1 function12, int i, Object obj) {
noticePopup.enqueue(str, charSequence, (i & 4) != 0 ? null : charSequence2, charSequence3, (i & 16) != 0 ? null : drawable, (i & 32) != 0 ? null : str2, (i & 64) != 0 ? null : drawable2, (i & 128) != 0 ? null : list, (i & 256) != 0 ? null : str3, (i & 512) != 0 ? null : num, (i & 1024) != 0 ? null : drawable3, (i & 2048) != 0 ? 5 : num2, (i & 4096) != 0 ? d0.t.m.listOf(a0.getOrCreateKotlinClass(WidgetHome.class)) : list2, (i & 8192) != 0 ? NoticePopup$enqueue$1.INSTANCE : function1, function12);
}
private final ValueAnimator getAutoDismissAnimator(Integer num, Function0<Unit> function0) {
if (num == null) {
return null;
}
ValueAnimator ofInt = ObjectAnimator.ofInt(0, 1);
NoticePopup$getAutoDismissAnimator$animatorListener$1 noticePopup$getAutoDismissAnimator$animatorListener$1 = new NoticePopup$getAutoDismissAnimator$animatorListener$1(function0);
m.checkNotNullExpressionValue(ofInt, "animator");
ofInt.setInterpolator(new LinearInterpolator());
ofInt.setDuration(((long) num.intValue()) * 1000);
ofInt.addListener(noticePopup$getAutoDismissAnimator$animatorListener$1);
ofInt.start();
return ofInt;
}
public final void enqueue(String str, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, Drawable drawable, String str2, Drawable drawable2, List<Sticker> list, String str3, Integer num, Drawable drawable3, Integer num2, List<? extends c<? extends AppComponent>> list2, Function1<? super View, Unit> function1, Function1<? super View, Unit> function12) {
m.checkNotNullParameter(str, "noticeName");
m.checkNotNullParameter(list2, "validScreens");
m.checkNotNullParameter(function1, "onClickTopRightIcon");
m.checkNotNullParameter(function12, "onClick");
StoreStream.Companion.getNotices().requestToShow(new StoreNotices.Notice(str, null, 0, 1, false, list2, 1000, false, 0, new NoticePopup$enqueue$notice$1(function12, str, num2, str3, num, str2, drawable2, drawable, charSequence, charSequence2, charSequence3, drawable3, list, function1), 150, null));
}
}