discord-jadx/app/src/main/java/com/discord/rlottie/RLottieImageView.java

119 lines
4.3 KiB
Java

package com.discord.rlottie;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.Display;
import android.view.WindowManager;
import androidx.appcompat.widget.AppCompatImageView;
import com.discord.rlottie.RLottieDrawable;
import d0.z.d.m;
import kotlin.TypeCastException;
/* compiled from: RLottieImageView.kt */
public class RLottieImageView extends AppCompatImageView {
public RLottieDrawable i;
public boolean j;
public boolean k;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public RLottieImageView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkParameterIsNotNull(context, "context");
RLottieDrawable.PlaybackMode playbackMode = RLottieDrawable.PlaybackMode.FREEZE;
}
@SuppressLint({"AnnotateVersionCheck"})
public final Display a(Context context) {
if (Build.VERSION.SDK_INT >= 30) {
Display display = context.getDisplay();
if (display == null) {
m.throwNpe();
}
m.checkExpressionValueIsNotNull(display, "display!!");
return display;
}
Object systemService = context.getSystemService("window");
if (systemService != null) {
Display defaultDisplay = ((WindowManager) systemService).getDefaultDisplay();
m.checkExpressionValueIsNotNull(defaultDisplay, "(getSystemService(Contex…owManager).defaultDisplay");
return defaultDisplay;
}
throw new TypeCastException("null cannot be cast to non-null type android.view.WindowManager");
}
public final void b() {
RLottieDrawable rLottieDrawable = this.i;
if (rLottieDrawable != null) {
this.k = true;
if (this.j && rLottieDrawable != null) {
rLottieDrawable.start();
}
}
}
public final void c(int i, int i2, int i3) {
RLottieDrawable.PlaybackMode playbackMode = RLottieDrawable.PlaybackMode.LOOP;
m.checkParameterIsNotNull(playbackMode, "playbackMode");
Context context = getContext();
m.checkExpressionValueIsNotNull(context, "context");
String valueOf = String.valueOf(i);
Context context2 = getContext();
m.checkExpressionValueIsNotNull(context2, "context");
RLottieDrawable rLottieDrawable = new RLottieDrawable(context, i, valueOf, i2, i3, a(context2).getRefreshRate(), false, (int[]) null);
this.i = rLottieDrawable;
rLottieDrawable.f(playbackMode);
RLottieDrawable rLottieDrawable2 = this.i;
if (rLottieDrawable2 != null) {
rLottieDrawable2.e(true);
}
setImageDrawable(this.i);
}
@Override // android.widget.ImageView, android.view.View
public void onAttachedToWindow() {
RLottieDrawable rLottieDrawable;
super.onAttachedToWindow();
this.j = true;
if (this.k && (rLottieDrawable = this.i) != null) {
rLottieDrawable.start();
}
}
@Override // android.widget.ImageView, android.view.View
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
this.j = false;
RLottieDrawable rLottieDrawable = this.i;
if (rLottieDrawable != null) {
rLottieDrawable.O = false;
}
}
public final void setPlaybackMode(RLottieDrawable.PlaybackMode playbackMode) {
m.checkParameterIsNotNull(playbackMode, "playbackMode");
RLottieDrawable rLottieDrawable = this.i;
if (rLottieDrawable != null) {
rLottieDrawable.f(playbackMode);
}
}
public final void setProgress(float f) {
RLottieDrawable rLottieDrawable = this.i;
if (rLottieDrawable != null) {
if (f < 0.0f) {
f = 0.0f;
} else if (f > 1.0f) {
f = 1.0f;
}
rLottieDrawable.H = (int) (((float) rLottieDrawable.q[0]) * f);
rLottieDrawable.f2188y = false;
rLottieDrawable.F = false;
if (!rLottieDrawable.d()) {
rLottieDrawable.G = true;
}
rLottieDrawable.invalidateSelf();
}
}
}