Initial commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = AccumulatorDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorData extends MoveBaseData<AccumulatorConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private AccumulatorConfig config;
|
||||
|
||||
public AccumulatorData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(getConfig().getServoID()));
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(this.config.getServoID())) + "(" + this.config.getStartAngle() + "°~" + this.config.getLaunchAngle() + "°)";
|
||||
}
|
||||
|
||||
public AccumulatorData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public AccumulatorConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(AccumulatorConfig accumulatorConfig) {
|
||||
super.setConfig((AccumulatorData) accumulatorConfig);
|
||||
this.config = accumulatorConfig;
|
||||
}
|
||||
|
||||
public AccumulatorData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
|
||||
public AccumulatorData(String str, byte b, int i, int i2, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AccumulatorDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String MAX_ANGLE = "max_angle";
|
||||
public static final String MIN_ANGLE = "min_angle";
|
||||
public static final String SERVO_ID = "servoID";
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return AccumulatorData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
AccumulatorData accumulatorData = (AccumulatorData) obj;
|
||||
if (!TextUtils.isEmpty(accumulatorData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", accumulatorData.getWidgetId());
|
||||
}
|
||||
AccumulatorConfig config = accumulatorData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(accumulatorData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(accumulatorData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
AccumulatorData accumulatorData = new AccumulatorData(attribute);
|
||||
AccumulatorConfig accumulatorConfig = new AccumulatorConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
accumulatorConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -251140552:
|
||||
if (nodeName.equals("max_angle")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 521338022:
|
||||
if (nodeName.equals("min_angle")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1984158196:
|
||||
if (nodeName.equals("servoID")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
accumulatorData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
accumulatorData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
accumulatorConfig.setServoID(valueOf.intValue());
|
||||
}
|
||||
} else if (c == 3) {
|
||||
accumulatorConfig.setStartAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
accumulatorConfig.setLaunchAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
accumulatorData.setConfig(accumulatorConfig);
|
||||
return accumulatorData;
|
||||
}
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionDataConverter implements Converter {
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return ActionWidgetData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
ActionWidgetData actionWidgetData = (ActionWidgetData) obj;
|
||||
if (!TextUtils.isEmpty(actionWidgetData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", actionWidgetData.getWidgetId());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
if (!TextUtils.isEmpty(actionWidgetData.getActionID())) {
|
||||
hierarchicalStreamWriter.startNode(ActionWidgetData.ACTION_ID);
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getActionID()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
if (TextUtils.isEmpty(actionWidgetData.getActionNm())) {
|
||||
return;
|
||||
}
|
||||
hierarchicalStreamWriter.startNode(ActionWidgetData.ACTION_NM);
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(actionWidgetData.getActionNm()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
ActionWidgetData actionWidgetData = new ActionWidgetData(attribute);
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -1656172079:
|
||||
if (nodeName.equals(ActionWidgetData.ACTION_ID)) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case -1656172047:
|
||||
if (nodeName.equals(UnityActivity.KEY_ACTION_ID)) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case -1656171883:
|
||||
if (nodeName.equals(ActionWidgetData.ACTION_NM)) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
actionWidgetData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
actionWidgetData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
actionWidgetData.setActionID(hierarchicalStreamReader.getValue());
|
||||
} else if (c == 3) {
|
||||
actionWidgetData.setActionID(hierarchicalStreamReader.getValue());
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
actionWidgetData.setActionNm(hierarchicalStreamReader.getValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
return actionWidgetData;
|
||||
}
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.action.ActionSequence;
|
||||
import com.ubt.jimu.utils.LocaleUtils;
|
||||
|
||||
@XStreamAlias("actionData")
|
||||
@XStreamConverter(ActionDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class ActionWidgetData extends ItemBaseData {
|
||||
public static final String ACTION_ID = "actionID";
|
||||
public static final String ACTION_NM = "actionNm";
|
||||
private String actionID;
|
||||
private String actionNm;
|
||||
|
||||
@XStreamOmitField
|
||||
private ActionSequence actionSequence;
|
||||
|
||||
public ActionWidgetData() {
|
||||
}
|
||||
|
||||
public String getActionID() {
|
||||
return this.actionID;
|
||||
}
|
||||
|
||||
public String getActionNm() {
|
||||
return this.actionNm;
|
||||
}
|
||||
|
||||
public ActionSequence getActionSequence() {
|
||||
return this.actionSequence;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public int getImageViewId() {
|
||||
int d;
|
||||
ActionSequence actionSequence = this.actionSequence;
|
||||
return (actionSequence == null || (d = actionSequence.d()) <= 0) ? R.drawable.icon_loudly : d;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getShowName(String str) {
|
||||
ActionSequence actionSequence = this.actionSequence;
|
||||
if (actionSequence != null) {
|
||||
String a = actionSequence.a(str);
|
||||
if (!TextUtils.isEmpty(a)) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return this.actionNm;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return getShowName(LocaleUtils.b());
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public boolean isOfficial() {
|
||||
ActionSequence actionSequence = this.actionSequence;
|
||||
if (actionSequence != null) {
|
||||
return actionSequence.j();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setActionID(String str) {
|
||||
this.actionID = str;
|
||||
}
|
||||
|
||||
public void setActionNm(String str) {
|
||||
this.actionNm = str;
|
||||
}
|
||||
|
||||
public void setActionSequence(ActionSequence actionSequence) {
|
||||
this.actionSequence = actionSequence;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("ActionWidgetData: ");
|
||||
sb.append(" actionID: " + this.actionID);
|
||||
sb.append(" actionNm: " + this.actionNm);
|
||||
return super.toString() + " " + sb.toString();
|
||||
}
|
||||
|
||||
public ActionWidgetData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public ActionWidgetData(String str, String str2, String str3, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
this.actionID = str2;
|
||||
this.actionNm = str3;
|
||||
}
|
||||
}
|
27
sources/com/ubt/jimu/controller/data/widget/AddViewData.java
Normal file
27
sources/com/ubt/jimu/controller/data/widget/AddViewData.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AddViewData extends MoveBaseData {
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public WidgetConfig getConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData, com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public boolean isOfficial() {
|
||||
return false;
|
||||
}
|
||||
}
|
399
sources/com/ubt/jimu/controller/data/widget/ControllerData.java
Normal file
399
sources/com/ubt/jimu/controller/data/widget/ControllerData.java
Normal file
@@ -0,0 +1,399 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Size;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
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.transport.model.TransportFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@XStreamAlias(TransportFile.MODEL_CONTROLLER_DIR)
|
||||
/* loaded from: classes.dex */
|
||||
public class ControllerData {
|
||||
public static final int DEFAULT_SCREEN_HEIGHT = 750;
|
||||
public static final int DEFAULT_SCREEN_WIDTH = 1334;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "xlsliderData")
|
||||
private List<AccumulatorData> accumulatorData;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "actionData")
|
||||
private List<ActionWidgetData> actionData;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private String controllerID;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size displaySize;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "hsliderData")
|
||||
private List<HSliderWidgetData> hsliderData;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "jockstickData")
|
||||
private List<JockstickData> jockstickData;
|
||||
|
||||
@XStreamAlias("ScreenHeight")
|
||||
@XStreamAsAttribute
|
||||
private int screenHeight;
|
||||
|
||||
@XStreamAlias("ScreenWidth")
|
||||
@XStreamAsAttribute
|
||||
private int screenWidth;
|
||||
|
||||
@XStreamImplicit(itemFieldName = "sliderData")
|
||||
private List<SliderWidgetData> sliderData;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size xmlSize;
|
||||
|
||||
public ControllerData() {
|
||||
this.screenWidth = DEFAULT_SCREEN_WIDTH;
|
||||
this.screenHeight = DEFAULT_SCREEN_HEIGHT;
|
||||
this.actionData = new ArrayList();
|
||||
this.sliderData = new ArrayList();
|
||||
this.hsliderData = new ArrayList();
|
||||
this.jockstickData = new ArrayList();
|
||||
this.accumulatorData = new ArrayList();
|
||||
}
|
||||
|
||||
private boolean hasMoveWidget() {
|
||||
List<HSliderWidgetData> list;
|
||||
List<JockstickData> list2;
|
||||
List<SliderWidgetData> list3 = this.sliderData;
|
||||
return (list3 != null && list3.size() > 0) || ((list = this.hsliderData) != null && list.size() > 0) || ((list2 = this.jockstickData) != null && list2.size() > 0);
|
||||
}
|
||||
|
||||
private boolean removeItem(String str, List<? extends ItemBaseData> list) {
|
||||
if (!TextUtils.isEmpty(str) && list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (str.equals(list.get(i).getWidgetId())) {
|
||||
return list.remove(i) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void transformInternal(List<? extends ItemBaseData> list, Size size, Size size2) {
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (ItemBaseData itemBaseData : list) {
|
||||
itemBaseData.setDisplaySize(size, size2);
|
||||
itemBaseData.transform();
|
||||
}
|
||||
}
|
||||
|
||||
public void addAccumulatorData(AccumulatorData accumulatorData) {
|
||||
List<AccumulatorData> list = this.accumulatorData;
|
||||
if (list != null) {
|
||||
list.add(accumulatorData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addActionData(ActionWidgetData actionWidgetData) {
|
||||
List<ActionWidgetData> list = this.actionData;
|
||||
if (list == null || actionWidgetData == null) {
|
||||
return;
|
||||
}
|
||||
list.add(actionWidgetData);
|
||||
}
|
||||
|
||||
public void addData(ItemBaseData itemBaseData) {
|
||||
if (itemBaseData == null) {
|
||||
return;
|
||||
}
|
||||
if (itemBaseData instanceof JockstickData) {
|
||||
Log.e("Test", "JockstickData:" + itemBaseData);
|
||||
addJockstickData((JockstickData) itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof HSliderWidgetData) {
|
||||
addHsliderData((HSliderWidgetData) itemBaseData);
|
||||
Log.e("Test", "moveBaseData:" + itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof SliderWidgetData) {
|
||||
addSliderData((SliderWidgetData) itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof ActionWidgetData) {
|
||||
Log.e("Test", "保存动作");
|
||||
addActionData((ActionWidgetData) itemBaseData);
|
||||
}
|
||||
if (itemBaseData instanceof AccumulatorData) {
|
||||
addAccumulatorData((AccumulatorData) itemBaseData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addHsliderData(HSliderWidgetData hSliderWidgetData) {
|
||||
List<HSliderWidgetData> list = this.hsliderData;
|
||||
if (list != null) {
|
||||
list.add(hSliderWidgetData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addJockstickData(JockstickData jockstickData) {
|
||||
List<JockstickData> list = this.jockstickData;
|
||||
if (list != null) {
|
||||
list.add(jockstickData);
|
||||
}
|
||||
}
|
||||
|
||||
public void addSliderData(SliderWidgetData sliderWidgetData) {
|
||||
List<SliderWidgetData> list = this.sliderData;
|
||||
if (list == null || sliderWidgetData == null) {
|
||||
return;
|
||||
}
|
||||
list.add(sliderWidgetData);
|
||||
}
|
||||
|
||||
public boolean clearEmptyWidget() {
|
||||
List<JockstickData> list = this.jockstickData;
|
||||
boolean z = false;
|
||||
if (list != null && list.size() > 0) {
|
||||
for (JockstickData jockstickData : new ArrayList(this.jockstickData)) {
|
||||
JockstickConfig config = jockstickData.getConfig();
|
||||
if (config == null || config.getType() == JockstickConfig.JockType.none || config.getWheelList() == null || config.getWheelList().isEmpty()) {
|
||||
this.jockstickData.remove(jockstickData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SliderWidgetData> list2 = this.sliderData;
|
||||
if (list2 != null && list2.size() > 0) {
|
||||
for (SliderWidgetData sliderWidgetData : new ArrayList(this.sliderData)) {
|
||||
SliderConfig config2 = sliderWidgetData.getConfig();
|
||||
if (config2 == null || config2.getServoID() <= 0) {
|
||||
this.sliderData.remove(sliderWidgetData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<HSliderWidgetData> list3 = this.hsliderData;
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
for (HSliderWidgetData hSliderWidgetData : new ArrayList(this.hsliderData)) {
|
||||
HSliderConfig config3 = hSliderWidgetData.getConfig();
|
||||
if (config3 == null || config3.getServoID() <= 0) {
|
||||
this.hsliderData.remove(hSliderWidgetData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<AccumulatorData> list4 = this.accumulatorData;
|
||||
if (list4 != null && list4.size() > 0) {
|
||||
for (AccumulatorData accumulatorData : new ArrayList(this.accumulatorData)) {
|
||||
AccumulatorConfig config4 = accumulatorData.getConfig();
|
||||
if (config4 == null || config4.getServoID() <= 0) {
|
||||
this.accumulatorData.remove(accumulatorData);
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public List<AccumulatorData> getAccumulatorData() {
|
||||
return this.accumulatorData;
|
||||
}
|
||||
|
||||
public List<ActionWidgetData> getActionData() {
|
||||
return this.actionData;
|
||||
}
|
||||
|
||||
public String getControllerID() {
|
||||
return this.controllerID;
|
||||
}
|
||||
|
||||
public List<HSliderWidgetData> getHsliderData() {
|
||||
return this.hsliderData;
|
||||
}
|
||||
|
||||
public List<JockstickData> getJockstickData() {
|
||||
return this.jockstickData;
|
||||
}
|
||||
|
||||
public MoveWidgetData getMoveConfig() {
|
||||
MoveWidgetData moveWidgetData;
|
||||
List<SliderWidgetData> list = this.sliderData;
|
||||
if (list == null || list.size() <= 0) {
|
||||
moveWidgetData = null;
|
||||
} else {
|
||||
ArrayList arrayList = new ArrayList(this.sliderData.size());
|
||||
Iterator<SliderWidgetData> it = this.sliderData.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(it.next().getConfig());
|
||||
}
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
moveWidgetData.setSliderConfigList(arrayList);
|
||||
}
|
||||
List<HSliderWidgetData> list2 = this.hsliderData;
|
||||
if (list2 != null && list2.size() > 0) {
|
||||
ArrayList arrayList2 = new ArrayList(this.hsliderData.size());
|
||||
Iterator<HSliderWidgetData> it2 = this.hsliderData.iterator();
|
||||
while (it2.hasNext()) {
|
||||
arrayList2.add(it2.next().getConfig());
|
||||
}
|
||||
if (moveWidgetData == null) {
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
}
|
||||
moveWidgetData.setHSliderConfigList(arrayList2);
|
||||
}
|
||||
List<JockstickData> list3 = this.jockstickData;
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
ArrayList arrayList3 = new ArrayList(this.jockstickData.size());
|
||||
Iterator<JockstickData> it3 = this.jockstickData.iterator();
|
||||
while (it3.hasNext()) {
|
||||
arrayList3.add(it3.next().getConfig());
|
||||
}
|
||||
if (moveWidgetData == null) {
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
}
|
||||
moveWidgetData.setJockstickConfigList(arrayList3);
|
||||
}
|
||||
List<AccumulatorData> list4 = this.accumulatorData;
|
||||
if (list4 != null && list4.size() > 0) {
|
||||
ArrayList arrayList4 = new ArrayList(this.accumulatorData.size());
|
||||
Iterator<AccumulatorData> it4 = this.accumulatorData.iterator();
|
||||
while (it4.hasNext()) {
|
||||
arrayList4.add(it4.next().getConfig());
|
||||
}
|
||||
if (moveWidgetData == null) {
|
||||
moveWidgetData = new MoveWidgetData();
|
||||
}
|
||||
moveWidgetData.setAccumulatorConfigList(arrayList4);
|
||||
}
|
||||
return moveWidgetData;
|
||||
}
|
||||
|
||||
public int getScreenHeight() {
|
||||
return this.screenHeight;
|
||||
}
|
||||
|
||||
public int getScreenWidth() {
|
||||
return this.screenWidth;
|
||||
}
|
||||
|
||||
public List<SliderWidgetData> getSliderData() {
|
||||
return this.sliderData;
|
||||
}
|
||||
|
||||
public float getTransformRatio() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public boolean hasAction() {
|
||||
return getActionData() != null && getActionData().size() > 0;
|
||||
}
|
||||
|
||||
public boolean removeAccumulatorData(String str) {
|
||||
return removeItem(str, this.accumulatorData);
|
||||
}
|
||||
|
||||
public boolean removeActionData(String str) {
|
||||
return removeItem(str, this.actionData);
|
||||
}
|
||||
|
||||
public boolean removeHsliderData(String str) {
|
||||
return removeItem(str, this.hsliderData);
|
||||
}
|
||||
|
||||
public boolean removeJockstickData(String str) {
|
||||
return removeItem(str, this.jockstickData);
|
||||
}
|
||||
|
||||
public boolean removeSliderData(String str) {
|
||||
return removeItem(str, this.sliderData);
|
||||
}
|
||||
|
||||
public void setAccumulatorData(List<AccumulatorData> list) {
|
||||
this.accumulatorData = list;
|
||||
}
|
||||
|
||||
public void setActionData(List<ActionWidgetData> list) {
|
||||
this.actionData = list;
|
||||
}
|
||||
|
||||
public void setControllerID(String str) {
|
||||
this.controllerID = str;
|
||||
}
|
||||
|
||||
public void setHsliderData(List<HSliderWidgetData> list) {
|
||||
this.hsliderData = list;
|
||||
}
|
||||
|
||||
public void setJockstickData(List<JockstickData> list) {
|
||||
this.jockstickData = list;
|
||||
}
|
||||
|
||||
public void setScreenHeight(int i) {
|
||||
this.screenHeight = i;
|
||||
}
|
||||
|
||||
public void setScreenWidth(int i) {
|
||||
this.screenWidth = i;
|
||||
}
|
||||
|
||||
public void setSliderData(List<SliderWidgetData> list) {
|
||||
this.sliderData = list;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("ControllerData: ");
|
||||
sb.append(" controllerID : " + this.controllerID);
|
||||
sb.append(" screenWidth: " + this.screenWidth);
|
||||
sb.append(" screenHeight" + this.screenHeight);
|
||||
StringBuilder sb2 = new StringBuilder();
|
||||
sb2.append(" actionData: ");
|
||||
List<ActionWidgetData> list = this.actionData;
|
||||
sb2.append(list != null ? list.toString() : "null");
|
||||
sb.append(sb2.toString());
|
||||
StringBuilder sb3 = new StringBuilder();
|
||||
sb3.append(" sliderData: ");
|
||||
List<SliderWidgetData> list2 = this.sliderData;
|
||||
sb3.append(list2 != null ? list2.toString() : "null");
|
||||
sb.append(sb3.toString());
|
||||
StringBuilder sb4 = new StringBuilder();
|
||||
sb4.append(" hsliderData: ");
|
||||
List<HSliderWidgetData> list3 = this.hsliderData;
|
||||
sb4.append(list3 != null ? list3.toString() : "null");
|
||||
sb.append(sb4.toString());
|
||||
StringBuilder sb5 = new StringBuilder();
|
||||
sb5.append(" jockstickData: ");
|
||||
List<JockstickData> list4 = this.jockstickData;
|
||||
sb5.append(list4 != null ? list4.toString() : "null");
|
||||
sb.append(sb5.toString());
|
||||
StringBuilder sb6 = new StringBuilder();
|
||||
sb6.append(" accumulatorData: ");
|
||||
List<AccumulatorData> list5 = this.accumulatorData;
|
||||
sb6.append(list5 != null ? list5.toString() : "null");
|
||||
sb.append(sb6.toString());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void transform(Size size, Size size2) {
|
||||
transformInternal(this.actionData, size, size2);
|
||||
transformInternal(this.jockstickData, size, size2);
|
||||
transformInternal(this.sliderData, size, size2);
|
||||
transformInternal(this.hsliderData, size, size2);
|
||||
transformInternal(this.accumulatorData, size, size2);
|
||||
}
|
||||
|
||||
public boolean removeActionData(ActionWidgetData actionWidgetData) {
|
||||
List<ActionWidgetData> list = this.actionData;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
return this.actionData.remove(actionWidgetData);
|
||||
}
|
||||
|
||||
public ControllerData(String str) {
|
||||
this();
|
||||
this.controllerID = str;
|
||||
}
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HSliderDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String MAX_ANGLE = "max_angle";
|
||||
public static final String MIN_ANGLE = "min_angle";
|
||||
public static final String SERVO_ID = "servoID";
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return HSliderWidgetData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
HSliderWidgetData hSliderWidgetData = (HSliderWidgetData) obj;
|
||||
if (!TextUtils.isEmpty(hSliderWidgetData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", hSliderWidgetData.getWidgetId());
|
||||
}
|
||||
HSliderConfig config = hSliderWidgetData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(hSliderWidgetData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(hSliderWidgetData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
HSliderWidgetData hSliderWidgetData = new HSliderWidgetData(attribute);
|
||||
HSliderConfig hSliderConfig = new HSliderConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
hSliderConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -251140552:
|
||||
if (nodeName.equals("max_angle")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 521338022:
|
||||
if (nodeName.equals("min_angle")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1984158196:
|
||||
if (nodeName.equals("servoID")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
hSliderWidgetData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
hSliderWidgetData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
hSliderConfig.setServoID(valueOf.intValue());
|
||||
}
|
||||
} else if (c == 3) {
|
||||
hSliderConfig.setMinAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
hSliderConfig.setMaxAngle(Integer.valueOf(hierarchicalStreamReader.getValue()).intValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
hSliderWidgetData.setConfig(hSliderConfig);
|
||||
return hSliderWidgetData;
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.HSliderConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = HSliderDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class HSliderWidgetData extends MoveBaseData<HSliderConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private HSliderConfig config;
|
||||
|
||||
public HSliderWidgetData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(getConfig().getServoID()));
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
HSliderConfig config = getConfig();
|
||||
if (config == null) {
|
||||
return "";
|
||||
}
|
||||
return String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(config.getServoID())) + "(" + config.getMinAngle() + "°~" + config.getMaxAngle() + "°)";
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
return super.toString() + " " + getConfig().toString();
|
||||
}
|
||||
|
||||
public HSliderWidgetData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public HSliderConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(HSliderConfig hSliderConfig) {
|
||||
super.setConfig((HSliderWidgetData) hSliderConfig);
|
||||
this.config = hSliderConfig;
|
||||
}
|
||||
|
||||
public HSliderWidgetData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public HSliderWidgetData(String str, byte b, int i, int i2, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
169
sources/com/ubt/jimu/controller/data/widget/ItemBaseData.java
Normal file
169
sources/com/ubt/jimu/controller/data/widget/ItemBaseData.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Size;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.controller.util.IDGenerator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class ItemBaseData {
|
||||
static final String ALIAS_POS_X = "pos_x";
|
||||
static final String ALIAS_POS_Y = "pos_y";
|
||||
static final String ALIAS_WIDGET_ID = "widgetId";
|
||||
|
||||
@XStreamOmitField
|
||||
private int ImageViewId;
|
||||
|
||||
@XStreamOmitField
|
||||
private float currentX;
|
||||
|
||||
@XStreamOmitField
|
||||
private float currentY;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size displaySize;
|
||||
|
||||
@XStreamAlias(ALIAS_POS_X)
|
||||
private float posX;
|
||||
|
||||
@XStreamAlias(ALIAS_POS_Y)
|
||||
private float posY;
|
||||
|
||||
@XStreamOmitField
|
||||
private String showName;
|
||||
|
||||
@XStreamAsAttribute
|
||||
private String widgetId;
|
||||
|
||||
@XStreamOmitField
|
||||
private Size xmlSize;
|
||||
|
||||
public ItemBaseData() {
|
||||
this.widgetId = IDGenerator.a(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private float getDisplayRatio() {
|
||||
float height = this.displaySize.getHeight() / this.xmlSize.getHeight();
|
||||
float width = this.displaySize.getWidth() / this.xmlSize.getWidth();
|
||||
return width > height ? height : width;
|
||||
}
|
||||
|
||||
private float getSaveRatio() {
|
||||
float height = this.xmlSize.getHeight() / this.displaySize.getHeight();
|
||||
float width = this.xmlSize.getWidth() / this.displaySize.getWidth();
|
||||
return width < height ? height : width;
|
||||
}
|
||||
|
||||
private void transformX(float f) {
|
||||
if (Math.abs(f) > 1.0E-6f) {
|
||||
if (this.displaySize == null || this.xmlSize == null) {
|
||||
this.posX = f;
|
||||
} else {
|
||||
this.posX = (f - (r0.getWidth() / 2.0f)) * getSaveRatio();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transformY(float f) {
|
||||
if (Math.abs(f) > 1.0E-6f) {
|
||||
if (this.displaySize == null || this.xmlSize == null) {
|
||||
this.posY = f;
|
||||
} else {
|
||||
this.posY = ((r0.getHeight() / 2.0f) - f) * getSaveRatio();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float getCurrentX() {
|
||||
if (Math.abs(this.currentX) < 1.0E-6f && this.displaySize != null && this.xmlSize != null) {
|
||||
this.currentX = (this.posX * getDisplayRatio()) + (this.displaySize.getWidth() / 2.0f);
|
||||
}
|
||||
return this.currentX;
|
||||
}
|
||||
|
||||
public float getCurrentY() {
|
||||
if (Math.abs(this.currentY) < 1.0E-6f && this.displaySize != null && this.xmlSize != null) {
|
||||
this.currentY = (this.displaySize.getHeight() / 2.0f) - (this.posY * getDisplayRatio());
|
||||
}
|
||||
return this.currentY;
|
||||
}
|
||||
|
||||
public int getImageViewId() {
|
||||
return this.ImageViewId;
|
||||
}
|
||||
|
||||
public float getPosX() {
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
public float getPosY() {
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
public String getShowName(String str) {
|
||||
return this.showName;
|
||||
}
|
||||
|
||||
public String getWidgetId() {
|
||||
return this.widgetId;
|
||||
}
|
||||
|
||||
public abstract String getWidgetInfo(Context context);
|
||||
|
||||
public abstract boolean isOfficial();
|
||||
|
||||
public void setCurrentPos(float f, float f2) {
|
||||
setCurrentX(f);
|
||||
setCurrentY(f2);
|
||||
}
|
||||
|
||||
public void setCurrentX(float f) {
|
||||
this.currentX = f;
|
||||
}
|
||||
|
||||
public void setCurrentY(float f) {
|
||||
this.currentY = f;
|
||||
}
|
||||
|
||||
protected void setDisplaySize(Size size, Size size2) {
|
||||
this.displaySize = size;
|
||||
this.xmlSize = size2;
|
||||
}
|
||||
|
||||
public void setImageViewId(int i) {
|
||||
this.ImageViewId = i;
|
||||
}
|
||||
|
||||
protected void setPosX(float f) {
|
||||
this.posX = f;
|
||||
}
|
||||
|
||||
protected void setPosY(float f) {
|
||||
this.posY = f;
|
||||
}
|
||||
|
||||
public void setShowName(String str) {
|
||||
this.showName = str;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ItemBaseData{widgetId='" + this.widgetId + "', posX=" + this.posX + ", posY=" + this.posY + ", ImageViewId=" + getImageViewId() + ", showName='" + this.showName + "', displaySize=" + this.displaySize + ", xmlSize=" + this.xmlSize + ", currentX=" + getCurrentX() + ", currentY=" + getCurrentY() + '}';
|
||||
}
|
||||
|
||||
protected void transform() {
|
||||
transformX(this.currentX);
|
||||
transformY(this.currentY);
|
||||
}
|
||||
|
||||
public ItemBaseData(String str) {
|
||||
this.widgetId = str;
|
||||
}
|
||||
|
||||
public ItemBaseData(String str, float f, float f2) {
|
||||
this(str);
|
||||
this.posX = f;
|
||||
this.posY = f2;
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = JockstickDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickData extends MoveBaseData<JockstickConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private JockstickConfig config;
|
||||
|
||||
public JockstickData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
String string = context.getResources().getString(R.string.control_two_engine);
|
||||
if (getConfig().getType() == JockstickConfig.JockType.fourServo) {
|
||||
string = context.getResources().getString(R.string.control_four_engine);
|
||||
}
|
||||
if (getConfig().getType() == JockstickConfig.JockType.sixServo) {
|
||||
string = context.getResources().getString(R.string.control_six_engine);
|
||||
}
|
||||
int index = getConfig().getIndex();
|
||||
if (index <= 1) {
|
||||
return string;
|
||||
}
|
||||
return string + index;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
return getShowName(context);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
return super.toString() + " " + getConfig().toString();
|
||||
}
|
||||
|
||||
public JockstickData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public JockstickConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(JockstickConfig jockstickConfig) {
|
||||
super.setConfig((JockstickData) jockstickConfig);
|
||||
this.config = jockstickConfig;
|
||||
}
|
||||
|
||||
public JockstickData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,156 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.config.JockstickConfig;
|
||||
import com.ubt.jimu.controller.data.config.Wheel;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubtech.utils.XLog;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JockstickDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String ID = "id";
|
||||
public static final String MOTION_TYPE = "motionType";
|
||||
public static final String POS = "pos";
|
||||
public static final String REVERSE = "reverse";
|
||||
public static final String TYPE = "type";
|
||||
public static final String WHEEL = "wheel";
|
||||
|
||||
private void marshalConfig(HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext, JockstickConfig jockstickConfig) {
|
||||
if (jockstickConfig != null) {
|
||||
JockstickConfig.JockType type = jockstickConfig.getType();
|
||||
if (type != null) {
|
||||
hierarchicalStreamWriter.startNode("type");
|
||||
hierarchicalStreamWriter.setValue(type.name());
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
CtrlMotionType motionType = jockstickConfig.getMotionType();
|
||||
if (motionType != null) {
|
||||
hierarchicalStreamWriter.startNode("motionType");
|
||||
hierarchicalStreamWriter.setValue(motionType.name());
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
List<Wheel> wheelList = jockstickConfig.getWheelList();
|
||||
if (wheelList == null || wheelList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
for (Wheel wheel : wheelList) {
|
||||
hierarchicalStreamWriter.startNode(WHEEL);
|
||||
marshallingContext.convertAnother(wheel);
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return JockstickData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
JockstickData jockstickData = (JockstickData) obj;
|
||||
if (!TextUtils.isEmpty(jockstickData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", jockstickData.getWidgetId());
|
||||
}
|
||||
JockstickConfig config = jockstickData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(jockstickData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(jockstickData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
JockstickData jockstickData = new JockstickData(attribute);
|
||||
JockstickConfig jockstickConfig = new JockstickConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
jockstickConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
switch (hierarchicalStreamReader.getNodeName()) {
|
||||
case "pos_x":
|
||||
jockstickData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
break;
|
||||
case "pos_y":
|
||||
jockstickData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
break;
|
||||
case "type":
|
||||
try {
|
||||
jockstickConfig.setType((JockstickConfig.JockType) unmarshallingContext.convertAnother(jockstickData, JockstickConfig.JockType.class));
|
||||
break;
|
||||
} catch (Exception e) {
|
||||
XLog.b(TransportFile.TYPE_CONTROLLER, "unknown JockType");
|
||||
e.printStackTrace();
|
||||
jockstickConfig.setType(JockstickConfig.JockType.twoServo);
|
||||
break;
|
||||
}
|
||||
case "motionType":
|
||||
try {
|
||||
jockstickConfig.setMotionType((CtrlMotionType) unmarshallingContext.convertAnother(jockstickData, CtrlMotionType.class));
|
||||
break;
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
jockstickConfig.setMotionType(CtrlMotionType.servo);
|
||||
break;
|
||||
}
|
||||
case "leftUpID":
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
jockstickConfig.putWheel(1, new Wheel(valueOf.intValue(), 1));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "rightUpID":
|
||||
Integer valueOf2 = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf2 != null && valueOf2.intValue() > 0) {
|
||||
jockstickConfig.putWheel(2, new Wheel(valueOf2.intValue(), 2));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "leftBottomID":
|
||||
Integer valueOf3 = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf3 != null && valueOf3.intValue() > 0) {
|
||||
jockstickConfig.putWheel(3, new Wheel(valueOf3.intValue(), 3));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "rightBottomID":
|
||||
Integer valueOf4 = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf4 != null && valueOf4.intValue() > 0) {
|
||||
jockstickConfig.putWheel(4, new Wheel(valueOf4.intValue(), 4));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "wheel":
|
||||
Wheel wheel = (Wheel) unmarshallingContext.convertAnother(jockstickData, Wheel.class);
|
||||
jockstickConfig.putWheel(wheel.getPosition(), wheel);
|
||||
break;
|
||||
default:
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
break;
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
jockstickData.setConfig(jockstickConfig);
|
||||
return jockstickData;
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
|
||||
import com.ubt.jimu.controller.data.config.WidgetConfig;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class MoveBaseData<C extends WidgetConfig> extends ItemBaseData {
|
||||
|
||||
@XStreamAsAttribute
|
||||
private String configID;
|
||||
|
||||
public MoveBaseData() {
|
||||
}
|
||||
|
||||
public abstract C getConfig();
|
||||
|
||||
public String getConfigID() {
|
||||
return this.configID;
|
||||
}
|
||||
|
||||
public abstract String getShowName(Context context);
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public boolean isOfficial() {
|
||||
return getConfig() != null && getConfig().getConfigType() == 1;
|
||||
}
|
||||
|
||||
public void setConfig(C c) {
|
||||
this.configID = c.getConfigID();
|
||||
}
|
||||
|
||||
public void setConfigID(String str) {
|
||||
this.configID = str;
|
||||
}
|
||||
|
||||
public void updateConfig(C c) {
|
||||
setConfig(c);
|
||||
}
|
||||
|
||||
public MoveBaseData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public MoveBaseData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
250
sources/com/ubt/jimu/controller/data/widget/MoveWidgetData.java
Normal file
250
sources/com/ubt/jimu/controller/data/widget/MoveWidgetData.java
Normal file
@@ -0,0 +1,250 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicit;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@XStreamAlias("MoveWidgetData")
|
||||
/* loaded from: classes.dex */
|
||||
public class MoveWidgetData {
|
||||
|
||||
@XStreamImplicit
|
||||
private List<AccumulatorConfig> accumulatorConfigList;
|
||||
|
||||
@XStreamImplicit
|
||||
private List<HSliderConfig> hSliderConfigList;
|
||||
|
||||
@XStreamImplicit
|
||||
private List<JockstickConfig> jockstickConfigList;
|
||||
|
||||
@XStreamImplicit
|
||||
private List<SliderConfig> sliderConfigList;
|
||||
|
||||
static /* synthetic */ int a(WidgetConfig widgetConfig, WidgetConfig widgetConfig2) {
|
||||
return widgetConfig2.getConfigType() != widgetConfig.getConfigType() ? widgetConfig2.getConfigType() - widgetConfig.getConfigType() : widgetConfig2.getConfigID().compareTo(widgetConfig.getConfigID());
|
||||
}
|
||||
|
||||
private boolean isExclusive(List<? extends WidgetConfig> list, WidgetConfig widgetConfig) {
|
||||
for (WidgetConfig widgetConfig2 : list) {
|
||||
if (widgetConfig2.equals(widgetConfig)) {
|
||||
widgetConfig.setConfigID(widgetConfig2.getConfigID());
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.isEmpty(widgetConfig.getConfigID()) && widgetConfig2.getConfigID().equals(widgetConfig.getConfigID())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addAccumulatorConfig(AccumulatorConfig accumulatorConfig) {
|
||||
List<AccumulatorConfig> list = this.accumulatorConfigList;
|
||||
if (list == null) {
|
||||
this.accumulatorConfigList = new ArrayList();
|
||||
this.accumulatorConfigList.add(accumulatorConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, accumulatorConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.accumulatorConfigList.add(accumulatorConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addHSliderConfig(HSliderConfig hSliderConfig) {
|
||||
List<HSliderConfig> list = this.hSliderConfigList;
|
||||
if (list == null) {
|
||||
this.hSliderConfigList = new ArrayList();
|
||||
this.hSliderConfigList.add(hSliderConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, hSliderConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.hSliderConfigList.add(hSliderConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addJockstickConfig(JockstickConfig jockstickConfig) {
|
||||
List<JockstickConfig> list = this.jockstickConfigList;
|
||||
if (list == null) {
|
||||
this.jockstickConfigList = new ArrayList();
|
||||
this.jockstickConfigList.add(jockstickConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, jockstickConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.jockstickConfigList.add(jockstickConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean addSliderConfig(SliderConfig sliderConfig) {
|
||||
List<SliderConfig> list = this.sliderConfigList;
|
||||
if (list == null) {
|
||||
this.sliderConfigList = new ArrayList();
|
||||
this.sliderConfigList.add(sliderConfig);
|
||||
return true;
|
||||
}
|
||||
if (!isExclusive(list, sliderConfig)) {
|
||||
return false;
|
||||
}
|
||||
this.sliderConfigList.add(sliderConfig);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<AccumulatorConfig> getAccumulatorConfigList() {
|
||||
return this.accumulatorConfigList;
|
||||
}
|
||||
|
||||
public List<WidgetConfig> getConfigList() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
List<JockstickConfig> list = this.jockstickConfigList;
|
||||
if (list != null && list.size() > 0) {
|
||||
arrayList.addAll(this.jockstickConfigList);
|
||||
}
|
||||
List<SliderConfig> list2 = this.sliderConfigList;
|
||||
if (list2 != null && list2.size() > 0) {
|
||||
arrayList.addAll(this.sliderConfigList);
|
||||
}
|
||||
List<HSliderConfig> list3 = this.hSliderConfigList;
|
||||
if (list3 != null && list3.size() > 0) {
|
||||
arrayList.addAll(this.hSliderConfigList);
|
||||
}
|
||||
List<AccumulatorConfig> list4 = this.accumulatorConfigList;
|
||||
if (list4 != null && list4.size() > 0) {
|
||||
arrayList.addAll(this.accumulatorConfigList);
|
||||
}
|
||||
Collections.sort(arrayList, new Comparator() { // from class: com.ubt.jimu.controller.data.widget.a
|
||||
@Override // java.util.Comparator
|
||||
public final int compare(Object obj, Object obj2) {
|
||||
return MoveWidgetData.a((WidgetConfig) obj, (WidgetConfig) obj2);
|
||||
}
|
||||
});
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public List<HSliderConfig> getHSliderConfigList() {
|
||||
return this.hSliderConfigList;
|
||||
}
|
||||
|
||||
public List<JockstickConfig> getJockstickConfigList() {
|
||||
return this.jockstickConfigList;
|
||||
}
|
||||
|
||||
public List<SliderConfig> getSliderConfigList() {
|
||||
return this.sliderConfigList;
|
||||
}
|
||||
|
||||
public boolean merge(ControllerData controllerData) {
|
||||
boolean z = false;
|
||||
if (controllerData != null) {
|
||||
List<SliderWidgetData> sliderData = controllerData.getSliderData();
|
||||
if (sliderData != null && sliderData.size() > 0) {
|
||||
for (SliderWidgetData sliderWidgetData : sliderData) {
|
||||
SliderConfig config = sliderWidgetData.getConfig();
|
||||
if (addSliderConfig(config)) {
|
||||
z = true;
|
||||
} else {
|
||||
sliderWidgetData.setConfig(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<HSliderWidgetData> hsliderData = controllerData.getHsliderData();
|
||||
if (hsliderData != null && hsliderData.size() > 0) {
|
||||
for (HSliderWidgetData hSliderWidgetData : hsliderData) {
|
||||
HSliderConfig config2 = hSliderWidgetData.getConfig();
|
||||
if (addHSliderConfig(config2)) {
|
||||
z = true;
|
||||
} else {
|
||||
hSliderWidgetData.setConfig(config2);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<JockstickData> jockstickData = controllerData.getJockstickData();
|
||||
if (jockstickData != null && jockstickData.size() > 0) {
|
||||
for (JockstickData jockstickData2 : jockstickData) {
|
||||
JockstickConfig config3 = jockstickData2.getConfig();
|
||||
if (addJockstickConfig(config3)) {
|
||||
z = true;
|
||||
} else {
|
||||
jockstickData2.setConfig(config3);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<AccumulatorData> accumulatorData = controllerData.getAccumulatorData();
|
||||
if (accumulatorData != null && accumulatorData.size() > 0) {
|
||||
for (AccumulatorData accumulatorData2 : accumulatorData) {
|
||||
AccumulatorConfig config4 = accumulatorData2.getConfig();
|
||||
if (addAccumulatorConfig(config4)) {
|
||||
z = true;
|
||||
} else {
|
||||
accumulatorData2.setConfig(config4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
public boolean removeAccumulatorConfig(AccumulatorConfig accumulatorConfig) {
|
||||
List<AccumulatorConfig> list;
|
||||
if (accumulatorConfig == null || (list = this.accumulatorConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.accumulatorConfigList.remove(accumulatorConfig);
|
||||
}
|
||||
|
||||
public boolean removeHSliderconfig(HSliderConfig hSliderConfig) {
|
||||
List<HSliderConfig> list;
|
||||
if (hSliderConfig == null || (list = this.hSliderConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.hSliderConfigList.remove(hSliderConfig);
|
||||
}
|
||||
|
||||
public boolean removeJockstickConfig(JockstickConfig jockstickConfig) {
|
||||
List<JockstickConfig> list;
|
||||
if (jockstickConfig == null || (list = this.jockstickConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.jockstickConfigList.remove(jockstickConfig);
|
||||
}
|
||||
|
||||
public boolean removeSliderconfig(SliderConfig sliderConfig) {
|
||||
List<SliderConfig> list;
|
||||
if (sliderConfig == null || (list = this.sliderConfigList) == null || list.size() <= 0) {
|
||||
return true;
|
||||
}
|
||||
return this.sliderConfigList.remove(sliderConfig);
|
||||
}
|
||||
|
||||
public void setAccumulatorConfigList(List<AccumulatorConfig> list) {
|
||||
this.accumulatorConfigList = list;
|
||||
}
|
||||
|
||||
public void setHSliderConfigList(List<HSliderConfig> list) {
|
||||
this.hSliderConfigList = list;
|
||||
}
|
||||
|
||||
public void setJockstickConfigList(List<JockstickConfig> list) {
|
||||
this.jockstickConfigList = list;
|
||||
}
|
||||
|
||||
public void setSliderConfigList(List<SliderConfig> list) {
|
||||
this.sliderConfigList = list;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "MoveWidgetData{sliderConfigList=" + this.sliderConfigList + ", hSliderConfigList=" + this.hSliderConfigList + ", jockstickConfigList=" + this.jockstickConfigList + ", accumulatorConfigList=" + this.accumulatorConfigList + '}';
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.thoughtworks.xstream.converters.Converter;
|
||||
import com.thoughtworks.xstream.converters.MarshallingContext;
|
||||
import com.thoughtworks.xstream.converters.UnmarshallingContext;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
|
||||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
import com.ubtech.utils.XLog;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SliderDataConverter implements Converter {
|
||||
public static final String CONFIG_ID = "configID";
|
||||
public static final String DIRECTION = "directionDisclock";
|
||||
public static final String MOTION_TYPE = "motionType";
|
||||
public static final String SERVO_ID = "servoID";
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return SliderWidgetData.class.equals(cls);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public void marshal(Object obj, HierarchicalStreamWriter hierarchicalStreamWriter, MarshallingContext marshallingContext) {
|
||||
SliderWidgetData sliderWidgetData = (SliderWidgetData) obj;
|
||||
if (!TextUtils.isEmpty(sliderWidgetData.getWidgetId())) {
|
||||
hierarchicalStreamWriter.addAttribute("widgetId", sliderWidgetData.getWidgetId());
|
||||
}
|
||||
SliderConfig config = sliderWidgetData.getConfig();
|
||||
if (config != null && !TextUtils.isEmpty(config.getConfigID())) {
|
||||
hierarchicalStreamWriter.addAttribute("configID", config.getConfigID());
|
||||
}
|
||||
hierarchicalStreamWriter.startNode("pos_x");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(sliderWidgetData.getPosX()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
hierarchicalStreamWriter.startNode("pos_y");
|
||||
hierarchicalStreamWriter.setValue(String.valueOf(sliderWidgetData.getPosY()));
|
||||
hierarchicalStreamWriter.endNode();
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
@Override // com.thoughtworks.xstream.converters.Converter
|
||||
public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader, UnmarshallingContext unmarshallingContext) {
|
||||
String attribute = hierarchicalStreamReader.getAttribute("widgetId");
|
||||
if (TextUtils.isEmpty(attribute)) {
|
||||
attribute = hierarchicalStreamReader.getAttribute("widgetID");
|
||||
}
|
||||
SliderWidgetData sliderWidgetData = new SliderWidgetData(attribute);
|
||||
SliderConfig sliderConfig = new SliderConfig();
|
||||
String attribute2 = hierarchicalStreamReader.getAttribute("configID");
|
||||
if (!TextUtils.isEmpty(attribute2)) {
|
||||
sliderConfig.setConfigID(attribute2);
|
||||
}
|
||||
while (hierarchicalStreamReader.hasMoreChildren()) {
|
||||
hierarchicalStreamReader.moveDown();
|
||||
String nodeName = hierarchicalStreamReader.getNodeName();
|
||||
char c = 65535;
|
||||
switch (nodeName.hashCode()) {
|
||||
case -1480753953:
|
||||
if (nodeName.equals(DIRECTION)) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case -720898032:
|
||||
if (nodeName.equals("motionType")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854733:
|
||||
if (nodeName.equals("pos_x")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 106854734:
|
||||
if (nodeName.equals("pos_y")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1984158196:
|
||||
if (nodeName.equals("servoID")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == 0) {
|
||||
sliderWidgetData.setPosX(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 1) {
|
||||
sliderWidgetData.setPosY(Float.valueOf(hierarchicalStreamReader.getValue()).floatValue());
|
||||
} else if (c == 2) {
|
||||
sliderConfig.setMotionType((CtrlMotionType) unmarshallingContext.convertAnother(sliderWidgetData, CtrlMotionType.class));
|
||||
} else if (c == 3) {
|
||||
Integer valueOf = Integer.valueOf(hierarchicalStreamReader.getValue());
|
||||
if (valueOf != null && valueOf.intValue() > 0) {
|
||||
sliderConfig.setServoID(valueOf.intValue());
|
||||
}
|
||||
} else if (c != 4) {
|
||||
XLog.b("woo", "Unknown node name : %s", hierarchicalStreamReader.getNodeName());
|
||||
} else {
|
||||
sliderConfig.setDirectionDisclock(Boolean.valueOf(hierarchicalStreamReader.getValue()).booleanValue());
|
||||
}
|
||||
hierarchicalStreamReader.moveUp();
|
||||
}
|
||||
sliderWidgetData.setConfig(sliderConfig);
|
||||
return sliderWidgetData;
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
package com.ubt.jimu.controller.data.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import com.thoughtworks.xstream.annotations.XStreamConverter;
|
||||
import com.thoughtworks.xstream.annotations.XStreamOmitField;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.data.CtrlMotionType;
|
||||
import com.ubt.jimu.controller.data.config.SliderConfig;
|
||||
|
||||
@XStreamConverter(priority = 9999, value = SliderDataConverter.class)
|
||||
/* loaded from: classes.dex */
|
||||
public class SliderWidgetData extends MoveBaseData<SliderConfig> {
|
||||
|
||||
@XStreamOmitField
|
||||
private SliderConfig config;
|
||||
|
||||
public SliderWidgetData() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public String getShowName(Context context) {
|
||||
String string = context.getResources().getString(R.string.servo_mode_servo_index);
|
||||
if (getConfig().getMotionType() == CtrlMotionType.motor) {
|
||||
string = context.getResources().getString(R.string.control_motor_index);
|
||||
}
|
||||
return String.format(string, Integer.valueOf(getConfig().getServoID()));
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String getWidgetInfo(Context context) {
|
||||
if (this.config == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(String.format(context.getResources().getString(R.string.servo_mode_servo_index), Integer.valueOf(this.config.getServoID())));
|
||||
sb.append("(");
|
||||
sb.append(this.config.isDirectionDisclock() ? context.getResources().getString(R.string.engine_rotate_anticlockwise) : context.getResources().getString(R.string.engine_rotate_clockwise));
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.ItemBaseData
|
||||
public String toString() {
|
||||
return super.toString() + " " + getConfig().toString();
|
||||
}
|
||||
|
||||
public SliderWidgetData(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public SliderConfig getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.controller.data.widget.MoveBaseData
|
||||
public void setConfig(SliderConfig sliderConfig) {
|
||||
super.setConfig((SliderWidgetData) sliderConfig);
|
||||
this.config = sliderConfig;
|
||||
}
|
||||
|
||||
public SliderWidgetData(String str, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SliderWidgetData(String str, CtrlMotionType ctrlMotionType, byte b, boolean z, float f, float f2) {
|
||||
super(str, f, f2);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user