1352 lines
54 KiB
Java
1352 lines
54 KiB
Java
package com.ubt.jimu.controller.view;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.animation.ObjectAnimator;
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.PointF;
|
|
import android.graphics.RectF;
|
|
import android.text.TextUtils;
|
|
import android.util.AttributeSet;
|
|
import android.util.Size;
|
|
import android.view.DragEvent;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewStub;
|
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.controller.adapter.ActionRecyclerViewAdapter;
|
|
import com.ubt.jimu.controller.adapter.ControlMenuPagerAdapter;
|
|
import com.ubt.jimu.controller.adapter.DirectionRecyclerViewAdapter;
|
|
import com.ubt.jimu.controller.adapter.ItemDragListener;
|
|
import com.ubt.jimu.controller.component.ActionView;
|
|
import com.ubt.jimu.controller.component.DeleteView;
|
|
import com.ubt.jimu.controller.component.DragShadowView;
|
|
import com.ubt.jimu.controller.component.GridView;
|
|
import com.ubt.jimu.controller.component.HSliderView;
|
|
import com.ubt.jimu.controller.component.MenuItemView;
|
|
import com.ubt.jimu.controller.component.SteeringWheelView;
|
|
import com.ubt.jimu.controller.component.VSliderView;
|
|
import com.ubt.jimu.controller.component.WallPulleyView;
|
|
import com.ubt.jimu.controller.data.action.ActionSequence;
|
|
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
|
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
|
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
|
import com.ubt.jimu.controller.data.config.SliderConfig;
|
|
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
|
import com.ubt.jimu.controller.data.widget.AccumulatorData;
|
|
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
|
|
import com.ubt.jimu.controller.data.widget.ControllerData;
|
|
import com.ubt.jimu.controller.data.widget.HSliderWidgetData;
|
|
import com.ubt.jimu.controller.data.widget.ItemBaseData;
|
|
import com.ubt.jimu.controller.data.widget.JockstickData;
|
|
import com.ubt.jimu.controller.data.widget.MoveBaseData;
|
|
import com.ubt.jimu.controller.data.widget.SliderWidgetData;
|
|
import com.ubt.jimu.controller.manager.ActionManager;
|
|
import com.ubt.jimu.controller.manager.CommandSendManager;
|
|
import com.ubt.jimu.controller.manager.MoveConfigManager;
|
|
import com.ubt.jimu.controller.util.AdsorbUtils;
|
|
import com.ubt.jimu.controller.view.control.ControlEditEvent;
|
|
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
|
|
import com.ubt.jimu.controller.view.control.ControllerStateChangeListener;
|
|
import com.ubt.jimu.controller.view.control.OnControllerClickListener;
|
|
import com.ubt.jimu.controller.view.control.OnGameControllerConfigResultListener;
|
|
import com.ubt.jimu.controller.view.control.SuperControlView;
|
|
import com.ubt.jimu.controller.view.control.ViewPagerSlide;
|
|
import com.ubt.jimu.utils.BitmapUtils;
|
|
import com.ubt.jimu.utils.LogUtils;
|
|
import com.ubt.jimu.utils.ScreenUtil;
|
|
import com.ubtech.utils.XLog;
|
|
import com.ubtech.view.widget.ToastView;
|
|
import com.ubtrobot.log.ALog;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class RemoteControlManagementView extends FrameLayout implements View.OnClickListener, ControlTouchEvent, View.OnDragListener, ItemDragListener, OnControllerClickListener, CommandSendManager.VSliderViewCommandSendListener<SliderWidgetData>, WallPulleyView.WallPulleyViewCommandParameterListener, CommandSendManager.HSliderViewCommandSendListener<HSliderWidgetData>, DeleteView.DeleteViewAnimatorListener {
|
|
private RectF A;
|
|
private List<MoveBaseData> B;
|
|
private ItemBaseData C;
|
|
private MenuItemView D;
|
|
private ActionRecyclerViewAdapter E;
|
|
private ImageView F;
|
|
private ImageView G;
|
|
private ImageView H;
|
|
private ImageView I;
|
|
private OnControllerClickListener J;
|
|
private OnGameControllerConfigResultListener K;
|
|
private ControllerStateChangeListener L;
|
|
private String M;
|
|
private RecyclerView N;
|
|
private List<ActionWidgetData> O;
|
|
private RecyclerView P;
|
|
private OnMenuItemClickListener Q;
|
|
private ControllerState R;
|
|
SmoothMoveRunnable S;
|
|
Thread T;
|
|
private UpdateCommandParameterListener U;
|
|
private boolean V;
|
|
private int W;
|
|
private Bitmap a;
|
|
private View a0;
|
|
private View b;
|
|
private float c;
|
|
private Size d;
|
|
private Context e;
|
|
private ImageView f;
|
|
private ImageView g;
|
|
private TextView h;
|
|
private ControlEditEvent i;
|
|
private DeleteView j;
|
|
private GridView k;
|
|
private RelativeLayout l;
|
|
private RelativeLayout m;
|
|
private RelativeLayout n;
|
|
private RelativeLayout o;
|
|
private ImageView p;
|
|
private FrameLayout q;
|
|
private ViewPagerSlide r;
|
|
private Map<String, SuperControlView> s;
|
|
private ObjectAnimator t;
|
|
private boolean u;
|
|
private boolean v;
|
|
private DirectionRecyclerViewAdapter x;
|
|
private DragShadowView y;
|
|
private boolean z;
|
|
|
|
/* renamed from: com.ubt.jimu.controller.view.RemoteControlManagementView$5, reason: invalid class name */
|
|
static /* synthetic */ class AnonymousClass5 {
|
|
static final /* synthetic */ int[] a = new int[ControllerState.values().length];
|
|
|
|
static {
|
|
try {
|
|
a[ControllerState.STATE_NORMAL.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
a[ControllerState.STATE_PHYSICAL_CONTROLLER_CONFIG.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
a[ControllerState.STATE_EDIT.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
}
|
|
}
|
|
|
|
public interface OnMenuItemClickListener {
|
|
void a(ItemBaseData itemBaseData);
|
|
|
|
void b(ItemBaseData itemBaseData);
|
|
}
|
|
|
|
class SmoothMoveRunnable implements Runnable {
|
|
private ItemBaseData a;
|
|
|
|
SmoothMoveRunnable() {
|
|
}
|
|
|
|
public void a(ItemBaseData itemBaseData) {
|
|
this.a = itemBaseData;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ItemBaseData itemBaseData = this.a;
|
|
if (itemBaseData == null) {
|
|
return;
|
|
}
|
|
if (itemBaseData instanceof ActionWidgetData) {
|
|
final int a = RemoteControlManagementView.this.a(itemBaseData);
|
|
RemoteControlManagementView.this.post(new Runnable() { // from class: com.ubt.jimu.controller.view.RemoteControlManagementView.SmoothMoveRunnable.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
RemoteControlManagementView.this.c();
|
|
if (a < 0) {
|
|
return;
|
|
}
|
|
RemoteControlManagementView.this.E.b(a);
|
|
RemoteControlManagementView remoteControlManagementView = RemoteControlManagementView.this;
|
|
remoteControlManagementView.a(remoteControlManagementView.P, a);
|
|
ToastView.a(RemoteControlManagementView.this.e, R.string.item_edit_tips).a();
|
|
}
|
|
});
|
|
} else {
|
|
final int c = RemoteControlManagementView.this.c(itemBaseData);
|
|
RemoteControlManagementView.this.post(new Runnable() { // from class: com.ubt.jimu.controller.view.RemoteControlManagementView.SmoothMoveRunnable.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
RemoteControlManagementView.this.n();
|
|
if (c < 0) {
|
|
return;
|
|
}
|
|
RemoteControlManagementView.this.x.b(c);
|
|
RemoteControlManagementView remoteControlManagementView = RemoteControlManagementView.this;
|
|
remoteControlManagementView.a(remoteControlManagementView.N, c);
|
|
ToastView.a(RemoteControlManagementView.this.e, R.string.item_edit_tips).a();
|
|
}
|
|
});
|
|
}
|
|
RemoteControlManagementView.this.post(new Runnable() { // from class: com.ubt.jimu.controller.view.RemoteControlManagementView.SmoothMoveRunnable.3
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (RemoteControlManagementView.this.u) {
|
|
return;
|
|
}
|
|
RemoteControlManagementView.this.a(true, true);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public interface UpdateCommandParameterListener {
|
|
void a(float f, float f2, float f3, JockstickData jockstickData);
|
|
|
|
void a(float f, AccumulatorData accumulatorData);
|
|
|
|
void a(float f, HSliderWidgetData hSliderWidgetData);
|
|
|
|
void a(float f, SliderWidgetData sliderWidgetData);
|
|
|
|
void a(ActionWidgetData actionWidgetData);
|
|
|
|
void a(ActionWidgetData actionWidgetData, SuperControlView.MotionEventState motionEventState);
|
|
|
|
void a(HSliderWidgetData hSliderWidgetData);
|
|
|
|
void a(JockstickData jockstickData);
|
|
|
|
void a(JockstickData jockstickData, SuperControlView.MotionEventState motionEventState);
|
|
|
|
void b(float f, AccumulatorData accumulatorData);
|
|
|
|
void b(float f, SliderWidgetData sliderWidgetData);
|
|
|
|
void g0();
|
|
}
|
|
|
|
public RemoteControlManagementView(Context context) {
|
|
super(context);
|
|
this.s = new HashMap();
|
|
this.u = true;
|
|
this.v = false;
|
|
this.z = true;
|
|
this.A = new RectF();
|
|
this.M = "";
|
|
this.R = ControllerState.STATE_NORMAL;
|
|
this.S = new SmoothMoveRunnable();
|
|
a(context);
|
|
}
|
|
|
|
private void o() {
|
|
this.f.setVisibility(0);
|
|
this.g.setVisibility(8);
|
|
this.h.setVisibility(8);
|
|
this.k.setVisibility(0);
|
|
this.m.setVisibility(0);
|
|
b(false);
|
|
this.l.setVisibility(8);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void p() {
|
|
this.f.setVisibility(8);
|
|
this.g.setVisibility(8);
|
|
this.h.setVisibility(8);
|
|
this.k.setVisibility(8);
|
|
this.m.setVisibility(8);
|
|
this.l.setVisibility(8);
|
|
}
|
|
|
|
private void setControlViewsSelectState(SuperControlView superControlView) {
|
|
if (superControlView instanceof ActionView) {
|
|
this.h.setText(this.e.getString(R.string.press_game_controller_button));
|
|
} else if (superControlView instanceof SteeringWheelView) {
|
|
this.h.setText(this.e.getString(R.string.press_game_controller_joystick));
|
|
}
|
|
Map<String, SuperControlView> controlViewMap = getControlViewMap();
|
|
if (getState() == ControllerState.STATE_PHYSICAL_CONTROLLER_CONFIG) {
|
|
Iterator<Map.Entry<String, SuperControlView>> it = controlViewMap.entrySet().iterator();
|
|
while (it.hasNext()) {
|
|
SuperControlView value = it.next().getValue();
|
|
if (value == superControlView) {
|
|
value.setSelect(true);
|
|
} else {
|
|
value.setSelect(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public Map<String, SuperControlView> getControlViewMap() {
|
|
return this.s;
|
|
}
|
|
|
|
public ControllerState getState() {
|
|
return this.R;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
switch (view.getId()) {
|
|
case R.id.control_menu_switch /* 2131296494 */:
|
|
a(!this.u, true);
|
|
break;
|
|
case R.id.grid_view /* 2131296670 */:
|
|
a(!this.u, true);
|
|
break;
|
|
case R.id.im_control_affirm /* 2131296715 */:
|
|
if (getState() == ControllerState.STATE_PHYSICAL_CONTROLLER_CONFIG) {
|
|
this.K.onOk();
|
|
}
|
|
setState(ControllerState.STATE_NORMAL);
|
|
break;
|
|
case R.id.im_control_cancel /* 2131296716 */:
|
|
if (getState() == ControllerState.STATE_PHYSICAL_CONTROLLER_CONFIG) {
|
|
this.K.onCancel();
|
|
}
|
|
setState(ControllerState.STATE_NORMAL);
|
|
break;
|
|
case R.id.im_control_null /* 2131296719 */:
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.g0();
|
|
break;
|
|
}
|
|
break;
|
|
case R.id.rl_tab_action /* 2131297380 */:
|
|
c();
|
|
break;
|
|
case R.id.rl_tab_widget /* 2131297381 */:
|
|
n();
|
|
break;
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View.OnDragListener
|
|
public boolean onDrag(View view, DragEvent dragEvent) {
|
|
SuperControlView superControlView;
|
|
SuperControlView superControlView2;
|
|
int action = dragEvent.getAction();
|
|
ALog.a("DRAG").d("Drag action:" + dragEvent.getAction() + " x:" + dragEvent.getX() + " y:" + dragEvent.getY() + " mscreenSize:" + this.d);
|
|
MenuItemView menuItemView = this.D;
|
|
if (menuItemView == null) {
|
|
ALog.a("DRAG").b("currentItemView is null!", new Object[0]);
|
|
return false;
|
|
}
|
|
MenuItemView.MenuItemType menuItemType = menuItemView.getMenuItemType();
|
|
if (menuItemType == MenuItemView.MenuItemType.WIDGET_ADD_ITEM || menuItemType == MenuItemView.MenuItemType.ACTION_ADD_ITEM) {
|
|
return false;
|
|
}
|
|
if (action == 1) {
|
|
d(this.C);
|
|
a(false);
|
|
a(false, true);
|
|
return true;
|
|
}
|
|
if (action == 2) {
|
|
float x = dragEvent.getX();
|
|
float y = dragEvent.getY();
|
|
float bgWidth = this.y.getBgWidth() / 2.0f;
|
|
float bgHeight = this.y.getBgHeight() / 2.0f;
|
|
this.A.set(x - bgWidth, y - bgHeight, bgWidth + x, bgHeight + y);
|
|
a(x, y);
|
|
return true;
|
|
}
|
|
if (action == 3) {
|
|
if (!this.z) {
|
|
return false;
|
|
}
|
|
if (menuItemType == MenuItemView.MenuItemType.WIDGET_ITEM) {
|
|
return a(dragEvent);
|
|
}
|
|
if (menuItemType == MenuItemView.MenuItemType.ACTION_ITEM) {
|
|
if (!TextUtils.isEmpty(this.M)) {
|
|
ToastView.a(this.e, getResources().getString(R.string.just_one_widget)).a();
|
|
return true;
|
|
}
|
|
PointF a = AdsorbUtils.a(this.c, this.d, dragEvent.getX(), dragEvent.getY(), this.A);
|
|
ActionView actionView = new ActionView(this.e, this.C.getImageViewId(), a.x, a.y);
|
|
actionView.setState(1);
|
|
actionView.e();
|
|
actionView.setControlTouchEvent(this);
|
|
actionView.a(this.j);
|
|
this.C.setCurrentPos(a.x, a.y);
|
|
actionView.setData((ActionWidgetData) this.C);
|
|
actionView.setOnControllerClickListener(this);
|
|
this.s.put(((ActionWidgetData) this.C).getActionID(), actionView);
|
|
this.q.addView(actionView);
|
|
}
|
|
return true;
|
|
}
|
|
if (action == 4) {
|
|
this.y.b();
|
|
this.y.setVisibility(8);
|
|
this.j.g();
|
|
this.f.setVisibility(0);
|
|
if (!TextUtils.isEmpty(this.M) && (superControlView = this.s.get(this.M)) != null) {
|
|
superControlView.a(false);
|
|
}
|
|
a(true);
|
|
a(true, true);
|
|
return true;
|
|
}
|
|
if (action != 5) {
|
|
return false;
|
|
}
|
|
this.j.h();
|
|
this.f.setVisibility(8);
|
|
this.M = "";
|
|
if (menuItemType == MenuItemView.MenuItemType.ACTION_ITEM) {
|
|
this.M = c(((ActionWidgetData) this.C).getActionID());
|
|
} else if (menuItemType == MenuItemView.MenuItemType.WIDGET_ITEM) {
|
|
this.M = c(((MoveBaseData) this.C).getConfig().getConfigID());
|
|
}
|
|
if (!TextUtils.isEmpty(this.M)) {
|
|
Map<String, SuperControlView> map = this.s;
|
|
if (map == null || map.size() == 0 || (superControlView2 = this.s.get(this.M)) == null) {
|
|
return false;
|
|
}
|
|
superControlView2.a(true);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void setComponentViewState(ControllerState controllerState) {
|
|
if (this.s.size() == 0) {
|
|
return;
|
|
}
|
|
for (SuperControlView superControlView : this.s.values()) {
|
|
int i = AnonymousClass5.a[controllerState.ordinal()];
|
|
if (i == 1) {
|
|
superControlView.setVisibility(0);
|
|
superControlView.setState(0);
|
|
} else if (i != 2) {
|
|
if (i != 3) {
|
|
XLog.b("RemoteControlManagementView", "Invalid state");
|
|
} else {
|
|
superControlView.setVisibility(0);
|
|
superControlView.setState(1);
|
|
}
|
|
} else if ((superControlView instanceof HSliderView) || (superControlView instanceof VSliderView) || (superControlView instanceof WallPulleyView)) {
|
|
superControlView.setVisibility(4);
|
|
} else {
|
|
superControlView.setState(2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setControlEvent(ControlEditEvent controlEditEvent) {
|
|
this.i = controlEditEvent;
|
|
}
|
|
|
|
public void setControllerStateChangeListener(ControllerStateChangeListener controllerStateChangeListener) {
|
|
this.L = controllerStateChangeListener;
|
|
}
|
|
|
|
public void setData(ControllerData controllerData) {
|
|
h();
|
|
if (controllerData == null) {
|
|
b(true);
|
|
return;
|
|
}
|
|
b(controllerData);
|
|
e(controllerData);
|
|
c(controllerData);
|
|
d(controllerData);
|
|
a(controllerData);
|
|
if (this.s.size() > 0) {
|
|
b(false);
|
|
} else {
|
|
b(true);
|
|
}
|
|
}
|
|
|
|
public void setGameControllerConfigResultListener(OnGameControllerConfigResultListener onGameControllerConfigResultListener) {
|
|
this.K = onGameControllerConfigResultListener;
|
|
}
|
|
|
|
public void setOnAddClickListener(OnMenuItemClickListener onMenuItemClickListener) {
|
|
this.Q = onMenuItemClickListener;
|
|
}
|
|
|
|
public void setOnControllerClickListener(OnControllerClickListener onControllerClickListener) {
|
|
this.J = onControllerClickListener;
|
|
}
|
|
|
|
public void setState(ControllerState controllerState) {
|
|
ControllerStateChangeListener controllerStateChangeListener;
|
|
if (!controllerState.equals(this.R) && (controllerStateChangeListener = this.L) != null) {
|
|
controllerStateChangeListener.a(controllerState);
|
|
}
|
|
this.R = controllerState;
|
|
int i = AnonymousClass5.a[controllerState.ordinal()];
|
|
if (i == 1) {
|
|
a(false, false);
|
|
return;
|
|
}
|
|
if (i == 2) {
|
|
b();
|
|
a(false, false);
|
|
} else {
|
|
if (i != 3) {
|
|
XLog.b("RemoteControlManagementView", "Invalid state");
|
|
return;
|
|
}
|
|
b();
|
|
c();
|
|
setComponentViewState(controllerState);
|
|
o();
|
|
a(true, true);
|
|
}
|
|
}
|
|
|
|
public void setVSliderViewUpdateCommandParameterListener(UpdateCommandParameterListener updateCommandParameterListener) {
|
|
this.U = updateCommandParameterListener;
|
|
}
|
|
|
|
private void h() {
|
|
this.s.clear();
|
|
this.q.removeAllViews();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public ControllerData i() {
|
|
ControllerData controllerData = new ControllerData();
|
|
Map<String, SuperControlView> map = this.s;
|
|
if (map == null || map.size() == 0) {
|
|
b(true);
|
|
return controllerData;
|
|
}
|
|
Iterator<SuperControlView> it = this.s.values().iterator();
|
|
while (it.hasNext()) {
|
|
ItemBaseData data = it.next().getData();
|
|
if (data != null) {
|
|
controllerData.addData(data);
|
|
}
|
|
}
|
|
return controllerData;
|
|
}
|
|
|
|
private void j() {
|
|
this.t = ObjectAnimator.ofFloat(this.m, "translationX", -(this.e.getResources().getDimension(R.dimen.control_menu_width) - this.e.getResources().getDimension(R.dimen.control_menu_switch_width)), 0.0f);
|
|
this.t.setDuration(500L);
|
|
this.t.setInterpolator(new AccelerateDecelerateInterpolator());
|
|
}
|
|
|
|
private void k() {
|
|
this.y.a(this.j);
|
|
}
|
|
|
|
private void l() {
|
|
this.f.setOnClickListener(this);
|
|
this.g.setOnClickListener(this);
|
|
this.p.setOnClickListener(this);
|
|
this.q.setOnDragListener(this);
|
|
this.k.setOnClickListener(this);
|
|
this.n.setOnClickListener(this);
|
|
this.o.setOnClickListener(this);
|
|
this.j.setDeleteViewAnimatorListener(this);
|
|
}
|
|
|
|
private void m() {
|
|
this.d = new Size(ScreenUtil.b(this.e), ScreenUtil.a(this.e));
|
|
this.c = getResources().getDimension(R.dimen.grid_view_width);
|
|
LayoutInflater.from(this.e).inflate(R.layout.view_remote_control, (ViewGroup) this, true);
|
|
this.f = (ImageView) findViewById(R.id.im_control_affirm);
|
|
this.f.setBackgroundResource(R.mipmap.affirm_controller);
|
|
this.g = (ImageView) findViewById(R.id.im_control_cancel);
|
|
this.h = (TextView) findViewById(R.id.tv_title);
|
|
this.m = (RelativeLayout) findViewById(R.id.rl_control_menu_layout);
|
|
this.p = (ImageView) findViewById(R.id.control_menu_switch);
|
|
this.p.setBackgroundResource(R.mipmap.control_menu_switch_right);
|
|
this.j = (DeleteView) findViewById(R.id.view_delete);
|
|
this.k = (GridView) findViewById(R.id.grid_view);
|
|
this.q = (FrameLayout) findViewById(R.id.control_container);
|
|
this.r = (ViewPagerSlide) findViewById(R.id.view_pager);
|
|
this.y = (DragShadowView) findViewById(R.id.view_drag_shadow);
|
|
this.n = (RelativeLayout) findViewById(R.id.rl_tab_action);
|
|
this.o = (RelativeLayout) findViewById(R.id.rl_tab_widget);
|
|
this.F = (ImageView) findViewById(R.id.im_tab_action);
|
|
this.G = (ImageView) findViewById(R.id.im_tab_widget);
|
|
this.a = BitmapUtils.a(getContext(), R.mipmap.control_line, (int) getResources().getDimension(R.dimen.control_menu_tab_line_width), (int) getResources().getDimension(R.dimen.control_menu_tab_line_height));
|
|
this.H = (ImageView) findViewById(R.id.view_widget_line);
|
|
this.I = (ImageView) findViewById(R.id.view_action_line);
|
|
this.I.setImageBitmap(this.a);
|
|
this.H.setImageBitmap(this.a);
|
|
this.H.setVisibility(8);
|
|
this.l = (RelativeLayout) findViewById(R.id.game_controller_config_backgroud);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void n() {
|
|
this.F.setBackgroundResource(R.mipmap.tab_control_action_default);
|
|
this.G.setBackgroundResource(R.mipmap.tab_control_control_onclick);
|
|
this.H.setVisibility(0);
|
|
this.I.setVisibility(8);
|
|
this.r.setCurrentItem(1);
|
|
}
|
|
|
|
public void d() {
|
|
ActionManager a = ActionManager.a(this.e.getApplicationContext());
|
|
a.b();
|
|
this.O = a.a();
|
|
ActionRecyclerViewAdapter actionRecyclerViewAdapter = this.E;
|
|
if (actionRecyclerViewAdapter != null) {
|
|
actionRecyclerViewAdapter.a(this.O);
|
|
}
|
|
}
|
|
|
|
public void e() {
|
|
this.B = MenuItemDataManage.a(this.e).a();
|
|
DirectionRecyclerViewAdapter directionRecyclerViewAdapter = this.x;
|
|
if (directionRecyclerViewAdapter != null) {
|
|
directionRecyclerViewAdapter.a(this.B);
|
|
}
|
|
}
|
|
|
|
public void f() {
|
|
e();
|
|
d();
|
|
}
|
|
|
|
public void g() {
|
|
this.f.setVisibility(0);
|
|
this.g.setVisibility(0);
|
|
this.h.setVisibility(0);
|
|
this.h.setText(this.e.getString(R.string.click_screen_component));
|
|
this.k.setVisibility(4);
|
|
this.m.setVisibility(8);
|
|
b(false);
|
|
this.l.setVisibility(0);
|
|
}
|
|
|
|
public void c() {
|
|
this.F.setBackgroundResource(R.mipmap.tab_control_action_onclick);
|
|
this.G.setBackgroundResource(R.mipmap.tab_control_control_default);
|
|
this.H.setVisibility(8);
|
|
this.I.setVisibility(0);
|
|
this.r.setCurrentItem(0);
|
|
}
|
|
|
|
public void b() {
|
|
ArrayList arrayList = new ArrayList();
|
|
View inflate = View.inflate(this.e, R.layout.control_pager_layout, null);
|
|
this.N = (RecyclerView) inflate.findViewById(R.id.control_recycler);
|
|
this.N.setLayoutManager(new LinearLayoutManager(this.e));
|
|
this.x = new DirectionRecyclerViewAdapter(this.B, this.e);
|
|
this.N.setAdapter(this.x);
|
|
View inflate2 = View.inflate(this.e, R.layout.control_pager_layout, null);
|
|
this.P = (RecyclerView) inflate2.findViewById(R.id.control_recycler);
|
|
this.P.setLayoutManager(new GridLayoutManager(this.e, 2));
|
|
this.E = new ActionRecyclerViewAdapter(this.O, this.e);
|
|
this.P.setAdapter(this.E);
|
|
arrayList.add(inflate2);
|
|
arrayList.add(inflate);
|
|
this.r.setAdapter(new ControlMenuPagerAdapter(this.e, arrayList));
|
|
this.x.a(this);
|
|
this.E.a(this);
|
|
}
|
|
|
|
private void e(ControllerData controllerData) {
|
|
List<SliderWidgetData> sliderData;
|
|
if (controllerData == null || (sliderData = controllerData.getSliderData()) == null || sliderData.size() == 0) {
|
|
return;
|
|
}
|
|
for (SliderWidgetData sliderWidgetData : sliderData) {
|
|
PointF b = b(sliderWidgetData);
|
|
VSliderView vSliderView = new VSliderView(this.e, b.x, b.y);
|
|
vSliderView.setControlTouchEvent(this);
|
|
vSliderView.a(this.j);
|
|
vSliderView.setData(sliderWidgetData);
|
|
vSliderView.setUpdateCommandParameterListener(this);
|
|
vSliderView.setEditState(false);
|
|
SliderConfig config = sliderWidgetData.getConfig();
|
|
if (config != null) {
|
|
this.s.put(config.getConfigID(), vSliderView);
|
|
this.q.addView(vSliderView);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(Context context) {
|
|
this.e = context;
|
|
m();
|
|
j();
|
|
k();
|
|
l();
|
|
}
|
|
|
|
private void d(ItemBaseData itemBaseData) {
|
|
MenuItemView menuItemView = this.D;
|
|
if (menuItemView == null) {
|
|
return;
|
|
}
|
|
MenuItemView.MenuItemType menuItemType = menuItemView.getMenuItemType();
|
|
if (menuItemType == MenuItemView.MenuItemType.WIDGET_ITEM) {
|
|
int b = MenuItemDataManage.a(this.e).b(itemBaseData);
|
|
float[] a = MenuItemDataManage.a(this.e).a(itemBaseData);
|
|
this.y.a(itemBaseData).a(MenuItemView.MenuItemType.WIDGET_ITEM).a(b).d(a[0], a[1]);
|
|
} else if (menuItemType == MenuItemView.MenuItemType.ACTION_ITEM) {
|
|
this.y.a(itemBaseData).a(MenuItemView.MenuItemType.ACTION_ITEM).b(this.e.getResources().getDimension(R.dimen.control_icon_width), this.e.getResources().getDimension(R.dimen.control_icon_width)).d(this.e.getResources().getDimension(R.dimen.control_action_width), this.e.getResources().getDimension(R.dimen.control_action_width)).a(this.C.getImageViewId());
|
|
}
|
|
this.y.setVisibility(0);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public int c(ItemBaseData itemBaseData) {
|
|
List<MoveBaseData> list = this.B;
|
|
if (list != null && list.size() > 0) {
|
|
for (int i = 0; i < this.B.size(); i++) {
|
|
String configID = this.B.get(i).getConfigID();
|
|
String configID2 = ((MoveBaseData) itemBaseData).getConfigID();
|
|
if (TextUtils.isEmpty(configID2)) {
|
|
return -1;
|
|
}
|
|
if (configID2.equals(configID)) {
|
|
return i + 1;
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public RemoteControlManagementView(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.s = new HashMap();
|
|
this.u = true;
|
|
this.v = false;
|
|
this.z = true;
|
|
this.A = new RectF();
|
|
this.M = "";
|
|
this.R = ControllerState.STATE_NORMAL;
|
|
this.S = new SmoothMoveRunnable();
|
|
a(context);
|
|
}
|
|
|
|
private void a(float f, float f2) {
|
|
this.y.c(f, f2);
|
|
if (this.y.a()) {
|
|
this.y.setDragShadowState(DragShadowView.DragShadowState.DELETE_STATE);
|
|
this.z = false;
|
|
return;
|
|
}
|
|
PointF a = AdsorbUtils.a(this.c, this.d, f, f2, this.A);
|
|
RectF rectF = this.A;
|
|
rectF.offsetTo(a.x - (rectF.width() / 2.0f), a.y - (this.A.height() / 2.0f));
|
|
this.y.a(a.x, a.y);
|
|
Collection<SuperControlView> values = this.s.values();
|
|
if (values != null && values.size() != 0) {
|
|
Iterator<SuperControlView> it = values.iterator();
|
|
boolean z = false;
|
|
while (it.hasNext() && !(z = AdsorbUtils.a(it.next().getShadowRectF(), this.A))) {
|
|
}
|
|
if (z) {
|
|
this.z = false;
|
|
this.y.setDragShadowState(DragShadowView.DragShadowState.OVERLAP_STATE);
|
|
return;
|
|
} else {
|
|
this.z = true;
|
|
this.y.setDragShadowState(DragShadowView.DragShadowState.DRAG_STATE);
|
|
return;
|
|
}
|
|
}
|
|
this.z = true;
|
|
this.y.setDragShadowState(DragShadowView.DragShadowState.DRAG_STATE);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void c(View view) {
|
|
a(true);
|
|
LogUtils.c("editStateOnUp:");
|
|
this.j.g();
|
|
this.v = false;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public boolean c(SuperControlView superControlView) {
|
|
Map<String, SuperControlView> map;
|
|
if (superControlView == null || (map = this.s) == null || map.size() == 0 || superControlView.getAdsorbRectF() == null) {
|
|
return false;
|
|
}
|
|
for (SuperControlView superControlView2 : this.s.values()) {
|
|
if (superControlView.hashCode() != superControlView2.hashCode() && AdsorbUtils.a(superControlView.getAdsorbRectF(), superControlView2.getShadowRectF())) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void b(View view) {
|
|
if (this.u) {
|
|
a(false, true);
|
|
}
|
|
if (this.v) {
|
|
return;
|
|
}
|
|
this.j.h();
|
|
this.f.setVisibility(8);
|
|
this.v = true;
|
|
}
|
|
|
|
private void d(ControllerData controllerData) {
|
|
List<JockstickData> jockstickData;
|
|
if (controllerData == null || (jockstickData = controllerData.getJockstickData()) == null || jockstickData.size() == 0) {
|
|
return;
|
|
}
|
|
for (JockstickData jockstickData2 : jockstickData) {
|
|
PointF b = b(jockstickData2);
|
|
SteeringWheelView steeringWheelView = new SteeringWheelView(this.e, b.x, b.y);
|
|
steeringWheelView.setControlTouchEvent(this);
|
|
steeringWheelView.a(this.j);
|
|
steeringWheelView.setData(jockstickData2);
|
|
steeringWheelView.setOnSlideListener(new SteeringWheelView.OnSlideListener() { // from class: com.ubt.jimu.controller.view.RemoteControlManagementView.3
|
|
@Override // com.ubt.jimu.controller.component.SteeringWheelView.OnSlideListener
|
|
public void a(float f, float f2, float f3, JockstickData jockstickData3) {
|
|
if (RemoteControlManagementView.this.U != null) {
|
|
RemoteControlManagementView.this.U.a(f, f2, f3, jockstickData3);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.component.SteeringWheelView.OnSlideListener
|
|
public void a(JockstickData jockstickData3, SuperControlView.MotionEventState motionEventState) {
|
|
if (RemoteControlManagementView.this.U != null) {
|
|
RemoteControlManagementView.this.U.a(jockstickData3, motionEventState);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.component.SteeringWheelView.OnSlideListener
|
|
public void a(JockstickData jockstickData3) {
|
|
if (RemoteControlManagementView.this.U != null) {
|
|
RemoteControlManagementView.this.U.a(jockstickData3);
|
|
}
|
|
}
|
|
});
|
|
steeringWheelView.setOnControllerClickListener(this);
|
|
JockstickConfig config = jockstickData2.getConfig();
|
|
if (config != null) {
|
|
this.s.put(config.getConfigID(), steeringWheelView);
|
|
this.q.addView(steeringWheelView, 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
private String c(String str) {
|
|
Map<String, SuperControlView> map = this.s;
|
|
return (map == null || map.size() == 0 || !this.s.keySet().contains(str)) ? "" : str;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void b(SuperControlView superControlView) {
|
|
if (superControlView == null) {
|
|
return;
|
|
}
|
|
if (this.q.getChildCount() >= 2) {
|
|
this.q.removeView(superControlView);
|
|
int indexOfChild = this.q.indexOfChild(superControlView);
|
|
LogUtils.c("i:" + indexOfChild);
|
|
if (indexOfChild < 0) {
|
|
this.q.addView(superControlView, 1);
|
|
}
|
|
}
|
|
requestLayout();
|
|
}
|
|
|
|
private void c(ControllerData controllerData) {
|
|
List<HSliderWidgetData> hsliderData;
|
|
if (controllerData == null || (hsliderData = controllerData.getHsliderData()) == null || hsliderData.size() == 0) {
|
|
return;
|
|
}
|
|
for (HSliderWidgetData hSliderWidgetData : hsliderData) {
|
|
PointF b = b(hSliderWidgetData);
|
|
HSliderView hSliderView = new HSliderView(this.e, b.x, b.y);
|
|
hSliderView.setControlTouchEvent(this);
|
|
hSliderView.setHSliderViewCommandSendListener(this);
|
|
hSliderView.a(this.j);
|
|
hSliderView.setData(hSliderWidgetData);
|
|
HSliderConfig config = hSliderWidgetData.getConfig();
|
|
if (config != null) {
|
|
this.s.put(config.getConfigID(), hSliderView);
|
|
this.q.addView(hSliderView);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void a(View view) {
|
|
XLog.a("Test", view + " 按下:");
|
|
if (this.p.isClickable()) {
|
|
a(false);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void a(View view, ItemBaseData itemBaseData) {
|
|
this.T = new Thread(this.S);
|
|
this.S.a(itemBaseData);
|
|
this.T.start();
|
|
}
|
|
|
|
private void b(ControllerData controllerData) {
|
|
List<ActionWidgetData> actionData;
|
|
if (controllerData == null || (actionData = controllerData.getActionData()) == null || actionData.size() <= 0) {
|
|
return;
|
|
}
|
|
for (ActionWidgetData actionWidgetData : actionData) {
|
|
if (TextUtils.isEmpty(actionWidgetData.getActionID())) {
|
|
XLog.b("Controller", "actionID is null");
|
|
} else {
|
|
int imageViewId = actionWidgetData.getImageViewId();
|
|
PointF b = b((ItemBaseData) actionWidgetData);
|
|
ActionView actionView = new ActionView(this.e, imageViewId, b.x, b.y);
|
|
actionView.setEditState(false);
|
|
actionView.setState(0);
|
|
actionView.e();
|
|
actionView.setControlTouchEvent(this);
|
|
actionView.setOnControllerClickListener(this);
|
|
actionView.a(this.j);
|
|
actionView.setData(actionWidgetData);
|
|
this.s.put(actionWidgetData.getActionID(), actionView);
|
|
this.q.addView(actionView);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public int a(ItemBaseData itemBaseData) {
|
|
List<ActionWidgetData> list = this.O;
|
|
if (list != null && list.size() > 0) {
|
|
for (int i = 0; i < this.O.size(); i++) {
|
|
String actionID = this.O.get(i).getActionID();
|
|
String actionID2 = ((ActionWidgetData) itemBaseData).getActionID();
|
|
if (TextUtils.isEmpty(actionID2)) {
|
|
return -1;
|
|
}
|
|
if (actionID2.equals(actionID)) {
|
|
return i + 1;
|
|
}
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.adapter.ItemDragListener
|
|
public void c(MenuItemView menuItemView, ItemBaseData itemBaseData) {
|
|
this.C = itemBaseData;
|
|
this.D = menuItemView;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void a(View view, float f, float f2) {
|
|
ItemBaseData data;
|
|
if (view == null || !(view instanceof SuperControlView) || (data = ((SuperControlView) view).getData()) == null) {
|
|
return;
|
|
}
|
|
data.setCurrentPos(f, f2);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void a(View view, String str) {
|
|
a(str, view);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void a(SuperControlView superControlView) {
|
|
this.q.removeView(superControlView);
|
|
this.q.addView(superControlView, 0);
|
|
requestLayout();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void a(ActionWidgetData actionWidgetData) {
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.a(actionWidgetData);
|
|
}
|
|
}
|
|
|
|
private PointF b(ItemBaseData itemBaseData) {
|
|
return AdsorbUtils.a(this.c, itemBaseData.getCurrentX(), itemBaseData.getCurrentY());
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.ControlTouchEvent
|
|
public void a(ActionWidgetData actionWidgetData, SuperControlView.MotionEventState motionEventState) {
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.a(actionWidgetData, motionEventState);
|
|
}
|
|
}
|
|
|
|
public void a(final boolean z, final boolean z2) {
|
|
final ControllerState controllerState = this.R;
|
|
this.m.setVisibility(0);
|
|
float dimension = this.e.getResources().getDimension(R.dimen.control_menu_width) - this.e.getResources().getDimension(R.dimen.control_menu_switch_width);
|
|
if (z) {
|
|
this.t = ObjectAnimator.ofFloat(this.m, "translationX", -dimension, 0.0f);
|
|
this.t.setDuration(300L);
|
|
this.t.setInterpolator(new AccelerateDecelerateInterpolator());
|
|
this.t.start();
|
|
} else if (controllerState == ControllerState.STATE_PHYSICAL_CONTROLLER_CONFIG) {
|
|
setComponentViewState(controllerState);
|
|
g();
|
|
this.u = z;
|
|
return;
|
|
} else {
|
|
if (!this.u && !z2) {
|
|
p();
|
|
setComponentViewState(controllerState);
|
|
if (this.i != null) {
|
|
this.i.b(i());
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.t = ObjectAnimator.ofFloat(this.m, "translationX", 0.0f, -dimension);
|
|
this.t.setDuration(300L);
|
|
this.t.setInterpolator(new AccelerateDecelerateInterpolator());
|
|
this.t.start();
|
|
this.E.a();
|
|
this.x.a();
|
|
}
|
|
this.t.addListener(new AnimatorListenerAdapter() { // from class: com.ubt.jimu.controller.view.RemoteControlManagementView.1
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
if (z) {
|
|
RemoteControlManagementView.this.p.setBackgroundResource(R.mipmap.control_menu_switch_life);
|
|
} else {
|
|
RemoteControlManagementView.this.p.setBackgroundResource(R.mipmap.control_menu_switch_right);
|
|
}
|
|
if (z2) {
|
|
return;
|
|
}
|
|
RemoteControlManagementView.this.p();
|
|
RemoteControlManagementView.this.setComponentViewState(controllerState);
|
|
if (RemoteControlManagementView.this.i != null) {
|
|
RemoteControlManagementView.this.i.b(RemoteControlManagementView.this.i());
|
|
}
|
|
}
|
|
});
|
|
this.u = z;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.adapter.ItemDragListener
|
|
public void b(MenuItemView menuItemView, ItemBaseData itemBaseData) {
|
|
OnMenuItemClickListener onMenuItemClickListener = this.Q;
|
|
if (onMenuItemClickListener != null) {
|
|
onMenuItemClickListener.a(itemBaseData);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.adapter.ItemDragListener
|
|
public void b(ActionWidgetData actionWidgetData) {
|
|
OnMenuItemClickListener onMenuItemClickListener;
|
|
if (actionWidgetData == null || actionWidgetData.getActionSequence() == null || (onMenuItemClickListener = this.Q) == null) {
|
|
return;
|
|
}
|
|
onMenuItemClickListener.b(actionWidgetData);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.component.WallPulleyView.WallPulleyViewCommandParameterListener
|
|
public void b(float f, AccumulatorData accumulatorData) {
|
|
UpdateCommandParameterListener updateCommandParameterListener;
|
|
if (f == 0.0f || (updateCommandParameterListener = this.U) == null) {
|
|
return;
|
|
}
|
|
updateCommandParameterListener.b(f, accumulatorData);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.manager.CommandSendManager.VSliderViewCommandSendListener
|
|
/* renamed from: b, reason: merged with bridge method [inline-methods] */
|
|
public void a(float f, SliderWidgetData sliderWidgetData) {
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.a(f, sliderWidgetData);
|
|
}
|
|
}
|
|
|
|
public void b(String str) {
|
|
Map<String, SuperControlView> map = this.s;
|
|
if (map == null || map.size() <= 0) {
|
|
return;
|
|
}
|
|
WidgetConfig a = MoveConfigManager.a(this.e.getApplicationContext()).a(str);
|
|
SuperControlView superControlView = this.s.get(str);
|
|
if (superControlView != null) {
|
|
if (a == null) {
|
|
a(str, superControlView);
|
|
} else {
|
|
((MoveBaseData) superControlView.getData()).setConfig(a);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void b(boolean z) {
|
|
if (this.a0 != null || z) {
|
|
if (this.a0 == null && z) {
|
|
this.a0 = ((ViewStub) findViewById(R.id.stub_control_null)).inflate();
|
|
this.b = this.a0.findViewById(R.id.im_control_null);
|
|
this.b.setOnClickListener(this);
|
|
return;
|
|
}
|
|
View view = this.a0;
|
|
if (view != null && z) {
|
|
view.setVisibility(0);
|
|
return;
|
|
}
|
|
View view2 = this.a0;
|
|
if (view2 == null || z) {
|
|
return;
|
|
}
|
|
view2.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
private void a(boolean z) {
|
|
this.p.setClickable(z);
|
|
}
|
|
|
|
private boolean a(DragEvent dragEvent) {
|
|
WidgetConfig config = ((MoveBaseData) this.C).getConfig();
|
|
if (config == null) {
|
|
return false;
|
|
}
|
|
boolean z = config instanceof JockstickConfig;
|
|
if (z && this.s.size() > 0) {
|
|
Iterator<SuperControlView> it = this.s.values().iterator();
|
|
while (it.hasNext()) {
|
|
if (it.next() instanceof SteeringWheelView) {
|
|
Toast.makeText(this.e, getResources().getString(R.string.just_one_wheel), 0).show();
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (!TextUtils.isEmpty(this.M)) {
|
|
Toast.makeText(this.e, getResources().getString(R.string.just_one_widget), 0).show();
|
|
return false;
|
|
}
|
|
XLog.a("Controller", "add currentRectF : %s", this.A.toString());
|
|
if (z) {
|
|
PointF a = AdsorbUtils.a(this.c, this.d, dragEvent.getX(), dragEvent.getY(), this.A);
|
|
SteeringWheelView steeringWheelView = new SteeringWheelView(this.e, a.x, a.y);
|
|
steeringWheelView.setEditState(true);
|
|
steeringWheelView.setState(1);
|
|
steeringWheelView.setControlTouchEvent(this);
|
|
steeringWheelView.a(this.j);
|
|
steeringWheelView.e();
|
|
this.C.setCurrentPos(a.x, a.y);
|
|
steeringWheelView.setData((JockstickData) this.C);
|
|
steeringWheelView.setOnSlideListener(new SteeringWheelView.OnSlideListener() { // from class: com.ubt.jimu.controller.view.RemoteControlManagementView.2
|
|
@Override // com.ubt.jimu.controller.component.SteeringWheelView.OnSlideListener
|
|
public void a(float f, float f2, float f3, JockstickData jockstickData) {
|
|
if (RemoteControlManagementView.this.U != null) {
|
|
RemoteControlManagementView.this.U.a(f, f2, f3, jockstickData);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.component.SteeringWheelView.OnSlideListener
|
|
public void a(JockstickData jockstickData, SuperControlView.MotionEventState motionEventState) {
|
|
if (RemoteControlManagementView.this.U != null) {
|
|
RemoteControlManagementView.this.U.a(jockstickData, motionEventState);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.component.SteeringWheelView.OnSlideListener
|
|
public void a(JockstickData jockstickData) {
|
|
if (RemoteControlManagementView.this.U != null) {
|
|
RemoteControlManagementView.this.U.a(jockstickData);
|
|
}
|
|
}
|
|
});
|
|
steeringWheelView.setOnControllerClickListener(this);
|
|
this.s.put(config.getConfigID(), steeringWheelView);
|
|
this.q.addView(steeringWheelView);
|
|
} else if (config instanceof HSliderConfig) {
|
|
PointF a2 = AdsorbUtils.a(this.c, this.d, dragEvent.getX(), dragEvent.getY(), this.A);
|
|
XLog.a("Controller", "adsorbPos: %s", a2.toString());
|
|
HSliderView hSliderView = new HSliderView(this.e, a2.x, a2.y);
|
|
hSliderView.setEditState(true);
|
|
hSliderView.e();
|
|
hSliderView.setControlTouchEvent(this);
|
|
hSliderView.setHSliderViewCommandSendListener(this);
|
|
hSliderView.a(this.j);
|
|
this.C.setCurrentPos(a2.x, a2.y);
|
|
hSliderView.setData((HSliderWidgetData) this.C);
|
|
this.q.addView(hSliderView);
|
|
this.s.put(config.getConfigID(), hSliderView);
|
|
} else if (config instanceof SliderConfig) {
|
|
PointF a3 = AdsorbUtils.a(this.c, this.d, dragEvent.getX(), dragEvent.getY(), this.A);
|
|
VSliderView vSliderView = new VSliderView(this.e, a3.x, a3.y);
|
|
vSliderView.setControlTouchEvent(this);
|
|
vSliderView.e();
|
|
vSliderView.a(this.j);
|
|
this.C.setCurrentPos(a3.x, a3.y);
|
|
vSliderView.setData((SliderWidgetData) this.C);
|
|
vSliderView.setUpdateCommandParameterListener(this);
|
|
vSliderView.setEditState(true);
|
|
this.s.put(config.getConfigID(), vSliderView);
|
|
this.q.addView(vSliderView);
|
|
} else if (config instanceof AccumulatorConfig) {
|
|
PointF a4 = AdsorbUtils.a(this.c, this.d, dragEvent.getX(), dragEvent.getY(), this.A);
|
|
WallPulleyView wallPulleyView = new WallPulleyView(this.e, a4.x, a4.y);
|
|
wallPulleyView.setEditState(true);
|
|
wallPulleyView.e();
|
|
wallPulleyView.setControlTouchEvent(this);
|
|
wallPulleyView.a(this.j);
|
|
this.C.setCurrentPos(a4.x, a4.y);
|
|
wallPulleyView.setData((AccumulatorData) this.C);
|
|
wallPulleyView.setWallPulleyViewCommandParameterListener(this);
|
|
this.s.put(config.getConfigID(), wallPulleyView);
|
|
this.q.addView(wallPulleyView);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void a(ControllerData controllerData) {
|
|
List<AccumulatorData> accumulatorData;
|
|
if (controllerData == null || (accumulatorData = controllerData.getAccumulatorData()) == null || accumulatorData.size() == 0) {
|
|
return;
|
|
}
|
|
for (AccumulatorData accumulatorData2 : accumulatorData) {
|
|
PointF b = b(accumulatorData2);
|
|
WallPulleyView wallPulleyView = new WallPulleyView(this.e, b.x, b.y);
|
|
wallPulleyView.setControlTouchEvent(this);
|
|
wallPulleyView.a(this.j);
|
|
wallPulleyView.setEditState(false);
|
|
wallPulleyView.setData(accumulatorData2);
|
|
wallPulleyView.setWallPulleyViewCommandParameterListener(this);
|
|
AccumulatorConfig config = accumulatorData2.getConfig();
|
|
if (config != null) {
|
|
this.s.put(config.getConfigID(), wallPulleyView);
|
|
this.q.addView(wallPulleyView);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.adapter.ItemDragListener
|
|
public void a(MenuItemView menuItemView, ItemBaseData itemBaseData) {
|
|
OnMenuItemClickListener onMenuItemClickListener = this.Q;
|
|
if (onMenuItemClickListener != null) {
|
|
onMenuItemClickListener.b(itemBaseData);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.OnControllerClickListener
|
|
public void a(ActionWidgetData actionWidgetData, SuperControlView superControlView) {
|
|
OnControllerClickListener onControllerClickListener;
|
|
if (getState() == ControllerState.STATE_PHYSICAL_CONTROLLER_CONFIG) {
|
|
setControlViewsSelectState(superControlView);
|
|
} else {
|
|
if (actionWidgetData == null || (onControllerClickListener = this.J) == null) {
|
|
return;
|
|
}
|
|
onControllerClickListener.a(actionWidgetData, superControlView);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.component.WallPulleyView.WallPulleyViewCommandParameterListener
|
|
public void a(float f, AccumulatorData accumulatorData) {
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.a(f, accumulatorData);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.manager.CommandSendManager.HSliderViewCommandSendListener
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void b(float f, HSliderWidgetData hSliderWidgetData) {
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.a(f, hSliderWidgetData);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.manager.CommandSendManager.HSliderViewCommandSendListener
|
|
public void a(HSliderWidgetData hSliderWidgetData) {
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.a(hSliderWidgetData);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.manager.CommandSendManager.VSliderViewCommandSendListener
|
|
/* renamed from: a, reason: avoid collision after fix types in other method and merged with bridge method [inline-methods] */
|
|
public void c(float f, SliderWidgetData sliderWidgetData) {
|
|
UpdateCommandParameterListener updateCommandParameterListener = this.U;
|
|
if (updateCommandParameterListener != null) {
|
|
updateCommandParameterListener.b(f, sliderWidgetData);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(final RecyclerView recyclerView, int i) {
|
|
int f = recyclerView.f(recyclerView.getChildAt(0));
|
|
int f2 = recyclerView.f(recyclerView.getChildAt(recyclerView.getChildCount() - 1));
|
|
if (i < f) {
|
|
recyclerView.k(i);
|
|
} else if (i <= f2) {
|
|
int i2 = i - f;
|
|
if (i2 >= 0 && i2 < recyclerView.getChildCount()) {
|
|
recyclerView.i(0, recyclerView.getChildAt(i2).getTop());
|
|
}
|
|
} else {
|
|
recyclerView.k(i);
|
|
this.W = i;
|
|
this.V = true;
|
|
}
|
|
recyclerView.a(new RecyclerView.OnScrollListener() { // from class: com.ubt.jimu.controller.view.RemoteControlManagementView.4
|
|
@Override // androidx.recyclerview.widget.RecyclerView.OnScrollListener
|
|
public void a(RecyclerView recyclerView2, int i3) {
|
|
super.a(recyclerView2, i3);
|
|
if (RemoteControlManagementView.this.V && i3 == 0) {
|
|
RemoteControlManagementView.this.V = false;
|
|
RemoteControlManagementView remoteControlManagementView = RemoteControlManagementView.this;
|
|
remoteControlManagementView.a(recyclerView, remoteControlManagementView.W);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public void a(String str) {
|
|
Map<String, SuperControlView> map = this.s;
|
|
if (map == null || map.size() <= 0) {
|
|
return;
|
|
}
|
|
ActionSequence a = ActionManager.a(this.e.getApplicationContext()).a(str);
|
|
SuperControlView superControlView = this.s.get(str);
|
|
if (superControlView != null) {
|
|
if (a == null) {
|
|
a(str, superControlView);
|
|
} else if (superControlView instanceof ActionView) {
|
|
((ActionWidgetData) superControlView.getData()).setActionSequence(a);
|
|
((ActionView) superControlView).a(a.d());
|
|
}
|
|
}
|
|
}
|
|
|
|
private void a(String str, View view) {
|
|
LogUtils.c("");
|
|
this.q.removeView(view);
|
|
this.s.remove(str);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.component.DeleteView.DeleteViewAnimatorListener
|
|
public void a() {
|
|
this.f.setVisibility(0);
|
|
}
|
|
}
|