145 lines
4.4 KiB
Java
145 lines
4.4 KiB
Java
package com.ubt.jimu.controller.manager;
|
|
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import com.ubt.jimu.controller.data.widget.HSliderWidgetData;
|
|
import com.ubt.jimu.controller.data.widget.ItemBaseData;
|
|
import com.ubt.jimu.controller.data.widget.SliderWidgetData;
|
|
import com.ubt.jimu.controller.manager.CommandSendManager;
|
|
import java.util.Timer;
|
|
import java.util.TimerTask;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class CommandSendManager<T extends ItemBaseData> {
|
|
private float a;
|
|
private T b;
|
|
private Timer c;
|
|
private CommandSendManager<T>.CommandTimerTask d;
|
|
private boolean e;
|
|
private int f = 100;
|
|
private Handler g;
|
|
private HSliderViewCommandSendListener h;
|
|
private VSliderViewCommandSendListener i;
|
|
|
|
class CommandTimerTask extends TimerTask {
|
|
CommandTimerTask() {
|
|
}
|
|
|
|
public /* synthetic */ void a() {
|
|
CommandSendManager.this.h.b(CommandSendManager.this.a, CommandSendManager.this.b);
|
|
}
|
|
|
|
public /* synthetic */ void b() {
|
|
CommandSendManager.this.i.a(CommandSendManager.this.a, CommandSendManager.this.b);
|
|
}
|
|
|
|
@Override // java.util.TimerTask, java.lang.Runnable
|
|
public void run() {
|
|
if (CommandSendManager.this.b == null) {
|
|
return;
|
|
}
|
|
if ((CommandSendManager.this.b instanceof HSliderWidgetData) && CommandSendManager.this.h != null) {
|
|
CommandSendManager.this.g.post(new Runnable() { // from class: com.ubt.jimu.controller.manager.d
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
CommandSendManager.CommandTimerTask.this.a();
|
|
}
|
|
});
|
|
} else {
|
|
if (!(CommandSendManager.this.b instanceof SliderWidgetData) || CommandSendManager.this.i == null) {
|
|
return;
|
|
}
|
|
CommandSendManager.this.g.post(new Runnable() { // from class: com.ubt.jimu.controller.manager.e
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
CommandSendManager.CommandTimerTask.this.b();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
public interface HSliderViewCommandSendListener<T> {
|
|
void a(T t);
|
|
|
|
void b(float f, T t);
|
|
}
|
|
|
|
public interface VSliderViewCommandSendListener<T> {
|
|
void a(float f, T t);
|
|
|
|
void c(float f, T t);
|
|
}
|
|
|
|
public CommandSendManager() {
|
|
c();
|
|
this.g = new Handler(Looper.getMainLooper());
|
|
}
|
|
|
|
private void c() {
|
|
this.c = new Timer();
|
|
this.d = new CommandTimerTask();
|
|
}
|
|
|
|
public void a(float f) {
|
|
this.a = f;
|
|
}
|
|
|
|
public void b() {
|
|
VSliderViewCommandSendListener vSliderViewCommandSendListener;
|
|
HSliderViewCommandSendListener hSliderViewCommandSendListener;
|
|
if (this.e) {
|
|
Timer timer = this.c;
|
|
if (timer != null) {
|
|
timer.cancel();
|
|
}
|
|
CommandSendManager<T>.CommandTimerTask commandTimerTask = this.d;
|
|
if (commandTimerTask != null) {
|
|
commandTimerTask.cancel();
|
|
}
|
|
this.c = null;
|
|
this.d = null;
|
|
this.e = false;
|
|
T t = this.b;
|
|
if (t == null) {
|
|
return;
|
|
}
|
|
if ((t instanceof HSliderWidgetData) && (hSliderViewCommandSendListener = this.h) != null) {
|
|
hSliderViewCommandSendListener.a(t);
|
|
return;
|
|
}
|
|
T t2 = this.b;
|
|
if (!(t2 instanceof SliderWidgetData) || (vSliderViewCommandSendListener = this.i) == null) {
|
|
return;
|
|
}
|
|
vSliderViewCommandSendListener.c(this.a, t2);
|
|
}
|
|
}
|
|
|
|
public void a(T t) {
|
|
this.b = t;
|
|
}
|
|
|
|
public void a() {
|
|
if (this.e) {
|
|
return;
|
|
}
|
|
if (this.c == null) {
|
|
this.c = new Timer();
|
|
}
|
|
if (this.d == null) {
|
|
this.d = new CommandTimerTask();
|
|
}
|
|
this.c.schedule(this.d, 0L, this.f);
|
|
this.e = true;
|
|
}
|
|
|
|
public void a(HSliderViewCommandSendListener hSliderViewCommandSendListener) {
|
|
this.h = hSliderViewCommandSendListener;
|
|
}
|
|
|
|
public void a(VSliderViewCommandSendListener vSliderViewCommandSendListener) {
|
|
this.i = vSliderViewCommandSendListener;
|
|
}
|
|
}
|