72 lines
2.3 KiB
Java
72 lines
2.3 KiB
Java
package com.discord.utilities.press;
|
|
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
/* compiled from: OnPressListener.kt */
|
|
public final class OnPressListener implements View.OnTouchListener {
|
|
private final OnPress onPress;
|
|
private boolean pressed;
|
|
|
|
/* compiled from: OnPressListener.kt */
|
|
/* renamed from: com.discord.utilities.press.OnPressListener$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 implements OnPress {
|
|
public final /* synthetic */ Function1 $onPress;
|
|
|
|
public AnonymousClass1(Function1 function1) {
|
|
this.$onPress = function1;
|
|
}
|
|
|
|
@Override // com.discord.utilities.press.OnPressListener.OnPress
|
|
public void onPress(boolean z2) {
|
|
this.$onPress.invoke(Boolean.valueOf(z2));
|
|
}
|
|
}
|
|
|
|
/* compiled from: OnPressListener.kt */
|
|
public interface OnPress {
|
|
void onPress(boolean z2);
|
|
}
|
|
|
|
public OnPressListener(OnPress onPress) {
|
|
m.checkNotNullParameter(onPress, "onPress");
|
|
this.onPress = onPress;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public OnPressListener(Function1<? super Boolean, Unit> function1) {
|
|
this(new AnonymousClass1(function1));
|
|
m.checkNotNullParameter(function1, "onPress");
|
|
}
|
|
|
|
private final Boolean isPressed(MotionEvent motionEvent) {
|
|
int action = motionEvent.getAction();
|
|
if (action != 0) {
|
|
if (!(action == 1 || action == 3)) {
|
|
if (action != 5) {
|
|
if (action != 6) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
return Boolean.FALSE;
|
|
}
|
|
return Boolean.TRUE;
|
|
}
|
|
|
|
@Override // android.view.View.OnTouchListener
|
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
boolean booleanValue;
|
|
m.checkNotNullParameter(view, "view");
|
|
m.checkNotNullParameter(motionEvent, "event");
|
|
Boolean isPressed = isPressed(motionEvent);
|
|
if (isPressed == null || this.pressed == (booleanValue = isPressed.booleanValue())) {
|
|
return false;
|
|
}
|
|
this.pressed = booleanValue;
|
|
this.onPress.onPress(booleanValue);
|
|
return false;
|
|
}
|
|
}
|