2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.utilities.press;
|
|
|
|
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import j0.j.b.a;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.Subscription;
|
|
|
|
import rx.functions.Action0;
|
|
|
|
/* compiled from: RepeatingOnTouchListener.kt */
|
|
|
|
public final class RepeatingOnTouchListener implements View.OnTouchListener {
|
|
|
|
private final Action0 action;
|
|
|
|
private final Action0 initialAction;
|
|
|
|
private final long initialDelay;
|
|
|
|
private final long repeatRate;
|
|
|
|
private Subscription subscription;
|
|
|
|
private final TimeUnit timeUnit;
|
|
|
|
|
|
|
|
public RepeatingOnTouchListener(long j, long j2, TimeUnit timeUnit, Action0 action0) {
|
|
|
|
this(j, j2, timeUnit, action0, null, 16, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public RepeatingOnTouchListener(long j, long j2, TimeUnit timeUnit, Action0 action0, Action0 action02) {
|
|
|
|
m.checkNotNullParameter(timeUnit, "timeUnit");
|
|
|
|
m.checkNotNullParameter(action0, "action");
|
|
|
|
m.checkNotNullParameter(action02, "initialAction");
|
|
|
|
this.initialDelay = j;
|
|
|
|
this.repeatRate = j2;
|
|
|
|
this.timeUnit = timeUnit;
|
|
|
|
this.action = action0;
|
|
|
|
this.initialAction = action02;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
|
|
public /* synthetic */ RepeatingOnTouchListener(long j, long j2, TimeUnit timeUnit, Action0 action0, Action0 action02, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this(j, j2, timeUnit, action0, (i & 16) != 0 ? action0 : action02);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void subscribe() {
|
2021-07-03 23:36:06 +00:00
|
|
|
this.subscription = Observable.d0(this.initialDelay, this.timeUnit).z(new RepeatingOnTouchListener$subscribe$1(this)).I(a.a()).W(new RepeatingOnTouchListener$subscribe$2(this), RepeatingOnTouchListener$subscribe$3.INSTANCE);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final Action0 getAction() {
|
|
|
|
return this.action;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Action0 getInitialAction() {
|
|
|
|
return this.initialAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final long getInitialDelay() {
|
|
|
|
return this.initialDelay;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final long getRepeatRate() {
|
|
|
|
return this.repeatRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final TimeUnit getTimeUnit() {
|
|
|
|
return this.timeUnit;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // android.view.View.OnTouchListener
|
|
|
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
|
|
Integer valueOf = motionEvent != null ? Integer.valueOf(motionEvent.getAction()) : null;
|
|
|
|
if (valueOf != null && valueOf.intValue() == 0) {
|
|
|
|
this.initialAction.call();
|
|
|
|
subscribe();
|
|
|
|
return true;
|
|
|
|
} else if (valueOf != null && valueOf.intValue() == 2) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Subscription subscription = this.subscription;
|
|
|
|
if (subscription != null) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
this.subscription = null;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|