Initial commit
This commit is contained in:
6
sources/com/ubt/jimu/blockly/Blockly.java
Normal file
6
sources/com/ubt/jimu/blockly/Blockly.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.ubt.jimu.blockly;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Blockly {
|
||||
public static final String VERSION = "3.10.1";
|
||||
}
|
||||
12
sources/com/ubt/jimu/blockly/BuildConfig.java
Normal file
12
sources/com/ubt/jimu/blockly/BuildConfig.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.ubt.jimu.blockly;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BuildConfig {
|
||||
public static final String APPLICATION_ID = "com.ubt.jimu.blockly";
|
||||
public static final String BUILD_TYPE = "release";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String FLAVOR = "";
|
||||
public static final String SDK_VERSION = "3.10.1";
|
||||
public static final int VERSION_CODE = 100;
|
||||
public static final String VERSION_NAME = "1.0.0";
|
||||
}
|
||||
267
sources/com/ubt/jimu/blockly/JimuRobot.java
Normal file
267
sources/com/ubt/jimu/blockly/JimuRobot.java
Normal file
@@ -0,0 +1,267 @@
|
||||
package com.ubt.jimu.blockly;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.diy.DiyRobotDbHandler;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuRobot {
|
||||
public static final String ACTIONS = "actions=";
|
||||
public static final String BLUE_STATE = "blueState=";
|
||||
public static final String CIRCLE_SERVOS = "circleServos=";
|
||||
public static final String CUSTOM_MODEL_PROJECT = "data/blockly/xml/project/";
|
||||
public static final String CUSTOM_SOUND_PATH = "data/blockly/sounds/custom/";
|
||||
public static final String GYROSCOPE_ID = "gyroscopeId=";
|
||||
public static final String INFRARED_ID = "infraredId=";
|
||||
public static final String IS_FIRST = "isFirst=";
|
||||
public static final String LANGUAGE = "languageCode=";
|
||||
public static final String LIGHTS = "lights=";
|
||||
public static final String MODEL_TYPE = "modelType=";
|
||||
public static final String SAMPLE_MODEL = "0";
|
||||
private static final String SAMPLE_PROJECT_PATH = "data/blockly/Blockly/defaultProjects/";
|
||||
private static final String SAMPLE_SOUND_PATH = "data/blockly/Blockly/project/ionicPopup/soundEffects/source/";
|
||||
public static final String SERVOS = "servos=";
|
||||
public static final String SOUNDS = "list.config";
|
||||
public static final String TOUCH_ID = "touchId=";
|
||||
public static final String USER_DIY_MODEL = "1";
|
||||
private String action;
|
||||
private String blocklyProject;
|
||||
private int blueState;
|
||||
private String circleServos;
|
||||
private String colorId;
|
||||
private String customSounds;
|
||||
private boolean edit;
|
||||
private String gyroscopeId;
|
||||
private String infraredId;
|
||||
private String isLithium;
|
||||
private String lights;
|
||||
private String modelID;
|
||||
private long modelServerId;
|
||||
private String modelType;
|
||||
private String motion;
|
||||
private String motor;
|
||||
private BlocklyProject program;
|
||||
private String sampleProject;
|
||||
private String sampleSounds;
|
||||
private String servo;
|
||||
private String touchId;
|
||||
private String ultrasonicId;
|
||||
private String unicornId;
|
||||
private int userId;
|
||||
private String xmlId;
|
||||
|
||||
public int firstOpen() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public String getBlocklyProject(String str) {
|
||||
String str2;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(ModelType.DEFAULT.getType() - 1);
|
||||
sb.append("");
|
||||
if (sb.toString().equals(this.modelType)) {
|
||||
str2 = DiyRobotDbHandler.getDefaultModelPath() + getModelId() + File.separator + getModelId();
|
||||
} else {
|
||||
str2 = DiyRobotDbHandler.getCustomModelPath() + getModelId() + File.separator + getModelId();
|
||||
}
|
||||
if ("newBlockly".equals(str)) {
|
||||
str2 = str2 + Utils.BLOCKLY_ADD_PATH;
|
||||
}
|
||||
return str2 + File.separator;
|
||||
}
|
||||
|
||||
public int getBlueState() {
|
||||
return this.blueState;
|
||||
}
|
||||
|
||||
public String getCircleServos() {
|
||||
if (!TextUtils.isEmpty(this.circleServos)) {
|
||||
this.circleServos = this.circleServos.replace(",", "|");
|
||||
}
|
||||
return this.circleServos;
|
||||
}
|
||||
|
||||
public String getColorId() {
|
||||
if (!TextUtils.isEmpty(this.colorId)) {
|
||||
this.colorId = this.colorId.replace(",", "|");
|
||||
}
|
||||
return this.colorId;
|
||||
}
|
||||
|
||||
public String getCustomSounds() {
|
||||
if (TextUtils.isEmpty(this.customSounds)) {
|
||||
this.customSounds = DiyRobotDbHandler.getCustomSoundsPath();
|
||||
}
|
||||
return this.customSounds;
|
||||
}
|
||||
|
||||
public String getGyroscopeId() {
|
||||
if (!TextUtils.isEmpty(this.gyroscopeId)) {
|
||||
this.gyroscopeId = this.gyroscopeId.replace(",", "|");
|
||||
}
|
||||
return this.gyroscopeId;
|
||||
}
|
||||
|
||||
public String getInfraredId() {
|
||||
if (!TextUtils.isEmpty(this.infraredId)) {
|
||||
this.infraredId = this.infraredId.replace(",", "|");
|
||||
}
|
||||
return this.infraredId;
|
||||
}
|
||||
|
||||
public String getIsLithium() {
|
||||
return this.isLithium;
|
||||
}
|
||||
|
||||
public String getLights() {
|
||||
if (!TextUtils.isEmpty(this.lights)) {
|
||||
this.lights = this.lights.replace(",", "|");
|
||||
}
|
||||
return this.lights;
|
||||
}
|
||||
|
||||
public String getModelId() {
|
||||
return this.modelID;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return this.modelType;
|
||||
}
|
||||
|
||||
public String getMotion() {
|
||||
return this.motion;
|
||||
}
|
||||
|
||||
public String getMotor() {
|
||||
if (!TextUtils.isEmpty(this.motor)) {
|
||||
this.motor = this.motor.replace(",", "|");
|
||||
}
|
||||
return this.motor;
|
||||
}
|
||||
|
||||
public BlocklyProject getProgram() {
|
||||
return this.program;
|
||||
}
|
||||
|
||||
public String getSamplePath() {
|
||||
this.sampleProject = ExternalOverFroyoUtils.a(JimuApplication.l(), ModelType.DEFAULT) + getModelId() + File.separator + getModelId();
|
||||
this.sampleProject += Utils.BLOCKLY_ADD_PATH;
|
||||
this.sampleProject += File.separator;
|
||||
return this.sampleProject;
|
||||
}
|
||||
|
||||
public String getSampleSounds() {
|
||||
if (TextUtils.isEmpty(this.sampleSounds)) {
|
||||
this.sampleSounds = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + SAMPLE_SOUND_PATH;
|
||||
}
|
||||
return this.sampleSounds;
|
||||
}
|
||||
|
||||
public long getServerModelId() {
|
||||
return this.modelServerId;
|
||||
}
|
||||
|
||||
public String getServerModelType() {
|
||||
return (Integer.parseInt(this.modelType) + 1) + "";
|
||||
}
|
||||
|
||||
public String getServo() {
|
||||
if (!TextUtils.isEmpty(this.servo)) {
|
||||
this.servo = this.servo.replace(",", "|");
|
||||
}
|
||||
return this.servo;
|
||||
}
|
||||
|
||||
public String getTouchId() {
|
||||
if (!TextUtils.isEmpty(this.touchId)) {
|
||||
this.touchId = this.touchId.replace(",", "|");
|
||||
}
|
||||
return this.touchId;
|
||||
}
|
||||
|
||||
public String getUltrasonicId() {
|
||||
if (!TextUtils.isEmpty(this.ultrasonicId)) {
|
||||
this.ultrasonicId = this.ultrasonicId.replace(",", "|");
|
||||
}
|
||||
return this.ultrasonicId;
|
||||
}
|
||||
|
||||
public String getUnicornId() {
|
||||
if (!TextUtils.isEmpty(this.unicornId)) {
|
||||
this.unicornId = this.unicornId.replace(",", "|");
|
||||
}
|
||||
return this.unicornId;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String getXmlId() {
|
||||
return this.xmlId;
|
||||
}
|
||||
|
||||
public boolean isEdit() {
|
||||
return this.edit;
|
||||
}
|
||||
|
||||
public void setBlueState(int i) {
|
||||
this.blueState = i;
|
||||
}
|
||||
|
||||
public void setCircleServos(String str) {
|
||||
this.circleServos = str;
|
||||
}
|
||||
|
||||
public void setColorId(String str) {
|
||||
this.colorId = str;
|
||||
}
|
||||
|
||||
public void setGyroscopeId(String str) {
|
||||
this.gyroscopeId = str;
|
||||
}
|
||||
|
||||
public void setInfraredId(String str) {
|
||||
this.infraredId = str;
|
||||
}
|
||||
|
||||
public void setIsLithium(String str) {
|
||||
this.isLithium = str;
|
||||
}
|
||||
|
||||
public void setLights(String str) {
|
||||
this.lights = str;
|
||||
}
|
||||
|
||||
public void setMotor(String str) {
|
||||
this.motor = str;
|
||||
}
|
||||
|
||||
public void setServerModelId(long j) {
|
||||
this.modelServerId = j;
|
||||
}
|
||||
|
||||
public void setServo(String str) {
|
||||
this.servo = str;
|
||||
}
|
||||
|
||||
public void setTouchId(String str) {
|
||||
this.touchId = str;
|
||||
}
|
||||
|
||||
public void setUltrasonicId(String str) {
|
||||
this.ultrasonicId = str;
|
||||
}
|
||||
|
||||
public void setUnicornId(String str) {
|
||||
this.unicornId = str;
|
||||
}
|
||||
}
|
||||
1571
sources/com/ubt/jimu/blockly/R.java
Normal file
1571
sources/com/ubt/jimu/blockly/R.java
Normal file
File diff suppressed because one or more lines are too long
193
sources/com/ubt/jimu/blockly/Utils.java
Normal file
193
sources/com/ubt/jimu/blockly/Utils.java
Normal file
@@ -0,0 +1,193 @@
|
||||
package com.ubt.jimu.blockly;
|
||||
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.Constants;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import com.ubt.jimu.utils.PackageHelper;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import com.ubtech.utils.StringUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Utils {
|
||||
public static final String BLOCKLY = "Blockly";
|
||||
public static final String BLOCKLY_ADD_PATH = "_new";
|
||||
public static final String Blockly_Root = "blockly";
|
||||
private static final String TAG = "Utils";
|
||||
private static Random sRandom = new Random();
|
||||
public static final String BLOCKLY_NEW = "TeachMaterialBlockly";
|
||||
public static String baseUrl = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "data/blockly/" + BLOCKLY_NEW + File.separator;
|
||||
|
||||
public interface IUnzipBlockly {
|
||||
void unZipFailed();
|
||||
|
||||
void unZipSuccessed();
|
||||
}
|
||||
|
||||
public static long formatFileCreateTime(String str) {
|
||||
if (str == null || !StringUtils.f(str)) {
|
||||
return 0L;
|
||||
}
|
||||
if (str.length() < 18) {
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
try {
|
||||
return new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS").parse(String.format("20%s/%s/%s %s:%s:%s.%s", str.substring(0, 2), str.substring(2, 4), str.substring(4, 6), str.substring(6, 8), str.substring(8, 10), str.substring(10, 12), str.substring(12, 15))).getTime();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getBlocklyHelpUrl() {
|
||||
String str = "https://jimu.ubtrobot.com/jimu/help_new/help_new.html?language=" + JimuApplication.l().g();
|
||||
return "https://video.ubtrobot.com/jimu/help_303/help_new.html?language=" + JimuApplication.l().g();
|
||||
}
|
||||
|
||||
public static String getDefaultName(int[] iArr, int i, String str) {
|
||||
String str2;
|
||||
if (i == 0) {
|
||||
return str + "1";
|
||||
}
|
||||
boolean z = false;
|
||||
for (int i2 = 0; i2 < i - 1; i2++) {
|
||||
int i3 = 0;
|
||||
while (i3 < (i - i2) - 1) {
|
||||
int i4 = i3 + 1;
|
||||
if (iArr[i3] > iArr[i4]) {
|
||||
int i5 = iArr[i3];
|
||||
iArr[i3] = iArr[i4];
|
||||
iArr[i4] = i5;
|
||||
}
|
||||
i3 = i4;
|
||||
}
|
||||
}
|
||||
int i6 = 0;
|
||||
while (true) {
|
||||
if (i6 >= i) {
|
||||
str2 = null;
|
||||
break;
|
||||
}
|
||||
int i7 = iArr[i6];
|
||||
i6++;
|
||||
if (i7 != i6) {
|
||||
str2 = str + i6;
|
||||
z = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
return str2;
|
||||
}
|
||||
return str + (i + 1);
|
||||
}
|
||||
|
||||
public static String getFormatId(long j) {
|
||||
String format = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date(j));
|
||||
String substring = format.substring(format.length() - 15, format.length());
|
||||
String str = substring + sRandom.nextInt(10) + sRandom.nextInt(10) + sRandom.nextInt(10);
|
||||
System.out.println(format);
|
||||
System.out.println(substring);
|
||||
System.out.println(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String getStarCourseDirPath() {
|
||||
String str = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "data" + File.separator + "blockly" + File.separator + "storyCourse";
|
||||
File file = new File(str);
|
||||
if (!file.isDirectory()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void setJSResult(final WebView webView, String str, String... strArr) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("javascript:");
|
||||
sb.append(str);
|
||||
sb.append("(");
|
||||
if (strArr != null && strArr.length > 0) {
|
||||
for (int i = 0; i < strArr.length; i++) {
|
||||
sb.append("'");
|
||||
sb.append(strArr[i]);
|
||||
sb.append("'");
|
||||
if (i < strArr.length - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
final String sb2 = sb.toString();
|
||||
webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.Utils.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
webView.loadUrl(sb2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void unZipBlockly(IUnzipBlockly iUnzipBlockly) {
|
||||
unZipBlockly(BLOCKLY_NEW, iUnzipBlockly);
|
||||
}
|
||||
|
||||
private static void unzip(final String str, final String str2, final IUnzipBlockly iUnzipBlockly) {
|
||||
new Thread() { // from class: com.ubt.jimu.blockly.Utils.1
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
String str3 = str2 + ".zip";
|
||||
String str4 = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "data/blockly/";
|
||||
try {
|
||||
FileHelper.a(new File(str4 + str2 + File.separator));
|
||||
FileHelper.a(JimuApplication.l(), str3, str4, true);
|
||||
Cache.getInstance().getSettings().put(Constants.BLOCKLY_VERSION, str);
|
||||
if (iUnzipBlockly != null) {
|
||||
iUnzipBlockly.unZipSuccessed();
|
||||
}
|
||||
XLog.c(Utils.TAG, "Unzip blockly success!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("ActivityModelHome", "unAssertsZip Error:" + e.getMessage());
|
||||
IUnzipBlockly iUnzipBlockly2 = iUnzipBlockly;
|
||||
if (iUnzipBlockly2 != null) {
|
||||
iUnzipBlockly2.unZipFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
public static void unZipBlockly(String str, IUnzipBlockly iUnzipBlockly) {
|
||||
String str2 = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "data/blockly/" + str + File.separator;
|
||||
File file = new File(str2);
|
||||
try {
|
||||
String string = Cache.getInstance().getSettings().getString(Constants.BLOCKLY_VERSION, BuildConfig.VERSION_NAME);
|
||||
String a = PackageHelper.a();
|
||||
XLog.c(TAG, "blockly oldversion: %s, currentVersion: %s", string, a);
|
||||
if (!string.equals(a)) {
|
||||
unzip(a, str, iUnzipBlockly);
|
||||
} else if (!file.exists() || file.list() == null || file.list().length < 2) {
|
||||
unzip(a, str, iUnzipBlockly);
|
||||
} else {
|
||||
ALog.a("ActivityModelHome").d(str + "已经解压到" + str2);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("ActivityModelHome", e.getMessage());
|
||||
if (iUnzipBlockly != null) {
|
||||
iUnzipBlockly.unZipFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
145
sources/com/ubt/jimu/blockly/bean/BlocklyProgramsReturnBean.java
Normal file
145
sources/com/ubt/jimu/blockly/bean/BlocklyProgramsReturnBean.java
Normal file
@@ -0,0 +1,145 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyProgramsReturnBean {
|
||||
private String info;
|
||||
private List<ModelsBean> models;
|
||||
private boolean status;
|
||||
|
||||
public static class ModelsBean {
|
||||
private String blocklyType;
|
||||
private String blocklyVersion;
|
||||
private String customModelId;
|
||||
private String fileName;
|
||||
private String fileUrl;
|
||||
private int id;
|
||||
private String isDeleted;
|
||||
private long lastUploadTime;
|
||||
private String loaclFilePath;
|
||||
private int modelId;
|
||||
private String modelType;
|
||||
private String xmlId;
|
||||
|
||||
public String getBlocklyType() {
|
||||
return this.blocklyType;
|
||||
}
|
||||
|
||||
public String getBlocklyVersion() {
|
||||
return this.blocklyVersion;
|
||||
}
|
||||
|
||||
public String getCustomModelId() {
|
||||
return this.customModelId;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
public String getFileUrl() {
|
||||
return this.fileUrl;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public String getLoaclFilePath() {
|
||||
return this.loaclFilePath;
|
||||
}
|
||||
|
||||
public int getModelId() {
|
||||
return this.modelId;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return this.modelType;
|
||||
}
|
||||
|
||||
public String getXmlId() {
|
||||
return this.xmlId;
|
||||
}
|
||||
|
||||
public void setBlocklyType(String str) {
|
||||
this.blocklyType = str;
|
||||
}
|
||||
|
||||
public void setBlocklyVersion(String str) {
|
||||
this.blocklyVersion = str;
|
||||
}
|
||||
|
||||
public void setCustomModelId(String str) {
|
||||
this.customModelId = str;
|
||||
}
|
||||
|
||||
public void setFileName(String str) {
|
||||
this.fileName = str;
|
||||
}
|
||||
|
||||
public void setFileUrl(String str) {
|
||||
this.fileUrl = str;
|
||||
}
|
||||
|
||||
public void setId(int i) {
|
||||
this.id = i;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String str) {
|
||||
this.isDeleted = str;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setLoaclFilePath(String str) {
|
||||
this.loaclFilePath = str;
|
||||
}
|
||||
|
||||
public void setModelId(int i) {
|
||||
this.modelId = i;
|
||||
}
|
||||
|
||||
public void setModelType(String str) {
|
||||
this.modelType = str;
|
||||
}
|
||||
|
||||
public void setXmlId(String str) {
|
||||
this.xmlId = str;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return this.info;
|
||||
}
|
||||
|
||||
public List<ModelsBean> getModels() {
|
||||
return this.models;
|
||||
}
|
||||
|
||||
public boolean isStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setInfo(String str) {
|
||||
this.info = str;
|
||||
}
|
||||
|
||||
public void setModels(List<ModelsBean> list) {
|
||||
this.models = list;
|
||||
}
|
||||
|
||||
public void setStatus(boolean z) {
|
||||
this.status = z;
|
||||
}
|
||||
}
|
||||
233
sources/com/ubt/jimu/blockly/bean/BlocklyProject.java
Normal file
233
sources/com/ubt/jimu/blockly/bean/BlocklyProject.java
Normal file
@@ -0,0 +1,233 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyProject extends SuperFilePath {
|
||||
public static final String TYPE_BLOCKLY = "blockly";
|
||||
public static final String TYPE_NEW_BLOCKLY = "newBlockly";
|
||||
private String blocklyType;
|
||||
private String blocklyVersion;
|
||||
private String customModelId;
|
||||
private String defaultName;
|
||||
private Long id;
|
||||
private boolean isDefault;
|
||||
private String isDeleted;
|
||||
private int isFirst;
|
||||
private boolean isModify;
|
||||
private boolean isUploadQiNiu;
|
||||
private boolean isUploadService;
|
||||
private long lastUploadTime;
|
||||
private long modelId;
|
||||
private String modelType;
|
||||
private String userId;
|
||||
private String xmlContent;
|
||||
private String xmlId;
|
||||
private String xmlName;
|
||||
public HashMap<String, String> xmlNameLang;
|
||||
|
||||
public BlocklyProject() {
|
||||
this.isDefault = false;
|
||||
}
|
||||
|
||||
public String getBlocklyType() {
|
||||
return this.blocklyType;
|
||||
}
|
||||
|
||||
public String getBlocklyVersion() {
|
||||
return this.blocklyVersion;
|
||||
}
|
||||
|
||||
public String getCustomModelId() {
|
||||
return this.customModelId;
|
||||
}
|
||||
|
||||
public String getDefaultName() {
|
||||
return this.defaultName;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean getIsDefault() {
|
||||
return this.isDefault;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public int getIsFirst() {
|
||||
return this.isFirst;
|
||||
}
|
||||
|
||||
public boolean getIsModify() {
|
||||
return this.isModify;
|
||||
}
|
||||
|
||||
public boolean getIsUploadQiNiu() {
|
||||
return this.isUploadQiNiu;
|
||||
}
|
||||
|
||||
public boolean getIsUploadService() {
|
||||
return this.isUploadService;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public long getModelId() {
|
||||
return this.modelId;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return this.modelType;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String getXmlContent() {
|
||||
return this.xmlContent;
|
||||
}
|
||||
|
||||
public String getXmlId() {
|
||||
return this.xmlId;
|
||||
}
|
||||
|
||||
public String getXmlName() {
|
||||
return this.xmlName;
|
||||
}
|
||||
|
||||
public boolean isModify() {
|
||||
return this.isModify;
|
||||
}
|
||||
|
||||
public boolean isUploadQiNiu() {
|
||||
return this.isUploadQiNiu;
|
||||
}
|
||||
|
||||
public boolean isUploadService() {
|
||||
return this.isUploadService;
|
||||
}
|
||||
|
||||
public void setBlocklyType(String str) {
|
||||
this.blocklyType = str;
|
||||
}
|
||||
|
||||
public void setBlocklyVersion(String str) {
|
||||
this.blocklyVersion = str;
|
||||
}
|
||||
|
||||
public void setCustomModelId(String str) {
|
||||
this.customModelId = str;
|
||||
}
|
||||
|
||||
public void setId(Long l) {
|
||||
this.id = l;
|
||||
}
|
||||
|
||||
public void setIsDefault(boolean z) {
|
||||
this.isDefault = z;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String str) {
|
||||
this.isDeleted = str;
|
||||
}
|
||||
|
||||
public void setIsFirst(int i) {
|
||||
this.isFirst = i;
|
||||
}
|
||||
|
||||
public void setIsModify(boolean z) {
|
||||
this.isModify = z;
|
||||
}
|
||||
|
||||
public void setIsUploadQiNiu(boolean z) {
|
||||
this.isUploadQiNiu = z;
|
||||
}
|
||||
|
||||
public void setIsUploadService(boolean z) {
|
||||
this.isUploadService = z;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setModelId(long j) {
|
||||
this.modelId = j;
|
||||
}
|
||||
|
||||
public void setModelType(String str) {
|
||||
this.modelType = str;
|
||||
}
|
||||
|
||||
public void setModify(boolean z) {
|
||||
this.isModify = z;
|
||||
}
|
||||
|
||||
public void setUploadQiNiu(boolean z) {
|
||||
this.isUploadQiNiu = z;
|
||||
}
|
||||
|
||||
public void setUploadService(boolean z) {
|
||||
this.isUploadService = z;
|
||||
}
|
||||
|
||||
public void setUserId(String str) {
|
||||
this.userId = str;
|
||||
}
|
||||
|
||||
public void setXmlContent(String str) {
|
||||
this.xmlContent = str;
|
||||
}
|
||||
|
||||
public void setXmlId(String str) {
|
||||
this.xmlId = str;
|
||||
}
|
||||
|
||||
public void setXmlName(String str) {
|
||||
this.xmlName = str;
|
||||
}
|
||||
|
||||
public BlocklyProject(String str, String str2, long j, String str3, String str4, String str5, String str6, String str7, String str8) {
|
||||
this.isDefault = false;
|
||||
this.userId = str;
|
||||
this.blocklyType = str4;
|
||||
this.modelType = str2;
|
||||
this.modelId = j;
|
||||
this.customModelId = str3;
|
||||
this.isModify = false;
|
||||
this.xmlId = str5;
|
||||
this.xmlName = str6;
|
||||
this.lastUploadTime = SystemUtils.a();
|
||||
this.blocklyVersion = str7;
|
||||
this.xmlContent = str8;
|
||||
}
|
||||
|
||||
public BlocklyProject(Long l, String str, String str2, boolean z, boolean z2, boolean z3, String str3, int i, String str4, long j, boolean z4, String str5, String str6, String str7, long j2, String str8, String str9) {
|
||||
this.isDefault = false;
|
||||
this.id = l;
|
||||
this.userId = str;
|
||||
this.xmlId = str2;
|
||||
this.isModify = z;
|
||||
this.isUploadQiNiu = z2;
|
||||
this.isUploadService = z3;
|
||||
this.xmlName = str3;
|
||||
this.isFirst = i;
|
||||
this.xmlContent = str4;
|
||||
this.lastUploadTime = j;
|
||||
this.isDefault = z4;
|
||||
this.blocklyVersion = str5;
|
||||
this.blocklyType = str6;
|
||||
this.modelType = str7;
|
||||
this.modelId = j2;
|
||||
this.customModelId = str8;
|
||||
this.isDeleted = str9;
|
||||
}
|
||||
}
|
||||
104
sources/com/ubt/jimu/blockly/bean/BlocklyProjectParameter.java
Normal file
104
sources/com/ubt/jimu/blockly/bean/BlocklyProjectParameter.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyProjectParameter {
|
||||
private String blocklyType;
|
||||
private String blocklyVersion;
|
||||
private String customModelId;
|
||||
private String fileName;
|
||||
private String fileUrl;
|
||||
private int id;
|
||||
private String isDeleted;
|
||||
private long lastUploadTime;
|
||||
private String modelId;
|
||||
private String modelType;
|
||||
private String xmlId;
|
||||
|
||||
public String getBlocklyType() {
|
||||
return this.blocklyType;
|
||||
}
|
||||
|
||||
public String getBlocklyVersion() {
|
||||
return this.blocklyVersion;
|
||||
}
|
||||
|
||||
public String getCustomModelId() {
|
||||
return this.customModelId;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
public String getFileUrl() {
|
||||
return this.fileUrl;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public String getModelId() {
|
||||
return this.modelId;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return this.modelType;
|
||||
}
|
||||
|
||||
public String getXmlId() {
|
||||
return this.xmlId;
|
||||
}
|
||||
|
||||
public void setBlocklyType(String str) {
|
||||
this.blocklyType = str;
|
||||
}
|
||||
|
||||
public void setBlocklyVersion(String str) {
|
||||
this.blocklyVersion = str;
|
||||
}
|
||||
|
||||
public void setCustomModelId(String str) {
|
||||
this.customModelId = str;
|
||||
}
|
||||
|
||||
public void setFileName(String str) {
|
||||
this.fileName = str;
|
||||
}
|
||||
|
||||
public void setFileUrl(String str) {
|
||||
this.fileUrl = str;
|
||||
}
|
||||
|
||||
public void setId(int i) {
|
||||
this.id = i;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String str) {
|
||||
this.isDeleted = str;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setModelId(String str) {
|
||||
this.modelId = str;
|
||||
}
|
||||
|
||||
public void setModelType(String str) {
|
||||
this.modelType = str;
|
||||
}
|
||||
|
||||
public void setXmlId(String str) {
|
||||
this.xmlId = str;
|
||||
}
|
||||
}
|
||||
158
sources/com/ubt/jimu/blockly/bean/JimuMotion.java
Normal file
158
sources/com/ubt/jimu/blockly/bean/JimuMotion.java
Normal file
@@ -0,0 +1,158 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import java.util.ArrayList;
|
||||
import org.greenrobot.greendao.converter.PropertyConverter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuMotion {
|
||||
public ArrayList<JimuServo> actionData;
|
||||
private String actionID;
|
||||
private String actionName;
|
||||
private String customModelId;
|
||||
private String defaultName;
|
||||
private String isDeleted;
|
||||
private int isFirst;
|
||||
private boolean isUploadService;
|
||||
private long lastUploadTime;
|
||||
private Long localId;
|
||||
private int modelId;
|
||||
private String modelType;
|
||||
private String userId;
|
||||
|
||||
public static class JimuServo {
|
||||
public int degree;
|
||||
public int ms;
|
||||
public int servo;
|
||||
}
|
||||
|
||||
public static class JimuServoConverter implements PropertyConverter<ArrayList<JimuServo>, String> {
|
||||
public String convertToDatabaseValue(ArrayList<JimuServo> arrayList) {
|
||||
return JsonHelper.a(arrayList);
|
||||
}
|
||||
|
||||
public ArrayList<JimuServo> convertToEntityProperty(String str) {
|
||||
return (ArrayList) JsonHelper.a(str, new TypeToken<ArrayList<JimuServo>>() { // from class: com.ubt.jimu.blockly.bean.JimuMotion.JimuServoConverter.1
|
||||
}.getType());
|
||||
}
|
||||
}
|
||||
|
||||
public JimuMotion(Long l, String str, String str2, String str3, int i, boolean z, long j, int i2, String str4, String str5, String str6, ArrayList<JimuServo> arrayList) {
|
||||
this.localId = l;
|
||||
this.modelType = str;
|
||||
this.customModelId = str2;
|
||||
this.isDeleted = str3;
|
||||
this.modelId = i;
|
||||
this.isUploadService = z;
|
||||
this.lastUploadTime = j;
|
||||
this.isFirst = i2;
|
||||
this.actionName = str4;
|
||||
this.actionID = str5;
|
||||
this.userId = str6;
|
||||
this.actionData = arrayList;
|
||||
}
|
||||
|
||||
public ArrayList<JimuServo> getActionData() {
|
||||
return this.actionData;
|
||||
}
|
||||
|
||||
public String getActionID() {
|
||||
return this.actionID;
|
||||
}
|
||||
|
||||
public String getActionName() {
|
||||
return this.actionName;
|
||||
}
|
||||
|
||||
public String getCustomModelId() {
|
||||
return this.customModelId;
|
||||
}
|
||||
|
||||
public String getDefaultName() {
|
||||
return this.defaultName;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public int getIsFirst() {
|
||||
return this.isFirst;
|
||||
}
|
||||
|
||||
public boolean getIsUploadService() {
|
||||
return this.isUploadService;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public Long getLocalId() {
|
||||
return this.localId;
|
||||
}
|
||||
|
||||
public int getModelId() {
|
||||
return this.modelId;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return this.modelType;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setActionData(ArrayList<JimuServo> arrayList) {
|
||||
this.actionData = arrayList;
|
||||
}
|
||||
|
||||
public void setActionID(String str) {
|
||||
this.actionID = str;
|
||||
}
|
||||
|
||||
public void setActionName(String str) {
|
||||
this.actionName = str;
|
||||
}
|
||||
|
||||
public void setCustomModelId(String str) {
|
||||
this.customModelId = str;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String str) {
|
||||
this.isDeleted = str;
|
||||
}
|
||||
|
||||
public void setIsFirst(int i) {
|
||||
this.isFirst = i;
|
||||
}
|
||||
|
||||
public void setIsUploadService(boolean z) {
|
||||
this.isUploadService = z;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setLocalId(Long l) {
|
||||
this.localId = l;
|
||||
}
|
||||
|
||||
public void setModelId(int i) {
|
||||
this.modelId = i;
|
||||
}
|
||||
|
||||
public void setModelType(String str) {
|
||||
this.modelType = str;
|
||||
}
|
||||
|
||||
public void setUserId(String str) {
|
||||
this.userId = str;
|
||||
}
|
||||
|
||||
public JimuMotion() {
|
||||
}
|
||||
}
|
||||
86
sources/com/ubt/jimu/blockly/bean/JimuMotionParameter.java
Normal file
86
sources/com/ubt/jimu/blockly/bean/JimuMotionParameter.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuMotionParameter {
|
||||
private String customModelId;
|
||||
private int id;
|
||||
private String isDeleted;
|
||||
private long lastUploadTime;
|
||||
private String modelId;
|
||||
private String modelType;
|
||||
private String postureCmd;
|
||||
private String postureId;
|
||||
private String postureName;
|
||||
|
||||
public String getCustomModelId() {
|
||||
return this.customModelId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public String getModelId() {
|
||||
return this.modelId;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return this.modelType;
|
||||
}
|
||||
|
||||
public String getPostureCmd() {
|
||||
return this.postureCmd;
|
||||
}
|
||||
|
||||
public String getPostureId() {
|
||||
return this.postureId;
|
||||
}
|
||||
|
||||
public String getPostureName() {
|
||||
return this.postureName;
|
||||
}
|
||||
|
||||
public void setCustomModelId(String str) {
|
||||
this.customModelId = str;
|
||||
}
|
||||
|
||||
public void setId(int i) {
|
||||
this.id = i;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String str) {
|
||||
this.isDeleted = str;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setModelId(String str) {
|
||||
this.modelId = str;
|
||||
}
|
||||
|
||||
public void setModelType(String str) {
|
||||
this.modelType = str;
|
||||
}
|
||||
|
||||
public void setPostureCmd(String str) {
|
||||
this.postureCmd = str;
|
||||
}
|
||||
|
||||
public void setPostureId(String str) {
|
||||
this.postureId = str;
|
||||
}
|
||||
|
||||
public void setPostureName(String str) {
|
||||
this.postureName = str;
|
||||
}
|
||||
}
|
||||
118
sources/com/ubt/jimu/blockly/bean/JimuMotionReturnBean.java
Normal file
118
sources/com/ubt/jimu/blockly/bean/JimuMotionReturnBean.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuMotionReturnBean {
|
||||
private String info;
|
||||
private List<ModelsBean> models;
|
||||
private boolean status;
|
||||
|
||||
public static class ModelsBean {
|
||||
private String customModelId;
|
||||
private int id;
|
||||
private String isDeleted;
|
||||
private long lastUploadTime;
|
||||
private int modelId;
|
||||
private String modelType;
|
||||
private String postureCmd;
|
||||
private String postureId;
|
||||
private String postureName;
|
||||
|
||||
public String getCustomModelId() {
|
||||
return this.customModelId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public int getModelId() {
|
||||
return this.modelId;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return this.modelType;
|
||||
}
|
||||
|
||||
public String getPostureCmd() {
|
||||
return this.postureCmd;
|
||||
}
|
||||
|
||||
public String getPostureId() {
|
||||
return this.postureId;
|
||||
}
|
||||
|
||||
public String getPostureName() {
|
||||
return this.postureName;
|
||||
}
|
||||
|
||||
public void setCustomModelId(String str) {
|
||||
this.customModelId = str;
|
||||
}
|
||||
|
||||
public void setId(int i) {
|
||||
this.id = i;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String str) {
|
||||
this.isDeleted = str;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setModelId(int i) {
|
||||
this.modelId = i;
|
||||
}
|
||||
|
||||
public void setModelType(String str) {
|
||||
this.modelType = str;
|
||||
}
|
||||
|
||||
public void setPostureCmd(String str) {
|
||||
this.postureCmd = str;
|
||||
}
|
||||
|
||||
public void setPostureId(String str) {
|
||||
this.postureId = str;
|
||||
}
|
||||
|
||||
public void setPostureName(String str) {
|
||||
this.postureName = str;
|
||||
}
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return this.info;
|
||||
}
|
||||
|
||||
public List<ModelsBean> getModels() {
|
||||
return this.models;
|
||||
}
|
||||
|
||||
public boolean isStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setInfo(String str) {
|
||||
this.info = str;
|
||||
}
|
||||
|
||||
public void setModels(List<ModelsBean> list) {
|
||||
this.models = list;
|
||||
}
|
||||
|
||||
public void setStatus(boolean z) {
|
||||
this.status = z;
|
||||
}
|
||||
}
|
||||
226
sources/com/ubt/jimu/blockly/bean/JimuSound.java
Normal file
226
sources/com/ubt/jimu/blockly/bean/JimuSound.java
Normal file
@@ -0,0 +1,226 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import java.util.Objects;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuSound extends SuperFilePath {
|
||||
public static final String TYPE_ANIMAL = "animal";
|
||||
public static final String TYPE_MACHINE = "machine";
|
||||
public static final String TYPE_RECORDING = "recording";
|
||||
public static final String TYPE_TUNE = "tune";
|
||||
private String audioId;
|
||||
private String beatTime;
|
||||
private String branchId;
|
||||
private String defaultName;
|
||||
private String description;
|
||||
private String duration;
|
||||
private String icon;
|
||||
private Long id;
|
||||
private boolean isDelay;
|
||||
private String isDeleted;
|
||||
private int isFirst;
|
||||
private boolean isSyncUbtService;
|
||||
private boolean isUploadQiNiu;
|
||||
private String key;
|
||||
private long lastUploadTime;
|
||||
private String playPath;
|
||||
private String type;
|
||||
private String userId;
|
||||
|
||||
public JimuSound(String str, String str2, String str3, String str4) {
|
||||
this.type = str;
|
||||
this.key = str2;
|
||||
this.icon = str4;
|
||||
this.description = str3;
|
||||
this.audioId = str2;
|
||||
this.lastUploadTime = SystemUtils.a();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof JimuSound)) {
|
||||
return false;
|
||||
}
|
||||
JimuSound jimuSound = (JimuSound) obj;
|
||||
return this.type.equals(jimuSound.type) && this.key.equals(jimuSound.key);
|
||||
}
|
||||
|
||||
public String getAudioId() {
|
||||
return this.audioId;
|
||||
}
|
||||
|
||||
public String getBeatTime() {
|
||||
return this.beatTime;
|
||||
}
|
||||
|
||||
public String getBranchId() {
|
||||
return this.branchId;
|
||||
}
|
||||
|
||||
public String getDefaultName() {
|
||||
return this.defaultName;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public String getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean getIsDelay() {
|
||||
return this.isDelay;
|
||||
}
|
||||
|
||||
public String getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public int getIsFirst() {
|
||||
return this.isFirst;
|
||||
}
|
||||
|
||||
public boolean getIsSyncUbtService() {
|
||||
return this.isSyncUbtService;
|
||||
}
|
||||
|
||||
public boolean getIsUploadQiNiu() {
|
||||
return this.isUploadQiNiu;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public String getPlayPath() {
|
||||
return this.playPath;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.key, this.type);
|
||||
}
|
||||
|
||||
public boolean isSyncUbtService() {
|
||||
return this.isSyncUbtService;
|
||||
}
|
||||
|
||||
public boolean isUploadQiNiu() {
|
||||
return this.isUploadQiNiu;
|
||||
}
|
||||
|
||||
public void setAudioId(String str) {
|
||||
this.audioId = str;
|
||||
}
|
||||
|
||||
public void setBeatTime(String str) {
|
||||
this.beatTime = str;
|
||||
}
|
||||
|
||||
public void setBranchId(String str) {
|
||||
this.branchId = str;
|
||||
}
|
||||
|
||||
public void setDescription(String str) {
|
||||
this.description = str;
|
||||
}
|
||||
|
||||
public void setDuration(String str) {
|
||||
this.duration = str;
|
||||
}
|
||||
|
||||
public void setIcon(String str) {
|
||||
this.icon = str;
|
||||
}
|
||||
|
||||
public void setId(Long l) {
|
||||
this.id = l;
|
||||
}
|
||||
|
||||
public void setIsDelay(boolean z) {
|
||||
this.isDelay = z;
|
||||
}
|
||||
|
||||
public void setIsDeleted(String str) {
|
||||
this.isDeleted = str;
|
||||
}
|
||||
|
||||
public void setIsFirst(int i) {
|
||||
this.isFirst = i;
|
||||
}
|
||||
|
||||
public void setIsSyncUbtService(boolean z) {
|
||||
this.isSyncUbtService = z;
|
||||
}
|
||||
|
||||
public void setIsUploadQiNiu(boolean z) {
|
||||
this.isUploadQiNiu = z;
|
||||
}
|
||||
|
||||
public void setKey(String str) {
|
||||
this.key = str;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setPlayPath(String str) {
|
||||
this.playPath = str;
|
||||
}
|
||||
|
||||
public void setSyncUbtService(boolean z) {
|
||||
this.isSyncUbtService = z;
|
||||
}
|
||||
|
||||
public void setType(String str) {
|
||||
this.type = str;
|
||||
}
|
||||
|
||||
public void setUploadQiNiu(boolean z) {
|
||||
this.isUploadQiNiu = z;
|
||||
}
|
||||
|
||||
public void setUserId(String str) {
|
||||
this.userId = str;
|
||||
}
|
||||
|
||||
public JimuSound(Long l, String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, boolean z, boolean z2, long j, int i) {
|
||||
this.id = l;
|
||||
this.userId = str;
|
||||
this.key = str2;
|
||||
this.icon = str3;
|
||||
this.audioId = str4;
|
||||
this.type = str5;
|
||||
this.duration = str6;
|
||||
this.description = str7;
|
||||
this.isDeleted = str8;
|
||||
this.isUploadQiNiu = z;
|
||||
this.isSyncUbtService = z2;
|
||||
this.lastUploadTime = j;
|
||||
this.isFirst = i;
|
||||
}
|
||||
|
||||
public JimuSound() {
|
||||
}
|
||||
}
|
||||
86
sources/com/ubt/jimu/blockly/bean/JimuSoundParameter.java
Normal file
86
sources/com/ubt/jimu/blockly/bean/JimuSoundParameter.java
Normal file
@@ -0,0 +1,86 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuSoundParameter {
|
||||
private String audioId;
|
||||
private String description;
|
||||
private String duration;
|
||||
private String fileUrl;
|
||||
private int id;
|
||||
private int isDeleted;
|
||||
private long lastUploadTime;
|
||||
private String type;
|
||||
private String userId;
|
||||
|
||||
public String getAudioId() {
|
||||
return this.audioId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public String getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public String getFileUrl() {
|
||||
return this.fileUrl;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getIsDeleted() {
|
||||
return this.isDeleted;
|
||||
}
|
||||
|
||||
public long getLastUploadTime() {
|
||||
return this.lastUploadTime;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setAudioId(String str) {
|
||||
this.audioId = str;
|
||||
}
|
||||
|
||||
public void setDescription(String str) {
|
||||
this.description = str;
|
||||
}
|
||||
|
||||
public void setDuration(String str) {
|
||||
this.duration = str;
|
||||
}
|
||||
|
||||
public void setFileUrl(String str) {
|
||||
this.fileUrl = str;
|
||||
}
|
||||
|
||||
public void setId(int i) {
|
||||
this.id = i;
|
||||
}
|
||||
|
||||
public void setIsDeleted(int i) {
|
||||
this.isDeleted = i;
|
||||
}
|
||||
|
||||
public void setLastUploadTime(long j) {
|
||||
this.lastUploadTime = j;
|
||||
}
|
||||
|
||||
public void setType(String str) {
|
||||
this.type = str;
|
||||
}
|
||||
|
||||
public void setUserId(String str) {
|
||||
this.userId = str;
|
||||
}
|
||||
}
|
||||
23
sources/com/ubt/jimu/blockly/bean/SuperFilePath.java
Normal file
23
sources/com/ubt/jimu/blockly/bean/SuperFilePath.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.ubt.jimu.blockly.bean;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SuperFilePath {
|
||||
public String fileUrl;
|
||||
public String localFilePath;
|
||||
|
||||
public String getFileUrl() {
|
||||
return this.fileUrl;
|
||||
}
|
||||
|
||||
public String getLocalFilePath() {
|
||||
return this.localFilePath;
|
||||
}
|
||||
|
||||
public void setFileUrl(String str) {
|
||||
this.fileUrl = str;
|
||||
}
|
||||
|
||||
public void setLocalFilePath(String str) {
|
||||
this.localFilePath = str;
|
||||
}
|
||||
}
|
||||
63
sources/com/ubt/jimu/blockly/command/BlocklyCommand.java
Normal file
63
sources/com/ubt/jimu/blockly/command/BlocklyCommand.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyCommand<T> {
|
||||
private T arg;
|
||||
private String callback;
|
||||
private BlocklyCommand<T>.CommandArg extraArg;
|
||||
private String name;
|
||||
private String url;
|
||||
|
||||
public class CommandArg {
|
||||
private String branchId;
|
||||
|
||||
public CommandArg() {
|
||||
}
|
||||
|
||||
public String getBranchId() {
|
||||
return this.branchId;
|
||||
}
|
||||
}
|
||||
|
||||
public BlocklyCommand(String str, Class<T> cls) {
|
||||
parseCommand(str, cls);
|
||||
}
|
||||
|
||||
private void parseCommand(String str, Class<T> cls) {
|
||||
if (str.startsWith(BlocklyCommandController.BASE_REQUEST_URL)) {
|
||||
String[] split = str.split("\\|");
|
||||
this.name = split[0];
|
||||
if (split.length > 1 && split[1].contains("\":") && cls != null) {
|
||||
this.arg = (T) JsonHelper.a(split[1], (Class<?>) cls);
|
||||
}
|
||||
if (split.length > 2) {
|
||||
this.callback = split[2];
|
||||
}
|
||||
if (split.length > 3) {
|
||||
this.extraArg = (CommandArg) JsonHelper.a(split[3], (Class<?>) CommandArg.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T getArg() {
|
||||
return this.arg;
|
||||
}
|
||||
|
||||
public String getCallback() {
|
||||
return this.callback;
|
||||
}
|
||||
|
||||
public BlocklyCommand<T>.CommandArg getExtraArg() {
|
||||
return this.extraArg;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.webkit.WebView;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyCommandController {
|
||||
public static final String ACTION = "action";
|
||||
public static final String ADJUST_SERVO = "adjustServo";
|
||||
public static final String BASE_REQUEST_URL = "jimu://";
|
||||
public static final String GET_POSTURE = "getPosture";
|
||||
public static final String QUERY = "query";
|
||||
public static final String QUERY_ALL_SENSOR = "queryAllSensor";
|
||||
public static final String QUERY_GYROSCOPE = "queryGyroscope";
|
||||
public static final String QUERY_INFRARED = "queryInfrared";
|
||||
public static final String QUERY_TOUCH_STATUS = "queryTouchStatus";
|
||||
public static final String SERVO_POWER_OFF = "servoPowerOff";
|
||||
public static final String SERVO_POWER_ON = "servoPowerOn";
|
||||
public static final String SERVO_SET = "servoSet";
|
||||
public static final String SERVO_SETBY_SPEED = "servoSetbySpeed";
|
||||
public static final String SET_DIGITAL_TUBE = "setDigitalTube";
|
||||
public static final String SET_EMOJI = "setEmoji";
|
||||
public static final String SET_LEDS = "setLEDs";
|
||||
public static final String SET_SERSOR_LED = "setSensorLED";
|
||||
public static final String SET_SERVO_MODE = "setServoMode";
|
||||
public static final String STOP_ROBOT = "stopRobot";
|
||||
public static final String STOP_SERVO = "stopServo";
|
||||
private JimuBlocklyCommand jsInterface;
|
||||
private final String tag = BlocklyCommandController.class.getSimpleName();
|
||||
public final String CONFIRM = "confirm";
|
||||
public final String SAVE_XML = "SaveXml";
|
||||
public final String READ_XML = "ReadXml";
|
||||
public final String DELETE_XML = "DeleteXml";
|
||||
public final String XML_LIST = "XmlList";
|
||||
public final String CONNECT_BLE = JimuBlocklyCommand.CONNECT_BLE;
|
||||
public final String DISCONNECT_BLE = "DisconnectBLE";
|
||||
public final String CLOSE_WINDOW = "CloseWindow";
|
||||
public final String BLE_STATE = JimuBlocklyCommand.BLE_STATE;
|
||||
public final String OPEN_HEART_BEAT = "openHeartbeat";
|
||||
public final String CLOSE_HEART_BEAT = "closeHeartbeat";
|
||||
public final String START_SENSOR_TIMER = "startInfraredTimer";
|
||||
public final String STOP_SENSOR_TIMER = "stopInfraredTimer";
|
||||
|
||||
public BlocklyCommandController(JimuBlocklyCommand jimuBlocklyCommand) {
|
||||
this.jsInterface = jimuBlocklyCommand;
|
||||
}
|
||||
|
||||
private void bleStateCommand(String str) {
|
||||
this.jsInterface.bleState();
|
||||
}
|
||||
|
||||
private void closeWindowCommand() {
|
||||
this.jsInterface.closeWindow();
|
||||
}
|
||||
|
||||
private void confirmCommand(String str) {
|
||||
this.jsInterface.confirm(str);
|
||||
}
|
||||
|
||||
private void connectedBLECommand() {
|
||||
this.jsInterface.connectedBLE();
|
||||
}
|
||||
|
||||
private void deleteXmlCommand(String str) {
|
||||
BlocklyCommand blocklyCommand = new BlocklyCommand(str, BlocklyProject.class);
|
||||
this.jsInterface.deleteXml(((BlocklyProject) blocklyCommand.getArg()).getXmlId(), blocklyCommand.getCallback());
|
||||
}
|
||||
|
||||
private void disconnectBleCommand(String str) {
|
||||
this.jsInterface.notifyBLEState("{\"blueState\":3}");
|
||||
this.jsInterface.unityComm(str);
|
||||
}
|
||||
|
||||
private void distribute(String str, String str2) {
|
||||
if (str2.contains("confirm")) {
|
||||
confirmCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains(JimuBlocklyCommand.CONNECT_BLE)) {
|
||||
connectedBLECommand();
|
||||
return;
|
||||
}
|
||||
if (str2.contains("CloseWindow")) {
|
||||
closeWindowCommand();
|
||||
return;
|
||||
}
|
||||
if (str2.contains("ReadXml")) {
|
||||
readXmlCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains("SaveXml")) {
|
||||
saveXmlCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains("DeleteXml")) {
|
||||
deleteXmlCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains("XmlList")) {
|
||||
xmlListCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains(JimuBlocklyCommand.BLE_STATE)) {
|
||||
bleStateCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains("openHeartbeat")) {
|
||||
heartBeatCommand("1");
|
||||
return;
|
||||
}
|
||||
if (str2.contains("closeHeartbeat")) {
|
||||
heartBeatCommand("0");
|
||||
return;
|
||||
}
|
||||
if (str2.contains("startInfraredTimer")) {
|
||||
startInfraredTimerCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains("stopInfraredTimer")) {
|
||||
stopInfraredTimerCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains(QUERY_INFRARED)) {
|
||||
queryInfraredCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains("DisconnectBLE")) {
|
||||
disconnectBleCommand(str);
|
||||
return;
|
||||
}
|
||||
if (str2.contains("setServoMode")) {
|
||||
setServoMode();
|
||||
} else if (str2.contains(SERVO_SET)) {
|
||||
servoSet(str, str2);
|
||||
} else {
|
||||
unityCommand(str);
|
||||
}
|
||||
}
|
||||
|
||||
private void heartBeatCommand(String str) {
|
||||
this.jsInterface.heartBeat(str);
|
||||
}
|
||||
|
||||
private void queryInfraredCommand(String str) {
|
||||
this.jsInterface.queryInfrared(str, new BlocklyCommand(str, null).getCallback());
|
||||
}
|
||||
|
||||
private void readXmlCommand(String str) {
|
||||
BlocklyCommand blocklyCommand = new BlocklyCommand(str, BlocklyProject.class);
|
||||
BlocklyProject blocklyProject = (BlocklyProject) blocklyCommand.getArg();
|
||||
if (blocklyProject != null) {
|
||||
this.jsInterface.readXml(blocklyProject.getXmlId(), blocklyCommand.getCallback());
|
||||
}
|
||||
}
|
||||
|
||||
private void saveXmlCommand(String str) {
|
||||
BlocklyCommand blocklyCommand = new BlocklyCommand(str, BlocklyProject.class);
|
||||
this.jsInterface.saveXml(((BlocklyProject) blocklyCommand.getArg()).getXmlName(), ((BlocklyProject) blocklyCommand.getArg()).getXmlContent(), ((BlocklyProject) blocklyCommand.getArg()).getXmlId(), ((BlocklyProject) blocklyCommand.getArg()).getBlocklyVersion(), blocklyCommand.getCallback());
|
||||
}
|
||||
|
||||
private void servoSet(String str, String str2) {
|
||||
String[] split = str.split("\\|");
|
||||
if (TextUtils.isEmpty(split[1])) {
|
||||
this.jsInterface.servoSet(split[2]);
|
||||
} else {
|
||||
unityCommand(str);
|
||||
}
|
||||
}
|
||||
|
||||
private void setServoMode() {
|
||||
this.jsInterface.setServoMode();
|
||||
}
|
||||
|
||||
private void startInfraredTimerCommand(String str) {
|
||||
this.jsInterface.startSensorTimer(str, new BlocklyCommand(str, BlocklyProject.class).getCallback());
|
||||
}
|
||||
|
||||
private void stopInfraredTimerCommand(String str) {
|
||||
this.jsInterface.stopSensorTimer(str);
|
||||
}
|
||||
|
||||
private void unityCommand(String str) {
|
||||
this.jsInterface.unityComm(str);
|
||||
}
|
||||
|
||||
private void xmlListCommand(String str) {
|
||||
this.jsInterface.xmlList(new BlocklyCommand(str, BlocklyProject.class).getCallback());
|
||||
}
|
||||
|
||||
public JimuBlocklyCommand getJsInterface() {
|
||||
return this.jsInterface;
|
||||
}
|
||||
|
||||
public boolean onBlocklyCommand(WebView webView, String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
String decode = URLDecoder.decode(str, "UTF-8");
|
||||
if (!decode.startsWith(BASE_REQUEST_URL)) {
|
||||
return false;
|
||||
}
|
||||
distribute(decode, decode.split("\\|")[0]);
|
||||
return true;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
sources/com/ubt/jimu/blockly/command/IBlocklyCommand.java
Normal file
43
sources/com/ubt/jimu/blockly/command/IBlocklyCommand.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public interface IBlocklyCommand {
|
||||
void bleState();
|
||||
|
||||
void closeWindow();
|
||||
|
||||
void confirm();
|
||||
|
||||
void connectedBLE();
|
||||
|
||||
void deleteXml(String str, String str2);
|
||||
|
||||
JimuRobot getJimuRobot();
|
||||
|
||||
void heartBeat(String str);
|
||||
|
||||
void notifyBLEState(String str);
|
||||
|
||||
void queryInfrared(String str, String str2);
|
||||
|
||||
void readXml(String str, String str2);
|
||||
|
||||
void saveXml(String str, String str2, String str3, String str4, String str5);
|
||||
|
||||
void servoSet(String str);
|
||||
|
||||
void setJimuRobot(JimuRobot jimuRobot);
|
||||
|
||||
void setServoMode();
|
||||
|
||||
void startSensorTimer(String str, String str2);
|
||||
|
||||
void stopSensorTimer(String str);
|
||||
|
||||
void unityComm(String str);
|
||||
|
||||
void xmlList(String str);
|
||||
}
|
||||
21
sources/com/ubt/jimu/blockly/command/IUnityCommand.java
Normal file
21
sources/com/ubt/jimu/blockly/command/IUnityCommand.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes.dex */
|
||||
public interface IUnityCommand {
|
||||
void blueConnectCallBack(String str);
|
||||
|
||||
void chargeProtected(String str);
|
||||
|
||||
void jsExceptionWaitResult();
|
||||
|
||||
void jsShowException(String str);
|
||||
|
||||
void notifyKeyboardHidden(String str);
|
||||
|
||||
void refreshAllServo(String str);
|
||||
|
||||
void showInfraredRef(String str, String str2);
|
||||
|
||||
void wakeupBlockly(String str, int i);
|
||||
}
|
||||
690
sources/com/ubt/jimu/blockly/command/JavaScriptCommand.java
Normal file
690
sources/com/ubt/jimu/blockly/command/JavaScriptCommand.java
Normal file
@@ -0,0 +1,690 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
import com.ubt.jimu.Channel;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.base.db.diy.DiyProgramFileDbHandler;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction;
|
||||
import com.ubt.jimu.blockly.command.result.JavaResultBean;
|
||||
import com.ubt.jimu.blockly.command.result.XmlListBean;
|
||||
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuMotionDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuSoundDbHandler;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioPlayer;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioRecoder;
|
||||
import com.ubt.jimu.course.repository.CourseResult;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import com.ubtrobot.ubtlib.analytics.IAnalytics;
|
||||
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JavaScriptCommand {
|
||||
private AbstractBlocklyInteraction blocklyInteraction;
|
||||
private Context context;
|
||||
private JimuCourseCommand jimuCourseCommand;
|
||||
private JimuRobot jimuRobot;
|
||||
private WebView webView;
|
||||
protected String TAG = JavaScriptCommand.class.getSimpleName();
|
||||
private ArrayList<BlocklyProject> projects = new ArrayList<>();
|
||||
private final String BLOCKLY_INTERVAL = "continueSteps";
|
||||
private BlocklyProjectDbHandler blocklyProjectDbHandler = new BlocklyProjectDbHandler(DatabaseUtils.getDaoSession(true).a());
|
||||
private JimuMotionDbHandler jimuMotionDbHandler = new JimuMotionDbHandler(DatabaseUtils.getDaoSession(true).o());
|
||||
private JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
private IAnalytics mAnalytics = JimuAnalytics.b();
|
||||
|
||||
public JavaScriptCommand(WebView webView, Context context, JimuRobot jimuRobot, AbstractBlocklyInteraction abstractBlocklyInteraction) {
|
||||
this.jimuRobot = jimuRobot;
|
||||
this.webView = webView;
|
||||
this.context = context;
|
||||
this.blocklyInteraction = abstractBlocklyInteraction;
|
||||
this.jimuCourseCommand = new JimuCourseCommand((UnityActivity) context);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r8v2, types: [T, com.ubt.jimu.blockly.bean.JimuSound, java.lang.Object] */
|
||||
public JavaResultBean<JimuSound> addCustomSound(String str) {
|
||||
JavaResultBean<JimuSound> javaResultBean = new JavaResultBean<>();
|
||||
?? r8 = (JimuSound) JsonHelper.a(str, (Class<?>) JimuSound.class);
|
||||
if (r8 == 0) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
return javaResultBean;
|
||||
}
|
||||
if (TextUtils.isEmpty(AudioRecoder.getInstance().getFileName())) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
return javaResultBean;
|
||||
}
|
||||
File file = new File(AudioRecoder.getInstance().getFileName());
|
||||
if (!file.exists()) {
|
||||
if (file.getParentFile().exists()) {
|
||||
FileHelper.a(file.getParentFile());
|
||||
}
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
return javaResultBean;
|
||||
}
|
||||
if (TextUtils.isEmpty(r8.getDescription())) {
|
||||
r8.setDescription(this.jimuSoundDbHandler.getDefaultSoundName(Cache.getInstance().getUserId(), r8.getDefaultName()));
|
||||
}
|
||||
if (this.jimuSoundDbHandler.nameExist(Cache.getInstance().getUserId(), r8.getDescription())) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_NAME;
|
||||
return javaResultBean;
|
||||
}
|
||||
r8.setUserId(Cache.getInstance().getUserId());
|
||||
r8.setKey(AudioRecoder.getInstance().getKey());
|
||||
r8.setAudioId(AudioRecoder.getInstance().getKey());
|
||||
r8.setType(JimuSound.TYPE_RECORDING);
|
||||
r8.setDuration(((AudioPlayer.getInstance().getAudioDuration(file.getAbsolutePath()) + 500) / 1000) + "");
|
||||
r8.setIsDeleted("0");
|
||||
r8.setLastUploadTime(SystemUtils.a());
|
||||
this.jimuSoundDbHandler.insert(r8);
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.result = r8;
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction != 0) {
|
||||
abstractBlocklyInteraction.addJimuSound(r8, file);
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
public List<JimuSound> customSoundList(String str) {
|
||||
return this.jimuSoundDbHandler.getJimuSounds(this.jimuRobot.getCustomSounds(), str);
|
||||
}
|
||||
|
||||
public JavaResultBean<String> deleteCustomMotion(String str) {
|
||||
JavaResultBean<String> javaResultBean = new JavaResultBean<>();
|
||||
JimuMotion jimuMotion = (JimuMotion) JsonHelper.b(str, JimuMotion.class);
|
||||
if (jimuMotion == null) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "failed";
|
||||
return javaResultBean;
|
||||
}
|
||||
jimuMotion.setUserId(Cache.getInstance().getUserId());
|
||||
jimuMotion.setCustomModelId(this.jimuRobot.getModelId());
|
||||
JimuMotion selectUnique = this.jimuMotionDbHandler.selectUnique(jimuMotion);
|
||||
if (selectUnique == null) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "failed";
|
||||
return javaResultBean;
|
||||
}
|
||||
if (selectUnique.getIsFirst() != 0 || selectUnique.getIsUploadService()) {
|
||||
selectUnique.setIsDeleted("1");
|
||||
selectUnique.setLastUploadTime(SystemUtils.a());
|
||||
selectUnique.setIsUploadService(false);
|
||||
this.jimuMotionDbHandler.update(selectUnique);
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.retMsg = CourseResult.SUCCESS;
|
||||
} else {
|
||||
this.jimuMotionDbHandler.deleteJimuMotionByModeelId(selectUnique.getActionID());
|
||||
}
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction != null) {
|
||||
abstractBlocklyInteraction.deleteJimuMotion(selectUnique);
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
public boolean deleteCustomSound(String str, String str2) {
|
||||
JimuSound jimuSound;
|
||||
JimuSound jimuSound2 = (JimuSound) JsonHelper.a(str2, (Class<?>) JimuSound.class);
|
||||
if (jimuSound2 == null || (jimuSound = this.jimuSoundDbHandler.getJimuSound(str, jimuSound2.getKey())) == null) {
|
||||
return false;
|
||||
}
|
||||
jimuSound.setIsDeleted("1");
|
||||
jimuSound.setLastUploadTime(SystemUtils.a());
|
||||
this.jimuSoundDbHandler.update(jimuSound);
|
||||
File file = new File(this.jimuRobot.getCustomSounds() + jimuSound2.getKey());
|
||||
if (file.exists()) {
|
||||
try {
|
||||
FileHelper.a(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction == null) {
|
||||
return true;
|
||||
}
|
||||
abstractBlocklyInteraction.deleteJimuSound(jimuSound, file);
|
||||
return true;
|
||||
}
|
||||
|
||||
public JavaResultBean<Object> deleteXml(String str) {
|
||||
boolean z;
|
||||
Iterator<BlocklyProject> it = this.projects.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
BlocklyProject next = it.next();
|
||||
if (next.getXmlId().equals(str)) {
|
||||
z = next.getIsDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
JavaResultBean<Object> javaResultBean = new JavaResultBean<>();
|
||||
if (z) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
javaResultBean.retMsg = "can not delete sample project.";
|
||||
return javaResultBean;
|
||||
}
|
||||
BlocklyProject blocklyProject = this.blocklyProjectDbHandler.getBlocklyProject(Cache.getInstance().getUserId(), this.jimuRobot.getServerModelType(), this.jimuRobot.getModelId(), str);
|
||||
if (blocklyProject != null) {
|
||||
File file = new File(this.jimuRobot.getBlocklyProject(blocklyProject.getBlocklyType()) + str + ".xml");
|
||||
blocklyProject.setIsDeleted("1");
|
||||
blocklyProject.setModelId(this.jimuRobot.getServerModelId());
|
||||
blocklyProject.setLastUploadTime(SystemUtils.a());
|
||||
blocklyProject.setIsModify(true);
|
||||
blocklyProject.setIsUploadService(false);
|
||||
this.blocklyProjectDbHandler.update(blocklyProject);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
javaResultBean.retCode = "0000";
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction != null) {
|
||||
abstractBlocklyInteraction.deleteBlocklyProject(blocklyProject, file);
|
||||
}
|
||||
} else {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r0v1, types: [T, com.ubt.jimu.blockly.bean.BlocklyProject, java.lang.Object] */
|
||||
public JavaResultBean<BlocklyProject> editXml(String str, String str2, String str3, String str4, String str5) {
|
||||
JavaResultBean<BlocklyProject> javaResultBean = new JavaResultBean<>();
|
||||
?? blocklyProject = this.blocklyProjectDbHandler.getBlocklyProject(Cache.getInstance().getUserId(), this.jimuRobot.getServerModelType(), this.jimuRobot.getModelId(), str3);
|
||||
if (blocklyProject == 0) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "the project you editing not exist!";
|
||||
return javaResultBean;
|
||||
}
|
||||
blocklyProject.setXmlName(str);
|
||||
blocklyProject.setBlocklyVersion(str4);
|
||||
blocklyProject.setModelId(this.jimuRobot.getServerModelId());
|
||||
blocklyProject.setIsUploadService(false);
|
||||
blocklyProject.setIsModify(true);
|
||||
blocklyProject.setIsUploadQiNiu(false);
|
||||
blocklyProject.setLastUploadTime(SystemUtils.a());
|
||||
this.blocklyProjectDbHandler.update(blocklyProject);
|
||||
String str6 = this.jimuRobot.getBlocklyProject(blocklyProject.getBlocklyType()) + str3 + ".xml";
|
||||
if (!FileHelper.a(str6, str2, (String) null)) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
javaResultBean.retMsg = "can not write xmlContent to file";
|
||||
return javaResultBean;
|
||||
}
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.retMsg = CourseResult.SUCCESS;
|
||||
javaResultBean.result = blocklyProject;
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction != 0) {
|
||||
abstractBlocklyInteraction.updateBlocklyProject(blocklyProject, new File(str6));
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r6v4, types: [T, com.ubt.jimu.blockly.bean.JimuMotion] */
|
||||
public JavaResultBean<JimuMotion> getCustomMotion(String str) {
|
||||
JavaResultBean<JimuMotion> javaResultBean = new JavaResultBean<>();
|
||||
JimuMotion jimuMotion = (JimuMotion) JsonHelper.b(str, JimuMotion.class);
|
||||
if (jimuMotion == null) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "无效的参数输入";
|
||||
return javaResultBean;
|
||||
}
|
||||
?? jimuMotionById = this.jimuMotionDbHandler.getJimuMotionById(Cache.getInstance().getUserId(), this.jimuRobot.getModelId(), jimuMotion.getActionID());
|
||||
if (jimuMotionById == 0) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "failed";
|
||||
} else {
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.retMsg = CourseResult.SUCCESS;
|
||||
javaResultBean.result = jimuMotionById;
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
public List<JimuMotion> getMotionList() {
|
||||
return this.jimuMotionDbHandler.getUserModelMotions(Cache.getInstance().getUserId(), this.jimuRobot.getModelId());
|
||||
}
|
||||
|
||||
public JavaResultBean<String> helpUrl() {
|
||||
JavaResultBean<String> javaResultBean = new JavaResultBean<>();
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.retMsg = CourseResult.SUCCESS;
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
jSONObject.put("funcName", UnityActivity.BLOCKLY_HELP);
|
||||
jSONObject.put("arg", "");
|
||||
UnityActivity.communityWithUnity(jSONObject.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
public void playAudio(String str) {
|
||||
final JimuSound jimuSound = (JimuSound) JsonHelper.a(str, (Class<?>) JimuSound.class);
|
||||
if (jimuSound == null) {
|
||||
return;
|
||||
}
|
||||
String str2 = null;
|
||||
if (JimuSound.TYPE_RECORDING.equals(jimuSound.getType())) {
|
||||
File file = new File(this.jimuRobot.getCustomSounds() + jimuSound.getKey());
|
||||
if (file.exists()) {
|
||||
String[] list = file.list();
|
||||
int length = list.length;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= length) {
|
||||
break;
|
||||
}
|
||||
String str3 = list[i];
|
||||
if (str3.matches("^.+(aac|wav|mp3|3gp)$")) {
|
||||
str2 = file.getAbsolutePath() + File.separator + str3;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
str2 = Utils.baseUrl + jimuSound.getPlayPath();
|
||||
}
|
||||
long parseDouble = JimuSound.TYPE_TUNE.equals(jimuSound.getType()) ? !TextUtils.isEmpty(jimuSound.getBeatTime()) ? (long) (Double.parseDouble(jimuSound.getBeatTime()) * 1000.0d) : AudioPlayer.getInstance().getAudioDuration(str2) : 0L;
|
||||
if (new File(str2).exists()) {
|
||||
if (jimuSound.getIsDelay()) {
|
||||
AudioPlayer.getInstance().play(str2, parseDouble, new AudioPlayer.IProgressListener() { // from class: com.ubt.jimu.blockly.command.JavaScriptCommand.1
|
||||
private void wakeupBlockly() {
|
||||
JavaScriptCommand.this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.command.JavaScriptCommand.1.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
Utils.setJSResult(JavaScriptCommand.this.webView, "continueSteps", jimuSound.getBranchId(), "1");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.audio.AudioPlayer.IProgressListener
|
||||
public void onError() {
|
||||
wakeupBlockly();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.audio.AudioPlayer.IProgressListener
|
||||
public void onFinished() {
|
||||
wakeupBlockly();
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
AudioPlayer.getInstance().play(str2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Log.e(this.TAG, "音效文件丢失:" + str2);
|
||||
if (jimuSound.getIsDelay()) {
|
||||
Utils.setJSResult(this.webView, "continueSteps", jimuSound.getBranchId(), "1");
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r0v5, types: [T, java.lang.String] */
|
||||
public JavaResultBean<String> readXml(String str) {
|
||||
String str2;
|
||||
if (this.projects.size() == 0) {
|
||||
xmlList();
|
||||
}
|
||||
BlocklyProject blocklyProject = null;
|
||||
Iterator<BlocklyProject> it = this.projects.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
BlocklyProject next = it.next();
|
||||
if (next.getXmlId().equals(str)) {
|
||||
blocklyProject = next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
JavaResultBean<String> javaResultBean = new JavaResultBean<>();
|
||||
if (blocklyProject != null) {
|
||||
if (blocklyProject.getIsDefault()) {
|
||||
str2 = this.jimuRobot.getSamplePath() + str + ".xml";
|
||||
} else {
|
||||
str2 = this.jimuRobot.getBlocklyProject(blocklyProject.getBlocklyType()) + str + ".xml";
|
||||
}
|
||||
String b = FileHelper.b(str2, "");
|
||||
javaResultBean.retCode = "0000";
|
||||
XmlListBean xmlListBean = new XmlListBean(b);
|
||||
xmlListBean.type = TextUtils.isEmpty(blocklyProject.getBlocklyType()) ? "newBlockly" : blocklyProject.getBlocklyType();
|
||||
xmlListBean.isDefault = blocklyProject.getIsDefault();
|
||||
xmlListBean.blocklyVersion = blocklyProject.getBlocklyVersion();
|
||||
javaResultBean.result = JsonHelper.a(xmlListBean);
|
||||
if ("google_play".equals(Channel.FIR_TEST.getChannelName())) {
|
||||
ALog.a(this.TAG).d(FileHelper.b(str2, ""));
|
||||
}
|
||||
} else {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
javaResultBean.retMsg = "xmlId not in projects";
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
public void recordContentViewEnd(String str) {
|
||||
this.mAnalytics.b((Activity) this.context, str);
|
||||
}
|
||||
|
||||
public void recordContentViewStart(String str) {
|
||||
this.mAnalytics.a((Activity) this.context, str);
|
||||
}
|
||||
|
||||
public void recordEvent(String str, String str2) {
|
||||
if (TextUtils.isEmpty(str2)) {
|
||||
JimuAnalytics.b().a(str);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(str2);
|
||||
Iterator<String> keys = jSONObject.keys();
|
||||
HashMap hashMap = new HashMap();
|
||||
while (keys.hasNext()) {
|
||||
String next = keys.next();
|
||||
hashMap.put(next, String.valueOf(jSONObject.get(next)));
|
||||
}
|
||||
JimuAnalytics.b().a(str, hashMap);
|
||||
} catch (JSONException e) {
|
||||
Log.e(this.TAG, "Parse data report event param fail!", e);
|
||||
} catch (Exception e2) {
|
||||
Log.e(this.TAG, "Parse data report event param fail!", e2);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:26:0x00ad, code lost:
|
||||
|
||||
if (r4 == false) goto L28;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:27:0x00af, code lost:
|
||||
|
||||
r0.retCode = "0000";
|
||||
r0.result = r8;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:28:0x00b8, code lost:
|
||||
|
||||
return r0;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:29:0x00b6, code lost:
|
||||
|
||||
r0.retCode = com.ubt.jimu.blockly.command.result.JavaResultBean.RESULT_EXCEPTION;
|
||||
*/
|
||||
/* JADX WARN: Type inference failed for: r8v2, types: [T, com.ubt.jimu.blockly.bean.JimuSound] */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public com.ubt.jimu.blockly.command.result.JavaResultBean<com.ubt.jimu.blockly.bean.JimuSound> renameAudio(java.lang.String r8) {
|
||||
/*
|
||||
r7 = this;
|
||||
com.ubt.jimu.blockly.command.result.JavaResultBean r0 = new com.ubt.jimu.blockly.command.result.JavaResultBean
|
||||
r0.<init>()
|
||||
java.lang.Class<com.ubt.jimu.blockly.bean.JimuSound> r1 = com.ubt.jimu.blockly.bean.JimuSound.class
|
||||
java.lang.Object r8 = com.ubt.jimu.utils.JsonHelper.a(r8, r1)
|
||||
com.ubt.jimu.blockly.bean.JimuSound r8 = (com.ubt.jimu.blockly.bean.JimuSound) r8
|
||||
java.lang.String r1 = "0011"
|
||||
if (r8 == 0) goto Lbc
|
||||
java.lang.String r2 = r8.getDescription()
|
||||
boolean r2 = android.text.TextUtils.isEmpty(r2)
|
||||
if (r2 == 0) goto L1d
|
||||
goto Lbc
|
||||
L1d:
|
||||
com.ubt.jimu.blockly.dao.JimuSoundDbHandler r2 = r7.jimuSoundDbHandler
|
||||
com.ubt.jimu.blockly.JimuRobot r3 = r7.jimuRobot
|
||||
java.lang.String r3 = r3.getCustomSounds()
|
||||
com.ubt.jimu.base.cache.Cache r4 = com.ubt.jimu.base.cache.Cache.getInstance()
|
||||
java.lang.String r4 = r4.getUserId()
|
||||
java.util.List r2 = r2.getJimuSounds(r3, r4)
|
||||
if (r2 == 0) goto Lb9
|
||||
int r3 = r2.size()
|
||||
if (r3 != 0) goto L3b
|
||||
goto Lb9
|
||||
L3b:
|
||||
java.util.Iterator r2 = r2.iterator()
|
||||
L3f:
|
||||
boolean r3 = r2.hasNext()
|
||||
r4 = 0
|
||||
if (r3 == 0) goto Lad
|
||||
java.lang.Object r3 = r2.next()
|
||||
com.ubt.jimu.blockly.bean.JimuSound r3 = (com.ubt.jimu.blockly.bean.JimuSound) r3
|
||||
java.lang.String r5 = r3.getDescription()
|
||||
boolean r6 = android.text.TextUtils.isEmpty(r5)
|
||||
if (r6 != 0) goto L65
|
||||
java.lang.String r6 = r8.getDescription()
|
||||
boolean r5 = r5.equals(r6)
|
||||
if (r5 == 0) goto L65
|
||||
java.lang.String r8 = "0001"
|
||||
r0.retCode = r8
|
||||
return r0
|
||||
L65:
|
||||
java.lang.String r5 = r3.getKey()
|
||||
java.lang.String r6 = r8.getKey()
|
||||
boolean r5 = r5.equals(r6)
|
||||
if (r5 == 0) goto L3f
|
||||
java.lang.String r2 = r8.getDescription()
|
||||
r3.setDescription(r2)
|
||||
java.lang.String r2 = r3.getDuration()
|
||||
r8.setDuration(r2)
|
||||
java.lang.String r2 = r3.getIcon()
|
||||
r8.setIcon(r2)
|
||||
java.lang.String r2 = r3.getType()
|
||||
r8.setType(r2)
|
||||
long r5 = com.ubt.jimu.utils.SystemUtils.a()
|
||||
r8.setLastUploadTime(r5)
|
||||
r8.setIsSyncUbtService(r4)
|
||||
r4 = 1
|
||||
long r5 = r8.getLastUploadTime()
|
||||
r3.setLastUploadTime(r5)
|
||||
com.ubt.jimu.blockly.dao.JimuSoundDbHandler r2 = r7.jimuSoundDbHandler
|
||||
r2.insertOrUpdate(r3)
|
||||
com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction r2 = r7.blocklyInteraction
|
||||
if (r2 == 0) goto Lad
|
||||
r2.renameJimuSound(r3)
|
||||
Lad:
|
||||
if (r4 == 0) goto Lb6
|
||||
java.lang.String r1 = "0000"
|
||||
r0.retCode = r1
|
||||
r0.result = r8
|
||||
goto Lb8
|
||||
Lb6:
|
||||
r0.retCode = r1
|
||||
Lb8:
|
||||
return r0
|
||||
Lb9:
|
||||
r0.retCode = r1
|
||||
return r0
|
||||
Lbc:
|
||||
r0.retCode = r1
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.blockly.command.JavaScriptCommand.renameAudio(java.lang.String):com.ubt.jimu.blockly.command.result.JavaResultBean");
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r1v2, types: [T, com.ubt.jimu.blockly.bean.JimuMotion, java.lang.Object] */
|
||||
public JavaResultBean<JimuMotion> renameMotion(String str) {
|
||||
JavaResultBean<JimuMotion> javaResultBean = new JavaResultBean<>();
|
||||
JimuMotion jimuMotion = (JimuMotion) JsonHelper.b(str, JimuMotion.class);
|
||||
if (jimuMotion == null) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
return javaResultBean;
|
||||
}
|
||||
?? jimuMotionById = this.jimuMotionDbHandler.getJimuMotionById(Cache.getInstance().getUserId(), this.jimuRobot.getModelId(), jimuMotion.getActionID());
|
||||
if (jimuMotionById == 0) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
return javaResultBean;
|
||||
}
|
||||
if (this.jimuMotionDbHandler.nameExist(jimuMotion)) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_NAME;
|
||||
return javaResultBean;
|
||||
}
|
||||
jimuMotionById.setLastUploadTime(SystemUtils.a());
|
||||
jimuMotionById.setIsUploadService(false);
|
||||
jimuMotionById.setActionName(jimuMotion.getActionName());
|
||||
this.jimuMotionDbHandler.insertOrUpdate(jimuMotionById);
|
||||
javaResultBean.result = jimuMotionById;
|
||||
javaResultBean.retCode = "0000";
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction != 0) {
|
||||
abstractBlocklyInteraction.renameJimuMotion(jimuMotionById);
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r2v10, types: [T, com.ubt.jimu.blockly.bean.BlocklyProject, java.lang.Object] */
|
||||
public JavaResultBean<BlocklyProject> renameProject(String str) {
|
||||
JavaResultBean<BlocklyProject> javaResultBean = new JavaResultBean<>();
|
||||
BlocklyProject blocklyProject = (BlocklyProject) JsonHelper.b(str, BlocklyProject.class);
|
||||
if (blocklyProject == null) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
return javaResultBean;
|
||||
}
|
||||
blocklyProject.setUserId(Cache.getInstance().getUserId());
|
||||
blocklyProject.setModelType(this.jimuRobot.getServerModelType());
|
||||
blocklyProject.setCustomModelId(this.jimuRobot.getModelId());
|
||||
blocklyProject.setBlocklyType("newBlockly");
|
||||
blocklyProject.setModelId(this.jimuRobot.getServerModelId());
|
||||
?? selectUnique = this.blocklyProjectDbHandler.selectUnique(blocklyProject);
|
||||
if (selectUnique == 0) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
return javaResultBean;
|
||||
}
|
||||
if (this.blocklyProjectDbHandler.isNameExist(blocklyProject)) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_NAME;
|
||||
javaResultBean.retMsg = "project's name already exist!";
|
||||
return javaResultBean;
|
||||
}
|
||||
selectUnique.setLastUploadTime(SystemUtils.a());
|
||||
selectUnique.setXmlName(blocklyProject.getXmlName());
|
||||
selectUnique.setIsUploadService(false);
|
||||
selectUnique.setIsModify(true);
|
||||
this.blocklyProjectDbHandler.insertOrUpdate(selectUnique);
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.result = selectUnique;
|
||||
selectUnique.setModelId(this.jimuRobot.getServerModelId());
|
||||
if (this.blocklyInteraction != null) {
|
||||
this.blocklyInteraction.renameBlocklyProject(selectUnique, new File(this.jimuRobot.getBlocklyProject(selectUnique.getBlocklyType()) + selectUnique.getXmlId() + ".xml"));
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r1v4, types: [T, java.lang.String] */
|
||||
public JavaResultBean<String> saveCustomMotion(String str) {
|
||||
LogUtils.c("保存动作");
|
||||
JavaResultBean<String> javaResultBean = new JavaResultBean<>();
|
||||
JimuMotion jimuMotion = (JimuMotion) JsonHelper.b(str, JimuMotion.class);
|
||||
if (jimuMotion == 0) {
|
||||
javaResultBean.retMsg = "参数输入异常";
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
return javaResultBean;
|
||||
}
|
||||
if (TextUtils.isEmpty(jimuMotion.getActionName())) {
|
||||
jimuMotion.setActionName(this.jimuMotionDbHandler.getDefaultMotionName(Cache.getInstance().getUserId(), this.jimuRobot.getModelId(), jimuMotion.getDefaultName()));
|
||||
}
|
||||
?? formatId = Utils.getFormatId(System.currentTimeMillis());
|
||||
jimuMotion.setUserId(Cache.getInstance().getUserId());
|
||||
jimuMotion.setActionID(formatId);
|
||||
jimuMotion.setCustomModelId(this.jimuRobot.getModelId());
|
||||
jimuMotion.setModelType(this.jimuRobot.getServerModelType());
|
||||
jimuMotion.setIsDeleted("0");
|
||||
jimuMotion.setModelId((int) this.jimuRobot.getServerModelId());
|
||||
if (this.jimuMotionDbHandler.nameExist(jimuMotion)) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_NAME;
|
||||
javaResultBean.retMsg = "重名";
|
||||
return javaResultBean;
|
||||
}
|
||||
jimuMotion.setLastUploadTime(SystemUtils.a());
|
||||
this.jimuMotionDbHandler.insert(jimuMotion);
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.retMsg = CourseResult.SUCCESS;
|
||||
javaResultBean.result = formatId;
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction != null) {
|
||||
abstractBlocklyInteraction.addJimuMotion(jimuMotion);
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Type inference failed for: r14v0, types: [T, com.ubt.jimu.blockly.bean.BlocklyProject, java.lang.Object] */
|
||||
public JavaResultBean<BlocklyProject> saveXml(String str, String str2, String str3, String str4) {
|
||||
JavaResultBean<BlocklyProject> javaResultBean = new JavaResultBean<>();
|
||||
String defaultXmlName = TextUtils.isEmpty(str) ? this.blocklyProjectDbHandler.getDefaultXmlName(str4, Cache.getInstance().getUserId(), this.jimuRobot.getServerModelType(), this.jimuRobot.getModelId()) : str;
|
||||
String formatId = Utils.getFormatId(System.currentTimeMillis());
|
||||
?? blocklyProject = new BlocklyProject(Cache.getInstance().getUserId(), this.jimuRobot.getServerModelType(), this.jimuRobot.getServerModelId(), this.jimuRobot.getModelId(), "newBlockly", formatId, defaultXmlName, str3, null);
|
||||
if (this.blocklyProjectDbHandler.isNameExist(blocklyProject)) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_NAME;
|
||||
javaResultBean.retMsg = "project's name already exist!";
|
||||
return javaResultBean;
|
||||
}
|
||||
String str5 = this.jimuRobot.getBlocklyProject(blocklyProject.getBlocklyType()) + formatId + ".xml";
|
||||
if (!FileHelper.a(str5, str2, (String) null)) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
javaResultBean.retMsg = "can not write xmlContent to file";
|
||||
return javaResultBean;
|
||||
}
|
||||
blocklyProject.setIsDeleted("0");
|
||||
blocklyProject.setModelId(this.jimuRobot.getServerModelId());
|
||||
this.blocklyProjectDbHandler.insertOrUpdate(blocklyProject);
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.retMsg = CourseResult.SUCCESS;
|
||||
javaResultBean.result = blocklyProject;
|
||||
AbstractBlocklyInteraction abstractBlocklyInteraction = this.blocklyInteraction;
|
||||
if (abstractBlocklyInteraction != 0) {
|
||||
abstractBlocklyInteraction.addBlocklyProject(blocklyProject, new File(str5));
|
||||
}
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
public JavaResultBean<Object> successDeal(String str) {
|
||||
JavaResultBean<Object> javaResultBean = new JavaResultBean<>();
|
||||
this.jimuCourseCommand.successDeal(str);
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r1v8, types: [T, com.ubt.jimu.blockly.command.result.XmlListBean] */
|
||||
public JavaResultBean<XmlListBean> xmlList() {
|
||||
this.projects.clear();
|
||||
JavaResultBean<XmlListBean> javaResultBean = new JavaResultBean<>();
|
||||
javaResultBean.retCode = "0000";
|
||||
List<BlocklyProject> diyBlocklyProject = ((UnityActivity) this.context).getBlocklyType() == 8196 ? DiyProgramFileDbHandler.getDiyBlocklyProject(this.jimuRobot.getModelId()) : BlocklyProjectDbHandler.getProjects(Cache.getInstance().getUserId(), this.jimuRobot.getModelId(), Integer.valueOf(this.jimuRobot.getServerModelType()).intValue());
|
||||
if (diyBlocklyProject != null && diyBlocklyProject.size() > 0) {
|
||||
this.projects.addAll(diyBlocklyProject);
|
||||
}
|
||||
javaResultBean.result = new XmlListBean(this.projects);
|
||||
return javaResultBean;
|
||||
}
|
||||
|
||||
public void recordEvent(String str) {
|
||||
this.mAnalytics.a(str);
|
||||
}
|
||||
}
|
||||
501
sources/com/ubt/jimu/blockly/command/JimuBlocklyCommand.java
Normal file
501
sources/com/ubt/jimu/blockly/command/JimuBlocklyCommand.java
Normal file
@@ -0,0 +1,501 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
import com.alibaba.android.arouter.facade.Postcard;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.base.db.diy.DiyHelper;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.command.result.JavaResultBean;
|
||||
import com.ubt.jimu.blockly.command.result.SaveBean;
|
||||
import com.ubt.jimu.blockly.command.result.XmlListBean;
|
||||
import com.ubt.jimu.blockly.exception.BlocklyEvent;
|
||||
import com.ubt.jimu.course.repository.JimuCourse;
|
||||
import com.ubt.jimu.course.view.JimuTaskListActivity;
|
||||
import com.ubt.jimu.discover.view.CourseListActivity;
|
||||
import com.ubt.jimu.diy.view.DiyBrowseActivity;
|
||||
import com.ubt.jimu.diy.view.DiyFanActivity;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SPUtils;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuBlocklyCommand {
|
||||
public static final String BLE_STATE = "BLEState";
|
||||
public static final String CONNECT_BLE = "ConnectBLE";
|
||||
public static final String EXIT_LOGIC_VIEW = "ExitLogicView";
|
||||
public static final String LOGIC_CMD = "LogicCMD";
|
||||
public static final String SET_SEND_XT_STATE = "setSendXTState";
|
||||
public static final String SET_SERVO_MODE = "setServoMode";
|
||||
public static final String WAKEUP_BLOCKLY = "continueSteps";
|
||||
private UnityActivity context;
|
||||
private TimerTask infraredTask;
|
||||
private JimuRobot jimuRobot;
|
||||
private int moduleType;
|
||||
private String queryCallback;
|
||||
private String queryUrl;
|
||||
private Timer timer;
|
||||
private WebView webView;
|
||||
private final String BLE_CONNECT_CALLBACK = JimuUnityCommand.BLE_CONNECT_CALLBACK;
|
||||
protected final long INFRARED_INTERVAL = 200;
|
||||
protected String tag = JimuBlocklyCommand.class.getSimpleName();
|
||||
private ArrayList<BlocklyProject> projects = new ArrayList<>();
|
||||
|
||||
private class InfraredTimerTask extends TimerTask {
|
||||
private String url;
|
||||
|
||||
public InfraredTimerTask(String str) {
|
||||
this.url = str;
|
||||
}
|
||||
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
JimuBlocklyCommand.this.unityComm(this.url);
|
||||
}
|
||||
}
|
||||
|
||||
public JimuBlocklyCommand(WebView webView, UnityActivity unityActivity, JimuRobot jimuRobot) {
|
||||
this.context = unityActivity;
|
||||
this.webView = webView;
|
||||
this.jimuRobot = jimuRobot;
|
||||
}
|
||||
|
||||
private boolean isNameExist(String str, String str2, String str3) {
|
||||
JavaResultBean<?> javaResultBean = new JavaResultBean<>();
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "";
|
||||
setJSResult(javaResultBean, str3, true);
|
||||
return true;
|
||||
}
|
||||
String b = FileHelper.b(this.jimuRobot.getBlocklyProject("blockly") + this.jimuRobot.getModelId() + ".config", (String) null);
|
||||
if (!TextUtils.isEmpty(b)) {
|
||||
ArrayList arrayList = (ArrayList) JsonHelper.a(b, new TypeToken<List<BlocklyProject>>() { // from class: com.ubt.jimu.blockly.command.JimuBlocklyCommand.3
|
||||
}.getType());
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList();
|
||||
}
|
||||
if (arrayList.size() > 0) {
|
||||
Iterator it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
BlocklyProject blocklyProject = (BlocklyProject) it.next();
|
||||
if (blocklyProject.getXmlName().equals(str) && !blocklyProject.getXmlId().equals(str2)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String writeConfigFile(String str, String str2, String str3, String str4) {
|
||||
String str5 = this.jimuRobot.getBlocklyProject("blockly") + this.jimuRobot.getModelId() + ".config";
|
||||
BlocklyProject blocklyProject = null;
|
||||
String b = FileHelper.b(str5, (String) null);
|
||||
boolean isEmpty = TextUtils.isEmpty(b);
|
||||
ArrayList arrayList = (ArrayList) JsonHelper.a(b, new TypeToken<List<BlocklyProject>>() { // from class: com.ubt.jimu.blockly.command.JimuBlocklyCommand.4
|
||||
}.getType());
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList();
|
||||
}
|
||||
if (TextUtils.isEmpty(str3)) {
|
||||
str3 = System.currentTimeMillis() + "";
|
||||
File file = new File(this.jimuRobot.getBlocklyProject("blockly"));
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
BlocklyProject blocklyProject2 = new BlocklyProject();
|
||||
blocklyProject2.setXmlId(str3);
|
||||
blocklyProject2.setXmlName(str);
|
||||
blocklyProject2.setBlocklyVersion(str4);
|
||||
blocklyProject2.setIsDefault(false);
|
||||
arrayList.add(0, blocklyProject2);
|
||||
this.projects.add(0, blocklyProject2);
|
||||
} else {
|
||||
Iterator it = arrayList.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
BlocklyProject blocklyProject3 = (BlocklyProject) it.next();
|
||||
if (blocklyProject3.getXmlId().equals(str3)) {
|
||||
blocklyProject3.setXmlName(str);
|
||||
blocklyProject = blocklyProject3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (blocklyProject != null) {
|
||||
arrayList.remove(blocklyProject);
|
||||
arrayList.add(0, blocklyProject);
|
||||
}
|
||||
}
|
||||
FileHelper.a(str5, JsonHelper.a(arrayList), "utf-8");
|
||||
if (isEmpty) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getModelType())) {
|
||||
Integer.parseInt(this.jimuRobot.getModelType());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(this.tag, "保存文件:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
return str3;
|
||||
}
|
||||
|
||||
public void bleState() {
|
||||
UnityActivity.communityWithUnity(this.context, BLE_STATE, "");
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
UnityActivity unityActivity;
|
||||
UnityActivity.communityWithUnity(this.context, EXIT_LOGIC_VIEW, "");
|
||||
if (8194 == this.context.getBlocklyType()) {
|
||||
JimuCourse jimuCourse = Cache.getInstance().getJimuCourse();
|
||||
Robot robot = Cache.getInstance().getRobot();
|
||||
if (robot != null && jimuCourse != null && (unityActivity = this.context) != null) {
|
||||
JimuTaskListActivity.start(unityActivity, Cache.getInstance().getPackageId(), robot.getModelId(), jimuCourse.getId());
|
||||
}
|
||||
} else if (8193 == this.context.getBlocklyType()) {
|
||||
LogUtils.c("返回首页");
|
||||
ARouter.b().a("/page/main").t();
|
||||
} else if (8197 == this.context.getBlocklyType()) {
|
||||
CourseListActivity.start(this.context, "AstroBot");
|
||||
} else if (8195 == this.context.getBlocklyType()) {
|
||||
DiyFanActivity.start(this.context, DiyFanActivity.uuid);
|
||||
} else if (8196 == this.context.getBlocklyType() || 8192 == this.context.getBlocklyType()) {
|
||||
SPUtils.b(String.format(DiyBrowseActivity.DIYSTEP, this.context.getModelID()), -2);
|
||||
ARouter.b().a("/diy/detail").t();
|
||||
} else {
|
||||
ARouter.b().a("/page/main").t();
|
||||
}
|
||||
stopSensorTimer("");
|
||||
}
|
||||
|
||||
public void confirm(String str) {
|
||||
String[] split;
|
||||
FileHelper.a(Utils.baseUrl + "status.txt", "", (String) null);
|
||||
if (TextUtils.isEmpty(str) || (split = str.split("\\|")) == null || split.length < 2) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Utils.setJSResult(this.webView, "continueSteps", URLEncoder.encode(new JSONObject(split[1]).optString("branchId"), "utf-8"), "1");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void connectedBLE() {
|
||||
UnityActivity.communityWithUnity(this.context, CONNECT_BLE, "");
|
||||
}
|
||||
|
||||
public void deleteXml(String str, String str2) {
|
||||
boolean z;
|
||||
ALog.a(this.tag).d("deleteXml");
|
||||
Iterator<BlocklyProject> it = this.projects.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
BlocklyProject next = it.next();
|
||||
if (next.getXmlId().equals(str)) {
|
||||
z = next.getIsDefault();
|
||||
break;
|
||||
}
|
||||
}
|
||||
JavaResultBean<?> javaResultBean = new JavaResultBean<>();
|
||||
if (z) {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
javaResultBean.retMsg = "can not delete sample project.";
|
||||
} else {
|
||||
File file = new File(this.jimuRobot.getBlocklyProject("blockly") + str + ".xml");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
javaResultBean.retCode = "0000";
|
||||
} else {
|
||||
javaResultBean.retCode = "0000";
|
||||
javaResultBean.retMsg = "file not exit";
|
||||
}
|
||||
String str3 = this.jimuRobot.getBlocklyProject("blockly") + this.jimuRobot.getModelId() + ".config";
|
||||
ArrayList arrayList = (ArrayList) JsonHelper.a(FileHelper.b(str3, (String) null), new TypeToken<List<BlocklyProject>>() { // from class: com.ubt.jimu.blockly.command.JimuBlocklyCommand.5
|
||||
}.getType());
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList();
|
||||
}
|
||||
Iterator it2 = arrayList.iterator();
|
||||
while (true) {
|
||||
if (!it2.hasNext()) {
|
||||
break;
|
||||
}
|
||||
BlocklyProject blocklyProject = (BlocklyProject) it2.next();
|
||||
if (blocklyProject.getXmlId().equals(str)) {
|
||||
arrayList.remove(blocklyProject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
FileHelper.a(str3, JsonHelper.a(arrayList), "utf-8");
|
||||
}
|
||||
setJSResult(javaResultBean, str2, false);
|
||||
}
|
||||
|
||||
public JimuRobot getJimuRobot() {
|
||||
return this.jimuRobot;
|
||||
}
|
||||
|
||||
public int getModuleType() {
|
||||
return this.moduleType;
|
||||
}
|
||||
|
||||
public String getQueryCallback() {
|
||||
return this.queryCallback;
|
||||
}
|
||||
|
||||
public String getQueryUrl() {
|
||||
return this.queryUrl;
|
||||
}
|
||||
|
||||
public void heartBeat(String str) {
|
||||
UnityActivity.communityWithUnity(this.context, SET_SEND_XT_STATE, str);
|
||||
}
|
||||
|
||||
public void notifyBLEState(String str) {
|
||||
EventBus.b().b(new BlocklyEvent(1006, str));
|
||||
setJSResult(JimuUnityCommand.BLE_CONNECT_CALLBACK, str, true);
|
||||
}
|
||||
|
||||
public void queryInfrared(String str, String str2) {
|
||||
unityComm(str);
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r1v4, types: [T, com.ubt.jimu.blockly.command.result.XmlListBean] */
|
||||
public void readXml(String str, String str2) {
|
||||
BlocklyProject blocklyProject;
|
||||
String str3;
|
||||
ALog.a(this.tag).d("readXml");
|
||||
Iterator<BlocklyProject> it = this.projects.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
blocklyProject = null;
|
||||
break;
|
||||
} else {
|
||||
blocklyProject = it.next();
|
||||
if (blocklyProject.getXmlId().equals(str)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
JavaResultBean<?> javaResultBean = new JavaResultBean<>();
|
||||
if (blocklyProject != null) {
|
||||
if (blocklyProject.getIsDefault()) {
|
||||
str3 = this.jimuRobot.getSamplePath() + str + ".xml";
|
||||
} else {
|
||||
str3 = this.jimuRobot.getBlocklyProject("blockly") + str + ".xml";
|
||||
}
|
||||
javaResultBean.retCode = "0000";
|
||||
} else {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
javaResultBean.retMsg = "xmlId not in projects";
|
||||
str3 = "";
|
||||
}
|
||||
javaResultBean.result = new XmlListBean(str3);
|
||||
setJSResult(javaResultBean, str2, true);
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r4v3, types: [T, com.ubt.jimu.blockly.command.result.SaveBean] */
|
||||
public void saveXml(String str, String str2, String str3, String str4, String str5) {
|
||||
ALog.a(this.tag).d("saveXml");
|
||||
if (TextUtils.isEmpty(str3)) {
|
||||
isNameExist(str, str3, str5);
|
||||
}
|
||||
String writeConfigFile = writeConfigFile(str, str2, str3, str4);
|
||||
JavaResultBean<?> javaResultBean = new JavaResultBean<>();
|
||||
if (FileHelper.a(this.jimuRobot.getBlocklyProject("blockly") + writeConfigFile + ".xml", str2, (String) null)) {
|
||||
javaResultBean.retCode = "0000";
|
||||
} else {
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_FAILED;
|
||||
}
|
||||
?? saveBean = new SaveBean();
|
||||
saveBean.xmlId = writeConfigFile;
|
||||
javaResultBean.result = saveBean;
|
||||
setJSResult(javaResultBean, str5, true);
|
||||
Iterator<BlocklyProject> it = this.projects.iterator();
|
||||
while (it.hasNext()) {
|
||||
BlocklyProject next = it.next();
|
||||
if (!TextUtils.isEmpty(next.getXmlId())) {
|
||||
next.getXmlId().equals(writeConfigFile);
|
||||
}
|
||||
}
|
||||
Integer.parseInt(this.jimuRobot.getModelType());
|
||||
}
|
||||
|
||||
public void servoSet(String str) {
|
||||
try {
|
||||
FileHelper.a(Utils.baseUrl + "status.txt", "", (String) null);
|
||||
Utils.setJSResult(this.webView, "continueSteps", URLEncoder.encode(str, "utf-8"), "1");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(this.tag, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void setJSResult(String str, String str2, boolean z) {
|
||||
if (z) {
|
||||
try {
|
||||
str2 = URLEncoder.encode(str2, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(this.tag, e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
final String str3 = "javascript:" + str + "('" + str2 + "')";
|
||||
this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.command.JimuBlocklyCommand.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
JimuBlocklyCommand.this.webView.loadUrl(str3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setJimuRobot(JimuRobot jimuRobot) {
|
||||
}
|
||||
|
||||
public void setModuleType(int i) {
|
||||
this.moduleType = i;
|
||||
}
|
||||
|
||||
public void setServoMode() {
|
||||
DiyDBModel queryForUUid;
|
||||
if (!"1".equals(this.jimuRobot.getModelType()) || (queryForUUid = DiyHelper.getInstance().queryForUUid(this.jimuRobot.getModelId())) == null) {
|
||||
return;
|
||||
}
|
||||
this.context.setIsBack(true);
|
||||
Postcard a = ARouter.b().a("/controller/servosettings");
|
||||
a.a("isFromUnity", true);
|
||||
a.a("robotLite", queryForUUid.getRobotLite());
|
||||
a.a(this.context, 107);
|
||||
}
|
||||
|
||||
public void startSensorTimer(String str, String str2) {
|
||||
ALog.a(this.tag).d("startSensorTimer");
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return;
|
||||
}
|
||||
this.queryUrl = str;
|
||||
this.queryCallback = str2;
|
||||
String str3 = "jimu://queryAllSensor";
|
||||
String[] split = str.split("\\|");
|
||||
if (split != null && split.length >= 1) {
|
||||
str3 = ("jimu://queryAllSensor|") + split[1];
|
||||
}
|
||||
if (split != null && split.length >= 2) {
|
||||
str3 = str3 + "|" + str2;
|
||||
}
|
||||
stopSensorTimer("");
|
||||
this.timer = new Timer();
|
||||
this.infraredTask = new InfraredTimerTask(str3);
|
||||
this.timer.schedule(this.infraredTask, 50L, 200L);
|
||||
}
|
||||
|
||||
public void stopSensorTimer(String str) {
|
||||
ALog.a(this.tag).d("stopSensorTimer");
|
||||
TimerTask timerTask = this.infraredTask;
|
||||
if (timerTask != null) {
|
||||
timerTask.cancel();
|
||||
this.infraredTask = null;
|
||||
}
|
||||
Timer timer = this.timer;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
this.timer.purge();
|
||||
this.timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void unityComm(String str) {
|
||||
JSONObject jSONObject = new JSONObject();
|
||||
try {
|
||||
jSONObject.put("funcName", LOGIC_CMD);
|
||||
jSONObject.put("arg", URLDecoder.decode(str, "UTF-8"));
|
||||
UnityActivity.communityWithUnity(this.context, jSONObject.toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JSONException e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r0v10, types: [T, com.ubt.jimu.blockly.command.result.XmlListBean] */
|
||||
/* JADX WARN: Type inference failed for: r0v8, types: [T, com.ubt.jimu.blockly.command.result.XmlListBean] */
|
||||
public void xmlList(String str) {
|
||||
ALog.a(this.tag).d("xmlList");
|
||||
this.projects.clear();
|
||||
File file = new File(this.jimuRobot.getBlocklyProject("blockly") + this.jimuRobot.getModelId() + ".config");
|
||||
File file2 = new File(this.jimuRobot.getSamplePath() + this.jimuRobot.getModelId() + ".config");
|
||||
JavaResultBean<?> javaResultBean = new JavaResultBean<>();
|
||||
javaResultBean.retCode = "0000";
|
||||
if (file.exists() || file2.exists()) {
|
||||
String b = FileHelper.b(file.getAbsolutePath(), (String) null);
|
||||
String b2 = FileHelper.b(file2.getAbsolutePath(), (String) null);
|
||||
Type type = new TypeToken<List<BlocklyProject>>() { // from class: com.ubt.jimu.blockly.command.JimuBlocklyCommand.6
|
||||
}.getType();
|
||||
ArrayList arrayList = (ArrayList) JsonHelper.a(b, type);
|
||||
ArrayList arrayList2 = (ArrayList) JsonHelper.a(b2, type);
|
||||
if (arrayList2 != null) {
|
||||
this.projects.addAll(arrayList2);
|
||||
}
|
||||
if (arrayList != null) {
|
||||
this.projects.addAll(arrayList);
|
||||
}
|
||||
javaResultBean.result = new XmlListBean(this.projects);
|
||||
} else {
|
||||
javaResultBean.result = new XmlListBean(new ArrayList());
|
||||
}
|
||||
setJSResult(javaResultBean, str, false);
|
||||
}
|
||||
|
||||
private void setJSResult(JavaResultBean<?> javaResultBean, String str, boolean z) {
|
||||
String a = JsonHelper.a(javaResultBean);
|
||||
if (z) {
|
||||
try {
|
||||
a = URLEncoder.encode(a, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
final String str2 = "javascript:" + str + "('" + a + "')";
|
||||
this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.command.JimuBlocklyCommand.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
JimuBlocklyCommand.this.webView.loadUrl(str2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
325
sources/com/ubt/jimu/blockly/command/JimuCourseCommand.java
Normal file
325
sources/com/ubt/jimu/blockly/command/JimuCourseCommand.java
Normal file
@@ -0,0 +1,325 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.course.JimuCourseMissionDbHandler;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.base.http.ApiObserver;
|
||||
import com.ubt.jimu.base.http.ApiResponse;
|
||||
import com.ubt.jimu.course.repository.CourseResult;
|
||||
import com.ubt.jimu.course.repository.JimuCourse;
|
||||
import com.ubt.jimu.course.repository.JimuCourseMission;
|
||||
import com.ubt.jimu.course.repository.JimuCourseMissionRepository;
|
||||
import com.ubt.jimu.course.repository.JimuCourseTask;
|
||||
import com.ubt.jimu.course.repository.JimuModule;
|
||||
import com.ubt.jimu.course.repository.UpdateMission;
|
||||
import com.ubt.jimu.course.view.JimuTaskListActivity;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.DeviceUtils;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubt.jimu.widgets.LoadingView;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtech.view.widget.ToastView;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuCourseCommand {
|
||||
private final String TAG = JimuCourseCommand.class.getSimpleName();
|
||||
private CompositeDisposable disposables = new CompositeDisposable();
|
||||
private boolean loading = false;
|
||||
private UnityActivity unityActivity;
|
||||
|
||||
public JimuCourseCommand(UnityActivity unityActivity) {
|
||||
this.unityActivity = unityActivity;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void backFromCourse() {
|
||||
backFromCourse(false);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean isLastMission(JimuCourseMission jimuCourseMission) {
|
||||
List<JimuCourseMission> missions;
|
||||
if (jimuCourseMission == null) {
|
||||
return false;
|
||||
}
|
||||
List<JimuCourseTask> courseTaskList = Cache.getInstance().getCourseTaskList();
|
||||
return courseTaskList == null || courseTaskList.size() == 0 || (missions = courseTaskList.get(courseTaskList.size() - 1).getMissions()) == null || missions.size() == 0 || missions.get(missions.size() - 1).getId() == jimuCourseMission.getId();
|
||||
}
|
||||
|
||||
private JimuCourseMission nextCourse() {
|
||||
JimuCourseMission jimuCourseMission;
|
||||
List<JimuCourseTask> courseTaskList = Cache.getInstance().getCourseTaskList();
|
||||
JimuCourseTask jimuCourseTask = Cache.getInstance().getJimuCourseTask();
|
||||
JimuCourseMission courseMission = Cache.getInstance().getCourseMission();
|
||||
int i = 0;
|
||||
for (JimuCourseMission jimuCourseMission2 : jimuCourseTask.getMissions()) {
|
||||
i++;
|
||||
if (jimuCourseMission2 != null && jimuCourseMission2.getId() == courseMission.getId()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == jimuCourseTask.getMissions().size()) {
|
||||
Iterator<JimuCourseTask> it = courseTaskList.iterator();
|
||||
int i2 = 0;
|
||||
while (it.hasNext()) {
|
||||
i2++;
|
||||
if (it.next().getId() == jimuCourseTask.getId()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i2 == courseTaskList.size()) {
|
||||
return null;
|
||||
}
|
||||
Cache.getInstance().setJimuCourseTask(courseTaskList.get(i2));
|
||||
jimuCourseMission = courseTaskList.get(i2).getMissions().get(0);
|
||||
} else {
|
||||
jimuCourseMission = jimuCourseTask.getMissions().get(i);
|
||||
}
|
||||
Cache.getInstance().setCourseMission(jimuCourseMission);
|
||||
return jimuCourseMission;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void onNextCourse() {
|
||||
JimuCourseMission nextCourse = nextCourse();
|
||||
if (nextCourse == null) {
|
||||
backFromCourse();
|
||||
return;
|
||||
}
|
||||
if ("1".equals(nextCourse.getIsLock())) {
|
||||
backFromCourse();
|
||||
return;
|
||||
}
|
||||
List<JimuModule> missingComponents = nextCourse.getMissingComponents(Cache.getInstance().getBoardInfo());
|
||||
if (missingComponents != null && missingComponents.size() > 0) {
|
||||
backFromCourse(true);
|
||||
return;
|
||||
}
|
||||
CourseResult.ResultData resultData = new CourseResult.ResultData();
|
||||
Robot robot = Cache.getInstance().getRobot();
|
||||
if (robot != null) {
|
||||
resultData.modelID = robot.getModelName();
|
||||
resultData.modelId = robot.getModelId();
|
||||
resultData.moveType = robot.getMoveType();
|
||||
}
|
||||
JimuCourse jimuCourse = Cache.getInstance().getJimuCourse();
|
||||
if (jimuCourse != null) {
|
||||
resultData.level = jimuCourse.getFolderName();
|
||||
}
|
||||
JimuCourseTask jimuCourseTask = Cache.getInstance().getJimuCourseTask();
|
||||
if (jimuCourseTask != null) {
|
||||
resultData.stage = jimuCourseTask.getFolderName();
|
||||
}
|
||||
JimuCourseMission courseMission = Cache.getInstance().getCourseMission();
|
||||
if (courseMission != null) {
|
||||
resultData.mission = courseMission.getFolderName();
|
||||
resultData.missionId = courseMission.getId();
|
||||
}
|
||||
String a = JsonHelper.a(new CourseResult(CourseResult.SUCCESS, CourseResult.SUCCESS, resultData));
|
||||
ALog.a(this.TAG).d(a);
|
||||
try {
|
||||
this.unityActivity.getUnityCallback().loadJavascript("loadNextMission", URLEncoder.encode(a, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void playAgain(ApiResponse<UpdateMission> apiResponse) {
|
||||
CourseResult.ResultData resultData = new CourseResult.ResultData();
|
||||
Robot robot = Cache.getInstance().getRobot();
|
||||
if (robot != null) {
|
||||
resultData.modelID = robot.getModelName();
|
||||
resultData.modelId = robot.getModelId();
|
||||
resultData.moveType = robot.getMoveType();
|
||||
}
|
||||
JimuCourse jimuCourse = Cache.getInstance().getJimuCourse();
|
||||
if (jimuCourse != null) {
|
||||
resultData.level = jimuCourse.getFolderName();
|
||||
}
|
||||
JimuCourseTask jimuCourseTask = Cache.getInstance().getJimuCourseTask();
|
||||
if (jimuCourseTask != null) {
|
||||
resultData.stage = jimuCourseTask.getFolderName();
|
||||
}
|
||||
JimuCourseMission courseMission = Cache.getInstance().getCourseMission();
|
||||
if (courseMission != null) {
|
||||
resultData.mission = courseMission.getFolderName();
|
||||
resultData.missionId = courseMission.getId();
|
||||
}
|
||||
String a = JsonHelper.a(new CourseResult(CourseResult.SUCCESS, CourseResult.SUCCESS, resultData));
|
||||
ALog.a(this.TAG).d(a);
|
||||
try {
|
||||
this.unityActivity.getUnityCallback().loadJavascript("loadNextMission", URLEncoder.encode(a, "UTF-8"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void skipCourse(String str, String str2, long j, long j2, long j3) {
|
||||
JimuCourseMissionRepository.getInstance().skipMission(str, j3, str2, j, j2, new ApiObserver<ApiResponse<List<JimuCourseMission>>>(null) { // from class: com.ubt.jimu.blockly.command.JimuCourseCommand.2
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
JimuCourseCommand.this.disposables.b(disposable);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onNext(ApiResponse<List<JimuCourseMission>> apiResponse) {
|
||||
if (apiResponse == null || apiResponse.getModels() == null) {
|
||||
JimuCourseCommand.this.backFromCourse();
|
||||
} else {
|
||||
JimuCourseCommand.unLockMission(apiResponse.getModels());
|
||||
JimuCourseCommand.this.onNextCourse();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void unLockMission(List<JimuCourseMission> list) {
|
||||
boolean z;
|
||||
if (list == null || list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (JimuCourseMission jimuCourseMission : list) {
|
||||
List<JimuCourseTask> courseTaskList = Cache.getInstance().getCourseTaskList();
|
||||
if (courseTaskList != null) {
|
||||
for (int i = 0; i < courseTaskList.size(); i++) {
|
||||
Iterator<JimuCourseMission> it = courseTaskList.get(i).getMissions().iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
z = false;
|
||||
break;
|
||||
}
|
||||
JimuCourseMission next = it.next();
|
||||
if (next.getId() == jimuCourseMission.getId()) {
|
||||
next.setIsLock(jimuCourseMission.getIsLock());
|
||||
next.setIsSkip(jimuCourseMission.getIsSkip());
|
||||
next.setStar(jimuCourseMission.getStar());
|
||||
z = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (z) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
JimuCourseMissionDbHandler.updateMissions(list);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void updateCurrentMission(UpdateMission updateMission) {
|
||||
JimuCourseMission courseMission = Cache.getInstance().getCourseMission();
|
||||
if (courseMission == null || updateMission == null) {
|
||||
return;
|
||||
}
|
||||
if (courseMission.getId() == updateMission.getMissionId()) {
|
||||
courseMission.setStar(updateMission.getStar());
|
||||
}
|
||||
JimuCourseMissionDbHandler.updateNextMission(courseMission);
|
||||
}
|
||||
|
||||
private synchronized Observable updateMission(String str, long j, int i, String str2, long j2, long j3, final int i2) {
|
||||
LoadingView loadingView = null;
|
||||
if (this.loading) {
|
||||
return null;
|
||||
}
|
||||
this.loading = true;
|
||||
return JimuCourseMissionRepository.getInstance().updateMission(str, j, i, str2, j2, j3, new ApiObserver<ApiResponse<UpdateMission>>(loadingView) { // from class: com.ubt.jimu.blockly.command.JimuCourseCommand.1
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
JimuCourseCommand.this.loading = false;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
JimuCourseCommand.this.loading = false;
|
||||
if (i2 == 1) {
|
||||
JimuCourseCommand.this.backFromCourse();
|
||||
}
|
||||
ToastView.a(JimuCourseCommand.this.unityActivity, JimuCourseCommand.this.unityActivity.getString(R.string.network_error), ToastView.Type.ERROR).a();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
JimuCourseCommand.this.disposables.b(disposable);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onNext(ApiResponse<UpdateMission> apiResponse) {
|
||||
JimuCourseCommand.this.loading = false;
|
||||
if (apiResponse == null || apiResponse.getModels() == null) {
|
||||
JimuCourseCommand.this.backFromCourse();
|
||||
return;
|
||||
}
|
||||
UpdateMission models = apiResponse.getModels();
|
||||
JimuCourseCommand.this.updateCurrentMission(models);
|
||||
if ((models.getMissions() == null || models.getMissions().size() == 0) && JimuCourseCommand.this.isLastMission(Cache.getInstance().getCourseMission())) {
|
||||
JimuCourseCommand.this.backFromCourse();
|
||||
return;
|
||||
}
|
||||
JimuCourseCommand.unLockMission(models.getMissions());
|
||||
int i3 = i2;
|
||||
if (i3 == 1) {
|
||||
JimuCourseCommand.this.backFromCourse();
|
||||
return;
|
||||
}
|
||||
if (i3 == 2) {
|
||||
JimuCourseCommand.this.playAgain(apiResponse);
|
||||
} else if (i3 != 3) {
|
||||
XLog.b("Course", "unknow type");
|
||||
} else {
|
||||
JimuCourseCommand.this.onNextCourse();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clearRequest() {
|
||||
this.disposables.dispose();
|
||||
this.disposables.a();
|
||||
}
|
||||
|
||||
public void successDeal(String str) {
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(str);
|
||||
int optInt = jSONObject.optInt("type");
|
||||
int optInt2 = jSONObject.optInt("starCount");
|
||||
int optInt3 = jSONObject.optInt("missionId");
|
||||
if (optInt == 4) {
|
||||
skipCourse(Cache.getInstance().getUserId(), DeviceUtils.a(JimuApplication.l()), Cache.getInstance().getPackageId(), Cache.getInstance().getRobot().getModelId(), optInt3);
|
||||
} else {
|
||||
updateMission(Cache.getInstance().getUserId(), optInt3, optInt2, DeviceUtils.a(JimuApplication.l()), Cache.getInstance().getPackageId(), Cache.getInstance().getRobot().getModelId(), optInt);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void backFromCourse(boolean z) {
|
||||
this.unityActivity.closeBlockly();
|
||||
this.unityActivity.setIsBack(true);
|
||||
if (Cache.getInstance().getJimuCourse() == null) {
|
||||
return;
|
||||
}
|
||||
JimuTaskListActivity.start(this.unityActivity, Cache.getInstance().getPackageId(), Cache.getInstance().getRobot().getModelId(), r0.getId(), z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,628 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebView;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.Constants;
|
||||
import com.ubt.jimu.base.db.diy.DiyHelper;
|
||||
import com.ubt.jimu.base.db.starcourse.CourseDbHandler;
|
||||
import com.ubt.jimu.base.entities.ActionResult;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubt.jimu.base.entities.Course;
|
||||
import com.ubt.jimu.base.entities.Robot;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction;
|
||||
import com.ubt.jimu.blockly.command.interaction.BlocklyInteraction;
|
||||
import com.ubt.jimu.blockly.command.interaction.BlocklyUpload;
|
||||
import com.ubt.jimu.blockly.command.result.JavaResultBean;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioParams;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioPlayer;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioRecoder;
|
||||
import com.ubt.jimu.blockly.feature.course.BlocklyDomCompare;
|
||||
import com.ubt.jimu.blockly.feature.sensor.SensorObservable;
|
||||
import com.ubt.jimu.blockly.feature.sensor.SensorObserver;
|
||||
import com.ubt.jimu.blockly.view.DialogBlocklyWebView;
|
||||
import com.ubt.jimu.course.repository.JimuCourse;
|
||||
import com.ubt.jimu.course.repository.JimuCourseMission;
|
||||
import com.ubt.jimu.course.repository.JimuCourseTask;
|
||||
import com.ubt.jimu.discover.CourseHelper;
|
||||
import com.ubt.jimu.discover.IAccomplishEventListener;
|
||||
import com.ubt.jimu.discover.view.AccomplishWithoutUserDialog;
|
||||
import com.ubt.jimu.diy.DiyRobotDbHandler;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.DeviceUtils;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SPUtils;
|
||||
import com.ubtech.permission.JimuPermissionRequest;
|
||||
import com.ubtech.permission.PermissionRequestListener;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import com.ubtech.utils.PermissionHelper;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuJavascriptInterface {
|
||||
private Context context;
|
||||
private Course course;
|
||||
private DialogBlocklyWebView dialogBlocklyWebView;
|
||||
private JavaScriptCommand javaScriptCommand;
|
||||
private JimuRobot jimuRobot;
|
||||
private WebView webView;
|
||||
private final String TAG = JimuJavascriptInterface.class.getSimpleName();
|
||||
private final String BLOCKLY_INTERVAL = "continueSteps";
|
||||
private final String SOUND_FILE_MODEL_ID = "0";
|
||||
private int platformType = 1;
|
||||
private AbstractBlocklyInteraction transportAction = new BlocklyInteraction(new BlocklyUpload());
|
||||
|
||||
public JimuJavascriptInterface(WebView webView, Context context, JimuRobot jimuRobot) {
|
||||
this.jimuRobot = jimuRobot;
|
||||
this.webView = webView;
|
||||
this.context = context;
|
||||
this.javaScriptCommand = new JavaScriptCommand(webView, context, jimuRobot, this.transportAction);
|
||||
}
|
||||
|
||||
private String getBlocklyProjectId(String str) {
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(str);
|
||||
if (jSONObject.has("xmlId")) {
|
||||
return jSONObject.getString("xmlId");
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String DeleteXml(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.deleteXml(getBlocklyProjectId(str)));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String EditXml(String str) {
|
||||
BlocklyProject blocklyProject = (BlocklyProject) JsonHelper.a(str, (Class<?>) BlocklyProject.class);
|
||||
if (blocklyProject != null) {
|
||||
return JsonHelper.a(this.javaScriptCommand.editXml(blocklyProject.getXmlName(), blocklyProject.getXmlContent(), blocklyProject.getXmlId(), blocklyProject.getBlocklyVersion(), blocklyProject.getDefaultName()));
|
||||
}
|
||||
JavaResultBean javaResultBean = new JavaResultBean();
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "unknow input";
|
||||
return JsonHelper.a(javaResultBean);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String ReadXml(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.readXml(getBlocklyProjectId(str)));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String ReadXmlList() {
|
||||
return JsonHelper.a(this.javaScriptCommand.xmlList());
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String SaveXml(String str) {
|
||||
BlocklyProject blocklyProject = (BlocklyProject) JsonHelper.a(str, (Class<?>) BlocklyProject.class);
|
||||
if (blocklyProject != null) {
|
||||
return JsonHelper.a(this.javaScriptCommand.saveXml(blocklyProject.getXmlName(), blocklyProject.getXmlContent(), blocklyProject.getBlocklyVersion(), blocklyProject.getDefaultName()));
|
||||
}
|
||||
JavaResultBean javaResultBean = new JavaResultBean();
|
||||
javaResultBean.retCode = JavaResultBean.RESULT_EXCEPTION;
|
||||
javaResultBean.retMsg = "unknow input";
|
||||
return JsonHelper.a(javaResultBean);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String addCustomSound(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.addCustomSound(str));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void cancelRecordAudio() {
|
||||
AudioRecoder.getInstance().stopRecod();
|
||||
File parentFile = new File(AudioRecoder.getInstance().getFileName()).getParentFile();
|
||||
if (parentFile == null || !parentFile.exists()) {
|
||||
return;
|
||||
}
|
||||
FileHelper.a(parentFile);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void courseSuccessPopup(String str) {
|
||||
LogUtils.c("courseId:" + str + " " + str);
|
||||
final IAccomplishEventListener iAccomplishEventListener = new IAccomplishEventListener() { // from class: com.ubt.jimu.blockly.command.JimuJavascriptInterface.4
|
||||
@Override // com.ubt.jimu.discover.IAccomplishEventListener
|
||||
public void onPlayAgain(Course course) {
|
||||
JimuJavascriptInterface.this.webView.reload();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.discover.IAccomplishEventListener
|
||||
public void onPlayContinue(Course course) {
|
||||
((UnityActivity) JimuJavascriptInterface.this.context).setIsBack(true);
|
||||
((UnityActivity) JimuJavascriptInterface.this.context).closeBlockly();
|
||||
}
|
||||
};
|
||||
final AccomplishWithoutUserDialog a = AccomplishWithoutUserDialog.a(this.course);
|
||||
a.a(iAccomplishEventListener);
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (!"local".equals(userId) && !TextUtils.isEmpty(userId)) {
|
||||
if (Course.STATUS_COMPLETED.equals(this.course.getStatus())) {
|
||||
a.show(((Activity) this.context).getFragmentManager(), "course");
|
||||
return;
|
||||
}
|
||||
CourseHelper courseHelper = new CourseHelper(new CourseHelper.IUploadCourseListener() { // from class: com.ubt.jimu.blockly.command.JimuJavascriptInterface.5
|
||||
@Override // com.ubt.jimu.discover.CourseHelper.IUploadCourseListener
|
||||
public void onFailed() {
|
||||
JimuJavascriptInterface.this.dialogBlocklyWebView.hideWait();
|
||||
JimuJavascriptInterface.this.webView.postDelayed(new Runnable() { // from class: com.ubt.jimu.blockly.command.JimuJavascriptInterface.5.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
JimuJavascriptInterface.this.dialogBlocklyWebView.commonTips(JimuJavascriptInterface.this.dialogBlocklyWebView.getString(R.string.network_error), 2);
|
||||
}
|
||||
}, 500L);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.discover.CourseHelper.IUploadCourseListener
|
||||
public void onFinished() {
|
||||
JimuJavascriptInterface.this.dialogBlocklyWebView.hideWait();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.discover.CourseHelper.IUploadCourseListener
|
||||
public void onStart() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.discover.CourseHelper.IUploadCourseListener
|
||||
public void onSuccess(ActionResult actionResult) {
|
||||
if (actionResult != null && actionResult.getCourse() != null && actionResult.getFlag() == 0) {
|
||||
a.show(((Activity) JimuJavascriptInterface.this.context).getFragmentManager(), "course");
|
||||
return;
|
||||
}
|
||||
CourseDbHandler.setCourseComplete(JimuJavascriptInterface.this.course);
|
||||
AccomplishWithoutUserDialog a2 = AccomplishWithoutUserDialog.a(JimuJavascriptInterface.this.course, actionResult);
|
||||
a2.a(((Activity) JimuJavascriptInterface.this.context).getFragmentManager(), "course", actionResult);
|
||||
a2.a(iAccomplishEventListener);
|
||||
}
|
||||
});
|
||||
String b = SPUtils.b(Constant.SelectRobot.INTERSTELLAR_ADVENTURE_SELECT_PACKAGE_KEY);
|
||||
long parseLong = Long.parseLong(str);
|
||||
if (Constant.SelectRobot.INTERSTELLAR_ADVENTURE_NEW_PACKAGE_COSMOS.equals(b) || Constant.SelectRobot.INTERSTELLAR_ADVENTURE_NEW_PACKAGE_STEM.equals(b) || Constant.SelectRobot.INTERSTELLAR_ADVENTURE_NEW_PACKAGE_UPGRADED.equals(b)) {
|
||||
parseLong += 24;
|
||||
}
|
||||
courseHelper.a(parseLong);
|
||||
this.dialogBlocklyWebView.showWait();
|
||||
return;
|
||||
}
|
||||
String storyName = this.course.getStoryName();
|
||||
LogUtils.c("storyName:" + storyName + " " + str);
|
||||
if (Constant.SelectRobot.ASTROBOT_MINI.equals(storyName)) {
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
SPUtils.b(Constant.SelectRobot.LOCAL_USER_COSMOS_FLAG_NEW, Integer.parseInt(str));
|
||||
}
|
||||
} else if (!TextUtils.isEmpty(str)) {
|
||||
SPUtils.b(Constant.SelectRobot.LOCAL_USER_COSMOS_FLAG_OLD, Integer.parseInt(str));
|
||||
}
|
||||
CourseDbHandler.setCourseComplete(this.course);
|
||||
a.show(((Activity) this.context).getFragmentManager(), "course");
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String customSoundList() {
|
||||
return JsonHelper.a(this.javaScriptCommand.customSoundList(Cache.getInstance().getUserId()));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String deleteCustomMotion(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.deleteCustomMotion(str));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean deleteCustomSound(String str) {
|
||||
return this.javaScriptCommand.deleteCustomSound(Cache.getInstance().getUserId(), str);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getBlocklyProjectDescription(String str) {
|
||||
return FileHelper.b(this.jimuRobot.getSamplePath() + str + ".desc", "");
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getCustomMotion(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.getCustomMotion(str));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getCustomMotionList() {
|
||||
return JsonHelper.a(this.javaScriptCommand.getMotionList());
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getDeviceDirection() {
|
||||
return this.dialogBlocklyWebView.getDirection() == null ? "" : this.dialogBlocklyWebView.getDirection().getValue();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getInitProgramInfo() {
|
||||
return this.jimuRobot.getProgram() == null ? "" : JsonHelper.a(this.jimuRobot.getProgram());
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getMotionList() {
|
||||
return TextUtils.isEmpty(this.jimuRobot.getMotion()) ? "{}" : this.jimuRobot.getMotion();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getServoID() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(JimuRobot.ACTIONS);
|
||||
sb.append(this.jimuRobot.getAction());
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getServo())) {
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.SERVOS);
|
||||
sb.append(this.jimuRobot.getServo());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getInfraredId())) {
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.INFRARED_ID);
|
||||
sb.append(this.jimuRobot.getInfraredId());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getTouchId())) {
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.TOUCH_ID);
|
||||
sb.append(this.jimuRobot.getTouchId());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getGyroscopeId())) {
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.GYROSCOPE_ID);
|
||||
sb.append(this.jimuRobot.getGyroscopeId());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getCircleServos())) {
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.CIRCLE_SERVOS);
|
||||
sb.append(this.jimuRobot.getCircleServos());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getLights())) {
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.LIGHTS);
|
||||
sb.append(this.jimuRobot.getLights());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getColorId())) {
|
||||
sb.append("&colorId=");
|
||||
sb.append(this.jimuRobot.getColorId());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getUnicornId())) {
|
||||
sb.append("&unicornId=");
|
||||
sb.append(this.jimuRobot.getUnicornId());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getMotor())) {
|
||||
sb.append("&motor=");
|
||||
sb.append(this.jimuRobot.getMotor());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getIsLithium())) {
|
||||
sb.append("&isLithium=");
|
||||
sb.append(this.jimuRobot.getIsLithium());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getUltrasonicId())) {
|
||||
sb.append("&ultrasonicId=");
|
||||
sb.append(this.jimuRobot.getUltrasonicId());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getModelType())) {
|
||||
sb.append("&modelType=");
|
||||
sb.append(this.jimuRobot.getModelType());
|
||||
}
|
||||
if (!TextUtils.isEmpty(this.jimuRobot.getModelId())) {
|
||||
sb.append("&modelID=");
|
||||
sb.append(this.jimuRobot.getModelId());
|
||||
}
|
||||
String g = JimuApplication.l().g();
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.LANGUAGE);
|
||||
sb.append(g);
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.BLUE_STATE);
|
||||
sb.append(this.jimuRobot.getBlueState());
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.MODEL_TYPE);
|
||||
sb.append(SPUtils.a(Constant.Black.BLACK_MODEL_TYPE_KEY, 0));
|
||||
sb.append("&platformType=");
|
||||
sb.append(this.platformType);
|
||||
Robot robot = Cache.getInstance().getRobot();
|
||||
String logPath = String.valueOf(ModelType.DEFAULT.getType()).equals(this.jimuRobot.getServerModelType()) ? robot != null ? DiyRobotDbHandler.getLogPath(ModelType.DEFAULT, robot.getModelName()) : "" : DiyHelper.getInstance().queryForUUid(this.jimuRobot.getModelId()) == null ? DiyRobotDbHandler.getLogPath(ModelType.PLAYER_DATA, this.jimuRobot.getModelId()) : DiyHelper.getInstance().queryForUUid(this.jimuRobot.getModelId()).getFilePath();
|
||||
sb.append("&modelLogo=");
|
||||
sb.append(logPath);
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if ("local".equals(userId)) {
|
||||
userId = DeviceUtils.a(this.context);
|
||||
}
|
||||
sb.append("&");
|
||||
sb.append("userId=");
|
||||
sb.append(userId);
|
||||
sb.append("&");
|
||||
sb.append("edit=");
|
||||
sb.append(((UnityActivity) this.context).code != 1007 ? 1 : 0);
|
||||
if (1 == this.dialogBlocklyWebView.getModuleType()) {
|
||||
JimuCourse jimuCourse = Cache.getInstance().getJimuCourse();
|
||||
JimuCourseTask jimuCourseTask = Cache.getInstance().getJimuCourseTask();
|
||||
JimuCourseMission courseMission = Cache.getInstance().getCourseMission();
|
||||
if (robot != null && jimuCourse != null && jimuCourseTask != null && courseMission != null) {
|
||||
String str = Constants.COURSE_RESOURCE_PATH + jimuCourse.getId();
|
||||
sb.append("&");
|
||||
sb.append("packageId=");
|
||||
sb.append(Cache.getInstance().getPackageId());
|
||||
sb.append("&");
|
||||
sb.append("modelId=");
|
||||
sb.append(robot.getModelId());
|
||||
sb.append("&");
|
||||
sb.append("modelID=");
|
||||
sb.append(robot.getModelName());
|
||||
sb.append("&");
|
||||
sb.append("modelName=");
|
||||
sb.append(robot.getModelDescriptionLangeage());
|
||||
sb.append("&");
|
||||
sb.append("moveType=");
|
||||
sb.append(robot.getMoveType());
|
||||
sb.append("&");
|
||||
sb.append("level=");
|
||||
sb.append(jimuCourse.getFolderName());
|
||||
sb.append("&");
|
||||
sb.append("stage=");
|
||||
sb.append(jimuCourseTask.getFolderName());
|
||||
sb.append("&");
|
||||
sb.append("mission=");
|
||||
sb.append(courseMission.getFolderName());
|
||||
sb.append("&");
|
||||
sb.append("missionId=");
|
||||
sb.append(courseMission.getId());
|
||||
sb.append("&");
|
||||
sb.append("sourcePath=");
|
||||
sb.append(str);
|
||||
}
|
||||
} else {
|
||||
sb.append("&");
|
||||
sb.append(JimuRobot.IS_FIRST);
|
||||
sb.append(this.jimuRobot.firstOpen());
|
||||
}
|
||||
Course course = this.course;
|
||||
if (course != null) {
|
||||
String nameKey = course.getNameKey();
|
||||
String replace = TextUtils.isEmpty(nameKey) ? "" : nameKey.replace("course_", "");
|
||||
sb.append("&");
|
||||
sb.append("courseId=");
|
||||
sb.append(replace);
|
||||
sb.append("&");
|
||||
sb.append("serialName=");
|
||||
sb.append("AstroBot");
|
||||
sb.append("&");
|
||||
sb.append("sourcePath=");
|
||||
sb.append(Utils.getStarCourseDirPath());
|
||||
}
|
||||
String tTSToken = Cache.getInstance().getTTSToken();
|
||||
LogUtils.c("ttsToken:" + tTSToken);
|
||||
if (!TextUtils.isEmpty(tTSToken)) {
|
||||
sb.append("&");
|
||||
sb.append("tok=");
|
||||
sb.append(tTSToken);
|
||||
String valueOf = Cache.getInstance().getLoginUserIntId() > 0 ? String.valueOf(Cache.getInstance().getLoginUserIntId()) : DeviceUtils.a(this.context);
|
||||
sb.append("&");
|
||||
sb.append("cuid=");
|
||||
sb.append(valueOf);
|
||||
}
|
||||
String sb2 = sb.toString();
|
||||
XLog.a("Chrome", sb2);
|
||||
return sb2;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean hasRecordAuthority() {
|
||||
if (PermissionHelper.a(this.context, "android.permission.RECORD_AUDIO")) {
|
||||
return PermissionHelper.a(this.context, "android.permission.RECORD_AUDIO");
|
||||
}
|
||||
this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.command.JimuJavascriptInterface.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
JimuPermissionRequest.a((Activity) JimuJavascriptInterface.this.context, (PermissionRequestListener) null);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String helpUrl() {
|
||||
String str = "https://jimu.ubtrobot.com/jimu/help_new/help_new.html?language=" + JimuApplication.l().g();
|
||||
this.javaScriptCommand.helpUrl();
|
||||
return str;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean isTablet() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void playAudio(String str) {
|
||||
this.javaScriptCommand.playAudio(str);
|
||||
}
|
||||
|
||||
public void playCurrentRecordAudio() {
|
||||
AudioPlayer.getInstance().play(AudioRecoder.getInstance().getFileName());
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void recordContentViewEnd(String str) {
|
||||
this.javaScriptCommand.recordContentViewEnd(str);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void recordContentViewStart(String str) {
|
||||
this.javaScriptCommand.recordContentViewStart(str);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void recordEvent(String str, String str2) {
|
||||
this.javaScriptCommand.recordEvent(str, str2);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void registerSensorObserver(String str) {
|
||||
SensorObservable.getInstance().addObserver((SensorObserver) JsonHelper.a(str, (Class<?>) SensorObserver.class));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void registerSensorObservers(String str) {
|
||||
try {
|
||||
JSONArray jSONArray = new JSONArray(str);
|
||||
for (int i = 0; i < jSONArray.length(); i++) {
|
||||
JSONObject jSONObject = jSONArray.getJSONObject(i);
|
||||
if (jSONObject != null) {
|
||||
SensorObservable.getInstance().addObserver((SensorObserver) JsonHelper.a(jSONObject.toString(), (Class<?>) SensorObserver.class));
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String renameAudio(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.renameAudio(str));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String renameMotion(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.renameMotion(str));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String renameProject(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.renameProject(str));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void resignActiveBranch() {
|
||||
ALog.a(this.TAG).d("重新激活分支");
|
||||
SensorObservable.getInstance().reActiveObserver();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String saveCustomMotion(String str) {
|
||||
return JsonHelper.a(this.javaScriptCommand.saveCustomMotion(str));
|
||||
}
|
||||
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public void setDialogBlocklyWebView(DialogBlocklyWebView dialogBlocklyWebView) {
|
||||
this.dialogBlocklyWebView = dialogBlocklyWebView;
|
||||
}
|
||||
|
||||
protected void setJSResult(String str, String... strArr) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("javascript:");
|
||||
sb.append(str);
|
||||
sb.append("(");
|
||||
if (strArr != null && strArr.length > 0) {
|
||||
for (int i = 0; i < strArr.length; i++) {
|
||||
sb.append("'");
|
||||
sb.append(strArr[i]);
|
||||
sb.append("'");
|
||||
if (i < strArr.length - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
final String sb2 = sb.toString();
|
||||
Log.i(this.TAG, sb2);
|
||||
this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.command.JimuJavascriptInterface.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
JimuJavascriptInterface.this.webView.loadUrl(sb2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setJimuRobot(JimuRobot jimuRobot) {
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public boolean startRecordAudio() {
|
||||
if (!PermissionHelper.a(this.context, "android.permission.RECORD_AUDIO")) {
|
||||
this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.command.JimuJavascriptInterface.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
JimuPermissionRequest.a((Activity) JimuJavascriptInterface.this.context, (PermissionRequestListener) null);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
String formatId = Utils.getFormatId(System.currentTimeMillis());
|
||||
try {
|
||||
return AudioRecoder.getInstance().startRecord((this.jimuRobot.getCustomSounds() + formatId) + File.separator + formatId + AudioParams.AAC);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(this.TAG, "录音失败");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void stopPlayAudio() {
|
||||
AudioPlayer.getInstance().stop();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void stopRecordAudio() {
|
||||
AudioRecoder.getInstance().stopRecod();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void successDeal(String str) {
|
||||
this.javaScriptCommand.successDeal(str);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void unRegisterAllSensorObserver() {
|
||||
ALog.a(this.TAG).d("删除所有的观察者");
|
||||
SensorObservable.getInstance().deleteObservers();
|
||||
SensorObservable.getInstance().clearActiveObserver();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void unRegisterSensorObserver(String str) {
|
||||
ALog.a(this.TAG).d("删除观察者:" + str);
|
||||
SensorObservable.getInstance().deleteObserver((SensorObserver) JsonHelper.a(str, (Class<?>) SensorObserver.class));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String verifyCourse(String str, String str2) {
|
||||
String check = new BlocklyDomCompare().check(str, str2);
|
||||
Log.i(this.TAG, check);
|
||||
return check;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
@Deprecated
|
||||
public String versionSwitch(String str) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void recordEvent(String str) {
|
||||
this.javaScriptCommand.recordEvent(str);
|
||||
}
|
||||
}
|
||||
105
sources/com/ubt/jimu/blockly/command/JimuUnityCommand.java
Normal file
105
sources/com/ubt/jimu/blockly/command/JimuUnityCommand.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import android.util.Log;
|
||||
import android.webkit.WebView;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioRecoder;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuUnityCommand {
|
||||
public static final String BLE_CONNECT_CALLBACK = "blueConnectCallBack";
|
||||
public static final String CHARGE_PROTECTION = "chargeProtection";
|
||||
public static final String NOTIFY_KEYBOARD_HIDDEN = "notifyKeyboardHidden";
|
||||
public static final String REFRESH_ALL_SERVO = "refreshAllServo";
|
||||
public static final String SHOW_EXCEPTION = "showException";
|
||||
public static final String STOP_RECORD_ON_PAUSE = "stopRecordAudioCallBack";
|
||||
public static final String WAKEUP_BLOCKLY = "continueSteps";
|
||||
public static final String tag = "JimuUnityCommand";
|
||||
private WebView webView;
|
||||
|
||||
public JimuUnityCommand(WebView webView) {
|
||||
this.webView = webView;
|
||||
}
|
||||
|
||||
public void blueConnectCallBack(String str) {
|
||||
try {
|
||||
Utils.setJSResult(this.webView, BLE_CONNECT_CALLBACK, URLEncoder.encode(str, "utf-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(tag, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void chargeProtected(String str) {
|
||||
setJSResult2(CHARGE_PROTECTION, str);
|
||||
}
|
||||
|
||||
public void jsExceptionWaitResult() {
|
||||
}
|
||||
|
||||
public void jsShowException(String str) {
|
||||
Utils.setJSResult(this.webView, SHOW_EXCEPTION, str);
|
||||
if (AudioRecoder.recoding) {
|
||||
Utils.setJSResult(this.webView, STOP_RECORD_ON_PAUSE, new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyKeyboardHidden(String str) {
|
||||
Utils.setJSResult(this.webView, NOTIFY_KEYBOARD_HIDDEN, str);
|
||||
}
|
||||
|
||||
public void refreshAllServo(String str) {
|
||||
try {
|
||||
Utils.setJSResult(this.webView, "refreshAllServo", URLEncoder.encode(str, "utf-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setJSResult2(String str, String... strArr) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("javascript:");
|
||||
sb.append(str);
|
||||
sb.append("(");
|
||||
if (strArr != null && strArr.length > 0) {
|
||||
for (int i = 0; i < strArr.length; i++) {
|
||||
sb.append("\"");
|
||||
sb.append(strArr[i]);
|
||||
sb.append("\"");
|
||||
if (i < strArr.length - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
final String sb2 = sb.toString();
|
||||
Log.i(tag, sb2);
|
||||
this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.command.JimuUnityCommand.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
JimuUnityCommand.this.webView.loadUrl(sb2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showInfraredRef(String str, String str2) {
|
||||
try {
|
||||
Utils.setJSResult(this.webView, str2, URLEncoder.encode(str, "utf-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(tag, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void wakeupBlockly(String str, int i, String str2, String str3) {
|
||||
try {
|
||||
String encode = URLEncoder.encode(str, "utf-8");
|
||||
Utils.setJSResult(this.webView, "continueSteps", encode, i + "", str2, str3);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(tag, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
534
sources/com/ubt/jimu/blockly/command/UnityCommandController.java
Normal file
534
sources/com/ubt/jimu/blockly/command/UnityCommandController.java
Normal file
@@ -0,0 +1,534 @@
|
||||
package com.ubt.jimu.blockly.command;
|
||||
|
||||
import android.R;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
import com.ubt.jimu.base.entities.Course;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.command.result.QueryResult;
|
||||
import com.ubt.jimu.blockly.exception.BlocklyEvent;
|
||||
import com.ubt.jimu.blockly.exception.JimuRobotMessage;
|
||||
import com.ubt.jimu.blockly.feature.blockly.JimuSensor;
|
||||
import com.ubt.jimu.blockly.feature.sensor.DeviceDirection;
|
||||
import com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact;
|
||||
import com.ubt.jimu.blockly.feature.sensor.ManagerHelper;
|
||||
import com.ubt.jimu.blockly.feature.sensor.SensorObservable;
|
||||
import com.ubt.jimu.blockly.view.DialogBlocklyWebView;
|
||||
import com.ubt.jimu.course.repository.CourseResult;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.unity.bluetooth.ConnectionStatus;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubtech.utils.StringUtils;
|
||||
import com.ubtech.utils.XLog;
|
||||
import com.ubtrobot.jimu.bluetooth.proxy.BluetoothProxy;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UnityCommandController {
|
||||
public static final String CONNECTION_BLE_CALLBACK = "ConnectBLECallBack";
|
||||
public static final String DELETE_PROGRAM = "deleteProgram";
|
||||
public static final String FRAGMENT_TAG_BLOCKLY = "tag_blockly";
|
||||
public static final String OPEN_LOGIC_PROGRAMMING = "OpenLogicProgramming";
|
||||
public static final String REFRESH_ALL_SERVO = "refreshAllServo";
|
||||
public static final String RESULT_FAILED = "1|failure";
|
||||
public static final String RESULT_SUCCESS = "1|success";
|
||||
public static final String SHOW_EXCEPTION_CALLBACK = "JsShowExceptionCallback";
|
||||
private UnityActivity activity;
|
||||
AudioManager am;
|
||||
private DialogBlocklyWebView blockly;
|
||||
private int code;
|
||||
private DirectionSensorEventListerCompact compactListener;
|
||||
private String connenctDevice;
|
||||
private Course course;
|
||||
boolean hasMagnetic;
|
||||
private ManagerHelper managerHelper;
|
||||
private int moduleType;
|
||||
private long serverModelId;
|
||||
private final String TAG = UnityCommandController.class.getSimpleName();
|
||||
private final String BLE_DISCONNECT_NOTITY = "BLEDisconnectNotity";
|
||||
private final String JS_SHOW_EXCEPTION = "JsShowException";
|
||||
private final String COMMON_TIPS = "CommonTips";
|
||||
private final String CHARGE_PROTECTED = "ChargeProtected";
|
||||
private final String LOGIC_CMD_RESULT = "LogicCMDResult";
|
||||
private final String BLUE_SETTING = "OpenAndroidBLESetting";
|
||||
private final String CANCEL_WAIT_DIALOG = "JsExceptionWaitResult";
|
||||
private final String SUCCESS = CourseResult.SUCCESS;
|
||||
private boolean open = false;
|
||||
private boolean isBlocklyRunning = false;
|
||||
|
||||
public UnityCommandController(UnityActivity unityActivity) {
|
||||
this.activity = unityActivity;
|
||||
this.managerHelper = new ManagerHelper(this.activity);
|
||||
this.am = (AudioManager) unityActivity.getSystemService("audio");
|
||||
}
|
||||
|
||||
private void SetSendXTState(int i) {
|
||||
if (this.connenctDevice != null) {
|
||||
BluetoothProxy.c().a(this.connenctDevice, i == 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void bleState(String str) {
|
||||
}
|
||||
|
||||
private void blocklyResult(String str, int i, String str2, String str3) {
|
||||
DialogBlocklyWebView dialogBlocklyWebView = this.blockly;
|
||||
if (dialogBlocklyWebView != null) {
|
||||
dialogBlocklyWebView.wakeupBlockly(str, i, str2, str3);
|
||||
}
|
||||
}
|
||||
|
||||
private void chargeProtected(String str) {
|
||||
DialogBlocklyWebView dialogBlocklyWebView = this.blockly;
|
||||
if (dialogBlocklyWebView != null) {
|
||||
dialogBlocklyWebView.chargeProtected(str);
|
||||
}
|
||||
}
|
||||
|
||||
private void commonTips(String str) {
|
||||
JimuRobotMessage jimuRobotMessage = (JimuRobotMessage) JsonHelper.a(str, (Class<?>) JimuRobotMessage.class);
|
||||
if (this.blockly == null) {
|
||||
this.activity.showToast(jimuRobotMessage);
|
||||
} else {
|
||||
EventBus.b().b(new BlocklyEvent(1001, jimuRobotMessage));
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteProgram(String str) {
|
||||
XLog.a(this.TAG, "删除案例");
|
||||
}
|
||||
|
||||
private String formatResult(String str) {
|
||||
QueryResult queryResult = (QueryResult) JsonHelper.a(str, (Class<?>) QueryResult.class);
|
||||
if (queryResult == null) {
|
||||
return null;
|
||||
}
|
||||
List<JimuSensor> infrared = queryResult.getInfrared();
|
||||
if (infrared != null) {
|
||||
for (JimuSensor jimuSensor : infrared) {
|
||||
jimuSensor.setResult(JimuSensor.convertInfraredValueToLevel2(jimuSensor.getResult()));
|
||||
}
|
||||
}
|
||||
String a = JsonHelper.a(queryResult);
|
||||
SensorObservable.getInstance().setData(queryResult);
|
||||
return a;
|
||||
}
|
||||
|
||||
private void initCompactSensorEventListener() {
|
||||
if (this.compactListener == null) {
|
||||
this.compactListener = new DirectionSensorEventListerCompact(new DirectionSensorEventListerCompact.ActionListener() { // from class: com.ubt.jimu.blockly.command.UnityCommandController.3
|
||||
@Override // com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact.ActionListener
|
||||
public void onBottomUp() {
|
||||
if (UnityCommandController.this.blockly != null) {
|
||||
UnityCommandController.this.blockly.refreshDirection(DeviceDirection.DOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact.ActionListener
|
||||
public void onChange(float[] fArr) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact.ActionListener
|
||||
public void onLeftUp() {
|
||||
if (UnityCommandController.this.blockly != null) {
|
||||
UnityCommandController.this.blockly.refreshDirection(DeviceDirection.LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact.ActionListener
|
||||
public void onNormal() {
|
||||
if (UnityCommandController.this.blockly != null) {
|
||||
UnityCommandController.this.blockly.refreshDirection(DeviceDirection.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact.ActionListener
|
||||
public void onRightUp() {
|
||||
if (UnityCommandController.this.blockly != null) {
|
||||
UnityCommandController.this.blockly.refreshDirection(DeviceDirection.RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact.ActionListener
|
||||
public void onShake(long j, float[] fArr) {
|
||||
if (UnityCommandController.this.blockly != null) {
|
||||
UnityCommandController.this.blockly.refreshDirection(DeviceDirection.SWING);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.feature.sensor.DirectionSensorEventListerCompact.ActionListener
|
||||
public void onTopUp() {
|
||||
if (UnityCommandController.this.blockly != null) {
|
||||
UnityCommandController.this.blockly.refreshDirection(DeviceDirection.UP);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
this.managerHelper.registerListener(this.compactListener, 1, 3);
|
||||
}
|
||||
|
||||
private void notifyBleState(String str) {
|
||||
DialogBlocklyWebView dialogBlocklyWebView = this.blockly;
|
||||
if (dialogBlocklyWebView != null) {
|
||||
dialogBlocklyWebView.blueConnectCallBack(str);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
private void onBlocklyResult(String str) {
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(str);
|
||||
String string = jSONObject.getString(UnityActivity.RESULT);
|
||||
String replace = jSONObject.getString("cmd").replace(BlocklyCommandController.BASE_REQUEST_URL, "");
|
||||
String[] split = replace.split("\\|");
|
||||
int i = 1;
|
||||
i = 1;
|
||||
JSONObject jSONObject2 = new JSONObject(split[split.length - 1]);
|
||||
if (BlocklyCommandController.QUERY.equals(split[0])) {
|
||||
JSONObject jSONObject3 = new JSONObject(string);
|
||||
String string2 = jSONObject3.has("state") ? jSONObject3.getString("state") : "";
|
||||
string = (jSONObject3.has(UnityActivity.RESULT) ? jSONObject3.getInt(UnityActivity.RESULT) : 1) == 0 ? RESULT_FAILED : RESULT_SUCCESS;
|
||||
i = CourseResult.SUCCESS.equals(string2);
|
||||
} else if ("queryRobotStatus".equals(split[0])) {
|
||||
JSONObject jSONObject4 = new JSONObject(string);
|
||||
if (jSONObject4.has("state")) {
|
||||
i = jSONObject4.optInt("state");
|
||||
}
|
||||
} else if (TextUtils.isEmpty(string) || !string.contains(CourseResult.SUCCESS)) {
|
||||
i = 0;
|
||||
}
|
||||
blocklyResult(jSONObject2.getString("branchId"), i, replace, string);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void onDirectionResult(JSONObject jSONObject, String[] strArr) {
|
||||
try {
|
||||
JSONObject jSONObject2 = new JSONObject();
|
||||
int i = 0;
|
||||
if (!this.compactListener.directionNotChange()) {
|
||||
String string = new JSONObject(strArr[1]).getString("direction");
|
||||
if (DeviceDirection.SWING.getValue().equals(string)) {
|
||||
if (!this.compactListener.isShaking()) {
|
||||
}
|
||||
i = 1;
|
||||
} else {
|
||||
DeviceDirection deviceDirection = this.compactListener.getDeviceDirection();
|
||||
if (deviceDirection != null) {
|
||||
if (!deviceDirection.getValue().equals(string)) {
|
||||
}
|
||||
i = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
jSONObject2.put("state", CourseResult.SUCCESS);
|
||||
jSONObject2.put(UnityActivity.RESULT, i);
|
||||
jSONObject.put(UnityActivity.RESULT, jSONObject2.toString());
|
||||
onBlocklyResult(jSONObject.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void onInfraredTimerResult(JSONObject jSONObject, String str) {
|
||||
try {
|
||||
if (jSONObject.has(UnityActivity.RESULT)) {
|
||||
String string = jSONObject.getString(UnityActivity.RESULT);
|
||||
if (TextUtils.isEmpty(string)) {
|
||||
return;
|
||||
}
|
||||
String[] split = string.split("\\|");
|
||||
if (split.length <= 1 || !CourseResult.SUCCESS.equals(split[0])) {
|
||||
return;
|
||||
}
|
||||
this.blockly.showInfraredRef(formatResult(split[1]), str);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(this.TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void onLogicCMDResult(String str) {
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(str);
|
||||
String string = jSONObject.getString(UnityActivity.RESULT);
|
||||
String[] split = jSONObject.getString("cmd").replace(BlocklyCommandController.BASE_REQUEST_URL, "").split("\\|");
|
||||
if ("failure".equals(string) && !BlocklyCommandController.QUERY_ALL_SENSOR.equals(split[0])) {
|
||||
onBlocklyResult(str);
|
||||
return;
|
||||
}
|
||||
if (split[0].equals(BlocklyCommandController.QUERY) && split[1].contains("direction")) {
|
||||
onDirectionResult(jSONObject, split);
|
||||
} else if (BlocklyCommandController.QUERY_ALL_SENSOR.equals(split[0])) {
|
||||
onInfraredTimerResult(jSONObject, split.length >= 2 ? split[2] : "");
|
||||
} else {
|
||||
onBlocklyResult(str);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public synchronized void open(String str) {
|
||||
if (this.isBlocklyRunning) {
|
||||
return;
|
||||
}
|
||||
int i = new SharePreferenceHelper().getInt(SharePreferenceHelper.SP_KEY_CONNECTION_STATUS, ConnectionStatus.DIS_CONNECT.getStatus());
|
||||
if (this.blockly == null) {
|
||||
this.blockly = DialogBlocklyWebView.getInstance(str, i, this.serverModelId, this.moduleType, this.code, this.activity.size, this.course);
|
||||
register();
|
||||
}
|
||||
if (this.activity.getFragmentManager().findFragmentByTag(FRAGMENT_TAG_BLOCKLY) == null) {
|
||||
if (this.blockly.isAdded()) {
|
||||
XLog.a(this.TAG, "show blockly");
|
||||
this.activity.getFragmentManager().beginTransaction().show(this.blockly).commit();
|
||||
} else {
|
||||
XLog.a(this.TAG, "add blockly");
|
||||
this.activity.getFragmentManager().beginTransaction().add(R.id.content, this.blockly, FRAGMENT_TAG_BLOCKLY).commit();
|
||||
}
|
||||
} else if (TextUtils.isEmpty(str)) {
|
||||
UnityActivity.communityWithUnity(this.activity, JimuBlocklyCommand.EXIT_LOGIC_VIEW, "");
|
||||
return;
|
||||
} else {
|
||||
XLog.a(this.TAG, "show blockly");
|
||||
this.blockly.updateJimuRobot(str);
|
||||
this.activity.getFragmentManager().beginTransaction().show(this.blockly).commit();
|
||||
}
|
||||
this.isBlocklyRunning = true;
|
||||
}
|
||||
|
||||
private synchronized void openBlockly(final String str) {
|
||||
if (new File((ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "data/blockly/") + Utils.BLOCKLY_NEW + File.separator + "teachMaterial/index.html").exists()) {
|
||||
open(str);
|
||||
} else {
|
||||
Utils.unZipBlockly(new Utils.IUnzipBlockly() { // from class: com.ubt.jimu.blockly.command.UnityCommandController.1
|
||||
@Override // com.ubt.jimu.blockly.Utils.IUnzipBlockly
|
||||
public void unZipFailed() {
|
||||
XLog.b(UnityCommandController.this.TAG, "openBlockly unZipFailed 无法解压Blockly到指定目录");
|
||||
UnityActivity.communityWithUnity(UnityCommandController.this.activity, JimuBlocklyCommand.EXIT_LOGIC_VIEW, "");
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.Utils.IUnzipBlockly
|
||||
public void unZipSuccessed() {
|
||||
UnityCommandController.this.open(str);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.am.requestAudioFocus(new AudioManager.OnAudioFocusChangeListener() { // from class: com.ubt.jimu.blockly.command.UnityCommandController.2
|
||||
@Override // android.media.AudioManager.OnAudioFocusChangeListener
|
||||
public void onAudioFocusChange(int i) {
|
||||
XLog.a(UnityCommandController.this.TAG, "audiomanager focusChange.");
|
||||
}
|
||||
}, 3, 2);
|
||||
}
|
||||
|
||||
private void register() {
|
||||
initCompactSensorEventListener();
|
||||
}
|
||||
|
||||
private void showException(String str) {
|
||||
XLog.b(this.TAG, "showException:" + str);
|
||||
if (this.blockly != null) {
|
||||
EventBus.b().b(new BlocklyEvent(1002, str));
|
||||
}
|
||||
}
|
||||
|
||||
private void unRegister() {
|
||||
this.managerHelper.unRegisterListener(this.compactListener);
|
||||
}
|
||||
|
||||
public void blocklyCallUnity(String str) {
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(str);
|
||||
String string = jSONObject.has("funcName") ? jSONObject.getString("funcName") : null;
|
||||
if (JimuBlocklyCommand.EXIT_LOGIC_VIEW.equals(string)) {
|
||||
this.open = false;
|
||||
closeBlockly();
|
||||
unRegister();
|
||||
this.activity.setIsBack(true);
|
||||
return;
|
||||
}
|
||||
if (JimuBlocklyCommand.CONNECT_BLE.equals(string)) {
|
||||
hideBlockly();
|
||||
return;
|
||||
}
|
||||
if (JimuBlocklyCommand.BLE_STATE.equals(string)) {
|
||||
if (TextUtils.isEmpty(this.connenctDevice)) {
|
||||
bleState("0");
|
||||
return;
|
||||
} else {
|
||||
bleState("1");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (JimuBlocklyCommand.SET_SEND_XT_STATE.equals(string)) {
|
||||
SetSendXTState(Integer.parseInt(jSONObject.getString("arg")));
|
||||
} else if ("setServoMode".equals(string)) {
|
||||
hideBlockly();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(this.TAG, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeBlockly() {
|
||||
XLog.a(this.TAG, "close blockly");
|
||||
this.isBlocklyRunning = false;
|
||||
this.open = false;
|
||||
if (this.blockly != null) {
|
||||
synchronized (this) {
|
||||
if (this.blockly != null) {
|
||||
this.blockly.stopQueryTimer();
|
||||
this.activity.getFragmentManager().beginTransaction().remove(this.blockly).commit();
|
||||
this.blockly = null;
|
||||
XLog.a(this.TAG, "销毁 DilogBlocklyWebview");
|
||||
}
|
||||
}
|
||||
}
|
||||
this.am.abandonAudioFocus(null);
|
||||
}
|
||||
|
||||
public synchronized void hideBlockly() {
|
||||
if (this.blockly != null) {
|
||||
this.isBlocklyRunning = false;
|
||||
this.activity.getFragmentManager().beginTransaction().hide(this.blockly).commit();
|
||||
XLog.a(this.TAG, "隐藏 DilogBlocklyWebview");
|
||||
}
|
||||
}
|
||||
|
||||
public void loadJavascript(String str, String... strArr) {
|
||||
DialogBlocklyWebView dialogBlocklyWebView = this.blockly;
|
||||
if (dialogBlocklyWebView == null) {
|
||||
return;
|
||||
}
|
||||
dialogBlocklyWebView.setJSResult(str, strArr);
|
||||
}
|
||||
|
||||
public void notifyConnectionState(String str) {
|
||||
if (this.blockly != null && StringUtils.f(str)) {
|
||||
this.blockly.setJSResult("BLEStateChanged", str);
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyKeyboardHidden(String str) {
|
||||
DialogBlocklyWebView dialogBlocklyWebView = this.blockly;
|
||||
if (dialogBlocklyWebView == null || !this.isBlocklyRunning) {
|
||||
return;
|
||||
}
|
||||
dialogBlocklyWebView.notifyKeyboardHidden(str);
|
||||
}
|
||||
|
||||
public boolean onUnityCallback(String str, String str2) {
|
||||
if ("CommonTips".equals(str)) {
|
||||
commonTips(str2);
|
||||
}
|
||||
if (!this.open && !OPEN_LOGIC_PROGRAMMING.equals(str)) {
|
||||
return false;
|
||||
}
|
||||
if (OPEN_LOGIC_PROGRAMMING.equals(str)) {
|
||||
this.open = true;
|
||||
openBlockly(str2);
|
||||
} else if ("ConnectBLECallBack".equals(str)) {
|
||||
openBlockly(str2);
|
||||
notifyBleState(str2);
|
||||
} else if ("BLEDisconnectNotity".equals(str)) {
|
||||
notifyBleState("{\"blueState\":\"3\"}");
|
||||
notifyConnectionState("3");
|
||||
EventBus.b().b(new BlocklyEvent(1003, str2));
|
||||
} else if ("JsShowException".equals(str)) {
|
||||
showException(str2);
|
||||
} else if ("ChargeProtected".equals(str)) {
|
||||
chargeProtected(str2);
|
||||
} else if ("LogicCMDResult".equals(str)) {
|
||||
onLogicCMDResult(str2);
|
||||
} else if ("JsExceptionWaitResult".equals(str)) {
|
||||
this.blockly.hideWait();
|
||||
} else if ("OpenAndroidBLESetting".equals(str)) {
|
||||
this.activity.startActivity(new Intent("android.settings.BLUETOOTH_SETTINGS"));
|
||||
} else if ("refreshAllServo".equals(str)) {
|
||||
openRefreshAllServo(str2);
|
||||
} else {
|
||||
if (!"deleteProgram".equals(str)) {
|
||||
return false;
|
||||
}
|
||||
deleteProgram(str2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openRefreshAllServo(String str) {
|
||||
this.activity.getFragmentManager().beginTransaction().show(this.blockly).commit();
|
||||
this.blockly.refreshAllServo(str);
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(str);
|
||||
this.blockly.refreshAllServo(jSONObject.has("commonServo") ? jSONObject.getString("commonServo") : "", jSONObject.has("circleServo") ? jSONObject.getString("circleServo") : "");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCode(int i) {
|
||||
this.code = i;
|
||||
}
|
||||
|
||||
public void setConnenctDevice(String str) {
|
||||
try {
|
||||
this.connenctDevice = str;
|
||||
int status = (TextUtils.isEmpty(this.connenctDevice) ? ConnectionStatus.DIS_CONNECT : ConnectionStatus.CONNECTED).getStatus();
|
||||
if (this.blockly != null) {
|
||||
this.blockly.setBlueState(status);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(this.TAG, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setCourse(Course course) {
|
||||
this.course = course;
|
||||
}
|
||||
|
||||
public void setModuleType(int i) {
|
||||
this.moduleType = i;
|
||||
}
|
||||
|
||||
public void setServerModelId(long j) {
|
||||
this.serverModelId = j;
|
||||
}
|
||||
|
||||
public synchronized void showBlockly() {
|
||||
if (this.blockly != null) {
|
||||
this.activity.getFragmentManager().beginTransaction().show(this.blockly).commit();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopBlockly() {
|
||||
DialogBlocklyWebView dialogBlocklyWebView = this.blockly;
|
||||
if (dialogBlocklyWebView == null) {
|
||||
return;
|
||||
}
|
||||
dialogBlocklyWebView.jsShowException("EnterBackground");
|
||||
}
|
||||
|
||||
public void updateBluetoothState(String str) {
|
||||
if (this.blockly != null && TextUtils.isDigitsOnly(str)) {
|
||||
this.blockly.setBlueState(Integer.valueOf(str).intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ubt.jimu.blockly.command.interaction;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class AbstractBlocklyInteraction {
|
||||
public void addBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
}
|
||||
|
||||
public void addJimuMotion(JimuMotion jimuMotion) {
|
||||
}
|
||||
|
||||
public void addJimuSound(JimuSound jimuSound, File file) {
|
||||
}
|
||||
|
||||
public void deleteBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
}
|
||||
|
||||
public void deleteJimuMotion(JimuMotion jimuMotion) {
|
||||
}
|
||||
|
||||
public void deleteJimuSound(JimuSound jimuSound, File file) {
|
||||
}
|
||||
|
||||
public void renameBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
}
|
||||
|
||||
public void renameJimuMotion(JimuMotion jimuMotion) {
|
||||
}
|
||||
|
||||
public void renameJimuSound(JimuSound jimuSound) {
|
||||
}
|
||||
|
||||
public void updateBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.ubt.jimu.blockly.command.interaction;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyInteraction extends AbstractBlocklyInteraction {
|
||||
private AbstractBlocklyInteraction[] listeners;
|
||||
|
||||
public BlocklyInteraction(AbstractBlocklyInteraction... abstractBlocklyInteractionArr) {
|
||||
if (abstractBlocklyInteractionArr == null || abstractBlocklyInteractionArr.length == 0) {
|
||||
this.listeners = new AbstractBlocklyInteraction[0];
|
||||
} else {
|
||||
this.listeners = abstractBlocklyInteractionArr;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
super.addBlocklyProject(blocklyProject, file);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.addBlocklyProject(blocklyProject, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addJimuMotion(JimuMotion jimuMotion) {
|
||||
super.addJimuMotion(jimuMotion);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.addJimuMotion(jimuMotion);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addJimuSound(JimuSound jimuSound, File file) {
|
||||
super.addJimuSound(jimuSound, file);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.addJimuSound(jimuSound, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
super.deleteBlocklyProject(blocklyProject, file);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.deleteBlocklyProject(blocklyProject, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteJimuMotion(JimuMotion jimuMotion) {
|
||||
super.deleteJimuMotion(jimuMotion);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.deleteJimuMotion(jimuMotion);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteJimuSound(JimuSound jimuSound, File file) {
|
||||
super.deleteJimuSound(jimuSound, file);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.deleteJimuSound(jimuSound, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
super.renameBlocklyProject(blocklyProject, file);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.renameBlocklyProject(blocklyProject, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameJimuMotion(JimuMotion jimuMotion) {
|
||||
super.renameJimuMotion(jimuMotion);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.renameJimuMotion(jimuMotion);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameJimuSound(JimuSound jimuSound) {
|
||||
super.renameJimuSound(jimuSound);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.renameJimuSound(jimuSound);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void updateBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
super.updateBlocklyProject(blocklyProject, file);
|
||||
for (AbstractBlocklyInteraction abstractBlocklyInteraction : this.listeners) {
|
||||
try {
|
||||
abstractBlocklyInteraction.updateBlocklyProject(blocklyProject, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.ubt.jimu.blockly.command.interaction;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuMotionDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuSoundDbHandler;
|
||||
import com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.DownloadSoundListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.JimuMotionHttpListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.RenameHttpListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.UploadBlocklyHttpListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.UploadJimuSoundHttpListener;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyUpload extends AbstractBlocklyInteraction implements RenameHttpListener, UploadBlocklyHttpListener, UploadJimuSoundHttpListener, DownloadSoundListener, JimuMotionHttpListener {
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
if (blocklyProject == null || file == null) {
|
||||
return;
|
||||
}
|
||||
blocklyProject.setLocalFilePath(file.getAbsolutePath());
|
||||
BlocklySyncHttpImpl.getInstance().setUploadBlocklyHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().prepareUploadBlockly(BlocklyUploadType.ADD_TYPE, blocklyProject);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addJimuMotion(JimuMotion jimuMotion) {
|
||||
BlocklySyncHttpImpl.getInstance().setJimuMotionHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().syncJimuMotionToUbtService(BlocklyUploadType.ADD_TYPE, jimuMotion);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addJimuSound(JimuSound jimuSound, File file) {
|
||||
jimuSound.setLocalFilePath(file.getAbsolutePath());
|
||||
BlocklySyncHttpImpl.getInstance().setUploadJimuSoundHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().prepareUploadJimuSound(BlocklyUploadType.ADD_TYPE, jimuSound);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
BlocklyProjectDbHandler.getInstance().setDeleteState(blocklyProject.getXmlId(), true);
|
||||
BlocklySyncHttpImpl.getInstance().setUploadBlocklyHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().syncDataToUbtHttp(BlocklyUploadType.DELETE_TYPE, BlocklySyncHttpImpl.getInstance().getBlocklyProjectParameterFromProject(blocklyProject));
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteJimuMotion(JimuMotion jimuMotion) {
|
||||
BlocklySyncHttpImpl.getInstance().setJimuMotionHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().syncJimuMotionToUbtService(BlocklyUploadType.DELETE_TYPE, jimuMotion);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteJimuSound(JimuSound jimuSound, File file) {
|
||||
jimuSound.setLocalFilePath(file.getAbsolutePath());
|
||||
BlocklySyncHttpImpl.getInstance().setUploadJimuSoundHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().syncJimuSoundToUbtService(BlocklyUploadType.DELETE_TYPE, jimuSound);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.DownloadSoundListener
|
||||
public void downloadSoundFaulted(JimuSound jimuSound) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.DownloadSoundListener
|
||||
public void downloadSoundSucceed(JimuSound jimuSound) {
|
||||
JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
jimuSoundDbHandler.updateQiNiuSyncState(jimuSound, true);
|
||||
jimuSoundDbHandler.updateJimuSoundUbtServiceState(jimuSound, true);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
if (blocklyProject == null) {
|
||||
return;
|
||||
}
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId) || "local".equals(userId)) {
|
||||
return;
|
||||
}
|
||||
BlocklySyncHttpImpl.getInstance().setRenameHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().blocklyRenameSyncHttp(blocklyProject);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.RenameHttpListener
|
||||
public void renameHttpFaulted(BlocklyProject blocklyProject) {
|
||||
BlocklyProjectDbHandler.getInstance().updateBlocklyState(blocklyProject.getXmlId(), true);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.RenameHttpListener
|
||||
public void renameHttpSucceed(BlocklyProject blocklyProject) {
|
||||
BlocklyProjectDbHandler.getInstance().updateBlocklyState(blocklyProject.getXmlId(), false);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameJimuMotion(JimuMotion jimuMotion) {
|
||||
BlocklySyncHttpImpl.getInstance().setJimuMotionHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().syncJimuMotionToUbtService(BlocklyUploadType.UPDATE_TYPE, jimuMotion);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameJimuSound(JimuSound jimuSound) {
|
||||
BlocklySyncHttpImpl.getInstance().setUploadJimuSoundHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().syncJimuSoundToUbtService(BlocklyUploadType.UPDATE_TYPE, jimuSound);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadBlocklyHttpListener
|
||||
public void syncDataToUbtHttpFaulted(BlocklyProject blocklyProject, BlocklyUploadType blocklyUploadType) {
|
||||
if (blocklyUploadType == BlocklyUploadType.UPDATE_TYPE || BlocklyUploadType.ADD_TYPE == blocklyUploadType) {
|
||||
BlocklyProjectDbHandler.getInstance().setServiceUplaodState(blocklyProject.getXmlId(), false);
|
||||
} else if (blocklyUploadType == BlocklyUploadType.DELETE_TYPE) {
|
||||
BlocklyProjectDbHandler.getInstance().setDeleteState(blocklyProject.getXmlId(), true);
|
||||
BlocklyProjectDbHandler.getInstance().setServiceUplaodState(blocklyProject.getXmlId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadBlocklyHttpListener
|
||||
public void syncDataToUbtHttpSucceed(BlocklyProject blocklyProject, BlocklyUploadType blocklyUploadType) {
|
||||
if (blocklyUploadType == BlocklyUploadType.ADD_TYPE || blocklyUploadType == BlocklyUploadType.UPDATE_TYPE) {
|
||||
BlocklyProjectDbHandler.getInstance().setServiceUplaodState(blocklyProject.getXmlId(), true);
|
||||
BlocklyProjectDbHandler.getInstance().setsetModifyState(blocklyProject.getXmlId(), false);
|
||||
BlocklyProjectDbHandler.getInstance().isFirs(blocklyProject.getXmlId(), 1);
|
||||
} else if (blocklyUploadType == BlocklyUploadType.DELETE_TYPE) {
|
||||
BlocklyProjectDbHandler.getInstance().deleteBlocklyProject(blocklyProject.getXmlId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadJimuSoundHttpListener
|
||||
public void syncToUbtServiceFaulted(BlocklyUploadType blocklyUploadType, JimuSound jimuSound) {
|
||||
JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
if (blocklyUploadType == BlocklyUploadType.ADD_TYPE || blocklyUploadType == BlocklyUploadType.UPDATE_TYPE) {
|
||||
jimuSoundDbHandler.updateJimuSoundUbtServiceState(jimuSound, false);
|
||||
} else if (blocklyUploadType == BlocklyUploadType.DELETE_TYPE) {
|
||||
jimuSoundDbHandler.uploadDeleteState(jimuSound, true);
|
||||
jimuSoundDbHandler.updateJimuSoundUbtServiceState(jimuSound, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadJimuSoundHttpListener
|
||||
public void syncToUbtServiceSucceed(BlocklyUploadType blocklyUploadType, JimuSound jimuSound) {
|
||||
JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
if (blocklyUploadType == BlocklyUploadType.ADD_TYPE || blocklyUploadType == BlocklyUploadType.UPDATE_TYPE) {
|
||||
jimuSoundDbHandler.updateJimuSoundUbtServiceState(jimuSound, true);
|
||||
} else if (blocklyUploadType == BlocklyUploadType.DELETE_TYPE) {
|
||||
jimuSoundDbHandler.deleteJimuSound(jimuSound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void updateBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
if (blocklyProject == null) {
|
||||
return;
|
||||
}
|
||||
BlocklySyncHttpImpl.getInstance().setUploadBlocklyHttpListener(this);
|
||||
BlocklySyncHttpImpl.getInstance().prepareUploadBlockly(BlocklyUploadType.UPDATE_TYPE, blocklyProject);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadBlocklyHttpListener
|
||||
public void uploadBlocklyToQiNiuFaulted(BlocklyProject blocklyProject) {
|
||||
BlocklyProjectDbHandler.getInstance().setQiNiuUplaodState(blocklyProject.getXmlId(), false);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadBlocklyHttpListener
|
||||
public void uploadBlocklyToQiNiuSucceed(BlocklyProject blocklyProject) {
|
||||
BlocklyProjectDbHandler.getInstance().setQiNiuUplaodState(blocklyProject.getXmlId(), true);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadJimuSoundHttpListener
|
||||
public void uploadJimuSoundToQiNiuFaulted(BlocklyUploadType blocklyUploadType, JimuSound jimuSound) {
|
||||
new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p()).updateQiNiuSyncState(jimuSound, false);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.UploadJimuSoundHttpListener
|
||||
public void uploadJimuSoundToQiNiuSucceed(BlocklyUploadType blocklyUploadType, JimuSound jimuSound) {
|
||||
JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
if (blocklyUploadType == BlocklyUploadType.ADD_TYPE) {
|
||||
jimuSoundDbHandler.updateQiNiuSyncState(jimuSound, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.JimuMotionHttpListener
|
||||
public void uploadMotionToUbtServiceFaulted(BlocklyUploadType blocklyUploadType, JimuMotion jimuMotion) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.JimuMotionHttpListener
|
||||
public void uploadMotionToUbtServiceSucceed(BlocklyUploadType blocklyUploadType, JimuMotion jimuMotion) {
|
||||
JimuMotionDbHandler jimuMotionDbHandler = new JimuMotionDbHandler(DatabaseUtils.getDaoSession(true).o());
|
||||
if (blocklyUploadType != BlocklyUploadType.ADD_TYPE && blocklyUploadType != BlocklyUploadType.UPDATE_TYPE) {
|
||||
jimuMotionDbHandler.deleteJimuMotionByModeelId(jimuMotion.getActionID());
|
||||
return;
|
||||
}
|
||||
jimuMotion.setIsFirst(1);
|
||||
jimuMotion.setIsUploadService(true);
|
||||
jimuMotionDbHandler.insertOrUpdate(jimuMotion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ubt.jimu.blockly.command.interaction;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum BlocklyUploadType {
|
||||
ADD_TYPE,
|
||||
UPDATE_TYPE,
|
||||
DELETE_TYPE
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.ubt.jimu.blockly.command.interaction;
|
||||
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.transport.Transporter;
|
||||
import com.ubt.jimu.transport.dao.ConfigItemDbHandler;
|
||||
import com.ubt.jimu.transport.model.ConfigItem;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class TransportBlocklyInteraction extends AbstractBlocklyInteraction {
|
||||
private final String TAG = TransportBlocklyInteraction.class.getSimpleName();
|
||||
private ConfigItemDbHandler configItemDbHandler = new ConfigItemDbHandler(DatabaseUtils.getDaoSession(true).b());
|
||||
private JimuRobot jimuRobot;
|
||||
|
||||
public TransportBlocklyInteraction(JimuRobot jimuRobot) {
|
||||
this.jimuRobot = jimuRobot;
|
||||
}
|
||||
|
||||
private void uploadConfigItem(String str, ConfigItem configItem) {
|
||||
Transporter.b().a(str, configItem);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
super.addBlocklyProject(blocklyProject, file);
|
||||
if (blocklyProject == null) {
|
||||
return;
|
||||
}
|
||||
ConfigItem fromBlocklyProject = ConfigItem.fromBlocklyProject(blocklyProject);
|
||||
fromBlocklyProject.setFileModifyTime(SystemUtils.a());
|
||||
fromBlocklyProject.setIsDeleted("0");
|
||||
fromBlocklyProject.setIsModify(true);
|
||||
ConfigItem selectById = this.configItemDbHandler.selectById(Long.valueOf(this.configItemDbHandler.insert(fromBlocklyProject)));
|
||||
Transporter.b().a(this.jimuRobot.getServerModelId(), this.jimuRobot.getModelId(), this.jimuRobot.getServerModelType(), file);
|
||||
uploadConfigItem("add", selectById);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addJimuMotion(JimuMotion jimuMotion) {
|
||||
super.addJimuMotion(jimuMotion);
|
||||
ConfigItem fromJimuMotion = ConfigItem.fromJimuMotion(jimuMotion);
|
||||
fromJimuMotion.setIsModify(true);
|
||||
fromJimuMotion.setIsDeleted("0");
|
||||
ConfigItem selectById = this.configItemDbHandler.selectById(Long.valueOf(this.configItemDbHandler.insert(fromJimuMotion)));
|
||||
if (selectById == null) {
|
||||
return;
|
||||
}
|
||||
uploadConfigItem("add", selectById);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void addJimuSound(JimuSound jimuSound, File file) {
|
||||
ConfigItem fromJimuSound;
|
||||
super.addJimuSound(jimuSound, file);
|
||||
if (jimuSound == null || (fromJimuSound = ConfigItem.fromJimuSound(jimuSound)) == null) {
|
||||
return;
|
||||
}
|
||||
fromJimuSound.setIsModify(true);
|
||||
fromJimuSound.setIsDeleted("0");
|
||||
uploadConfigItem("add", this.configItemDbHandler.selectById(Long.valueOf(this.configItemDbHandler.insert(fromJimuSound))));
|
||||
Transporter.b().a(Long.parseLong("0"), "0", "0", file);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
ConfigItem a;
|
||||
super.deleteBlocklyProject(blocklyProject, file);
|
||||
if (blocklyProject == null || (a = this.configItemDbHandler.a(blocklyProject)) == null) {
|
||||
return;
|
||||
}
|
||||
if (!"0000".equals(a.getServerID())) {
|
||||
this.configItemDbHandler.delete(a);
|
||||
return;
|
||||
}
|
||||
this.configItemDbHandler.c(a);
|
||||
uploadConfigItem("delete", a);
|
||||
Transporter.b().a(file);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteJimuMotion(JimuMotion jimuMotion) {
|
||||
super.deleteJimuMotion(jimuMotion);
|
||||
ConfigItem a = this.configItemDbHandler.a(jimuMotion);
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
if (!"0000".equals(a.getServerID())) {
|
||||
this.configItemDbHandler.delete(a);
|
||||
} else {
|
||||
this.configItemDbHandler.c(a);
|
||||
uploadConfigItem("delete", a);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void deleteJimuSound(JimuSound jimuSound, File file) {
|
||||
ConfigItem a;
|
||||
super.deleteJimuSound(jimuSound, file);
|
||||
if (jimuSound == null || (a = this.configItemDbHandler.a(jimuSound)) == null) {
|
||||
return;
|
||||
}
|
||||
if (!"0000".equals(a.getServerID())) {
|
||||
this.configItemDbHandler.delete(a);
|
||||
return;
|
||||
}
|
||||
this.configItemDbHandler.c(a);
|
||||
uploadConfigItem("delete", a);
|
||||
Transporter.b().a(file);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
ConfigItem a;
|
||||
super.renameBlocklyProject(blocklyProject, file);
|
||||
if (blocklyProject == null || (a = this.configItemDbHandler.a(blocklyProject)) == null) {
|
||||
return;
|
||||
}
|
||||
a.setFileModifyTime(SystemUtils.a());
|
||||
a.setIsModify(true);
|
||||
a.setDescription(blocklyProject.getXmlName());
|
||||
this.configItemDbHandler.update(a);
|
||||
uploadConfigItem("update", a);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameJimuMotion(JimuMotion jimuMotion) {
|
||||
super.renameJimuMotion(jimuMotion);
|
||||
ConfigItem a = this.configItemDbHandler.a(jimuMotion);
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
a.setDescription(jimuMotion.getActionName());
|
||||
a.setIsModify(true);
|
||||
this.configItemDbHandler.update(a);
|
||||
uploadConfigItem("update", a);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void renameJimuSound(JimuSound jimuSound) {
|
||||
ConfigItem a;
|
||||
super.renameJimuSound(jimuSound);
|
||||
if (jimuSound == null || (a = this.configItemDbHandler.a(jimuSound)) == null) {
|
||||
return;
|
||||
}
|
||||
a.setFileModifyTime(SystemUtils.a());
|
||||
a.setDescription(jimuSound.getDescription());
|
||||
a.setIsModify(true);
|
||||
this.configItemDbHandler.update(a);
|
||||
uploadConfigItem("update", a);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.blockly.command.interaction.AbstractBlocklyInteraction
|
||||
public void updateBlocklyProject(BlocklyProject blocklyProject, File file) {
|
||||
ConfigItem a;
|
||||
super.updateBlocklyProject(blocklyProject, file);
|
||||
if (blocklyProject == null || (a = this.configItemDbHandler.a(blocklyProject)) == null) {
|
||||
return;
|
||||
}
|
||||
a.setFileModifyTime(SystemUtils.a());
|
||||
a.setIsModify(true);
|
||||
this.configItemDbHandler.update(a);
|
||||
uploadConfigItem("update", a);
|
||||
Transporter.b().b(file);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ubt.jimu.blockly.command.result;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JavaResultBean<T> {
|
||||
public static final String RESULT_EXCEPTION = "0011";
|
||||
public static final String RESULT_FAILED = "0022";
|
||||
public static final String RESULT_NAME = "0001";
|
||||
public static final String RESULT_SUCCESS = "0000";
|
||||
public T result;
|
||||
public String retCode;
|
||||
public String retMsg;
|
||||
|
||||
public JavaResultBean() {
|
||||
}
|
||||
|
||||
public JavaResultBean(String str, String str2, T t) {
|
||||
this.retCode = str;
|
||||
this.retMsg = str2;
|
||||
this.result = t;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ubt.jimu.blockly.command.result;
|
||||
|
||||
import com.ubt.jimu.blockly.feature.blockly.JimuAction;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuActionList {
|
||||
public List<JimuAction> degree;
|
||||
public List<JimuAction> distance;
|
||||
public List<JimuAction> time;
|
||||
}
|
||||
59
sources/com/ubt/jimu/blockly/command/result/QueryResult.java
Normal file
59
sources/com/ubt/jimu/blockly/command/result/QueryResult.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.ubt.jimu.blockly.command.result;
|
||||
|
||||
import com.ubt.jimu.blockly.feature.blockly.ColorSensor;
|
||||
import com.ubt.jimu.blockly.feature.blockly.Gyroscope;
|
||||
import com.ubt.jimu.blockly.feature.blockly.JimuSensor;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class QueryResult {
|
||||
private List<ColorSensor> Color;
|
||||
private List<JimuSensor> DigitalTube;
|
||||
private List<JimuSensor> Gravity;
|
||||
private List<Gyroscope> Gyro;
|
||||
private List<JimuSensor> Infrared;
|
||||
private List<JimuSensor> Light;
|
||||
private List<JimuSensor> Phone;
|
||||
private List<JimuSensor> Touch;
|
||||
private List<JimuSensor> Ultrasonic;
|
||||
|
||||
public List<ColorSensor> getColor() {
|
||||
return this.Color;
|
||||
}
|
||||
|
||||
public List<JimuSensor> getDigitalTube() {
|
||||
return this.DigitalTube;
|
||||
}
|
||||
|
||||
public List<JimuSensor> getGravity() {
|
||||
return this.Gravity;
|
||||
}
|
||||
|
||||
public List<Gyroscope> getGyro() {
|
||||
return this.Gyro;
|
||||
}
|
||||
|
||||
public List<JimuSensor> getInfrared() {
|
||||
return this.Infrared;
|
||||
}
|
||||
|
||||
public List<JimuSensor> getLight() {
|
||||
return this.Light;
|
||||
}
|
||||
|
||||
public List<JimuSensor> getPhone() {
|
||||
return this.Phone;
|
||||
}
|
||||
|
||||
public List<JimuSensor> getTouch() {
|
||||
return this.Touch;
|
||||
}
|
||||
|
||||
public List<JimuSensor> getUltrasonic() {
|
||||
return this.Ultrasonic;
|
||||
}
|
||||
|
||||
public void setPhone(List<JimuSensor> list) {
|
||||
this.Phone = list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.ubt.jimu.blockly.command.result;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SaveBean {
|
||||
public String xmlId;
|
||||
}
|
||||
26
sources/com/ubt/jimu/blockly/command/result/XmlListBean.java
Normal file
26
sources/com/ubt/jimu/blockly/command/result/XmlListBean.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.ubt.jimu.blockly.command.result;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class XmlListBean {
|
||||
public String blocklyVersion;
|
||||
public boolean isDefault;
|
||||
public String type;
|
||||
public String xmlContent;
|
||||
public List<BlocklyProject> xmlList;
|
||||
|
||||
public XmlListBean(List<BlocklyProject> list) {
|
||||
this.xmlList = list;
|
||||
}
|
||||
|
||||
public XmlListBean(String str) {
|
||||
this.type = "newBlockly";
|
||||
this.xmlContent = str;
|
||||
}
|
||||
|
||||
public XmlListBean() {
|
||||
this.type = "newBlockly";
|
||||
}
|
||||
}
|
||||
457
sources/com/ubt/jimu/blockly/dao/BlocklyProjectDbHandler.java
Normal file
457
sources/com/ubt/jimu/blockly/dao/BlocklyProjectDbHandler.java
Normal file
@@ -0,0 +1,457 @@
|
||||
package com.ubt.jimu.blockly.dao;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.AbstractDaoHandler;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.diy.DiyRobotDbHandler;
|
||||
import com.ubt.jimu.gen.BlocklyProjectDao;
|
||||
import com.ubt.jimu.gen.TransportFileDao;
|
||||
import com.ubt.jimu.transport.Transporter;
|
||||
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
import org.greenrobot.greendao.query.WhereCondition;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyProjectDbHandler extends AbstractDaoHandler<BlocklyProject> {
|
||||
private static BlocklyProjectDbHandler blocklyProjectDbHandler;
|
||||
|
||||
public BlocklyProjectDbHandler(BlocklyProjectDao blocklyProjectDao) {
|
||||
super(blocklyProjectDao);
|
||||
}
|
||||
|
||||
public static synchronized BlocklyProjectDbHandler getInstance() {
|
||||
BlocklyProjectDbHandler blocklyProjectDbHandler2;
|
||||
synchronized (BlocklyProjectDbHandler.class) {
|
||||
if (blocklyProjectDbHandler == null) {
|
||||
blocklyProjectDbHandler = new BlocklyProjectDbHandler(DatabaseUtils.getDaoSession(true).a());
|
||||
}
|
||||
blocklyProjectDbHandler2 = blocklyProjectDbHandler;
|
||||
}
|
||||
return blocklyProjectDbHandler2;
|
||||
}
|
||||
|
||||
public static List<BlocklyProject> getProjects(String str, String str2, int i) {
|
||||
ArrayList arrayList;
|
||||
updateToVersion3(str, str2, i);
|
||||
BlocklyProjectDbHandler blocklyProjectDbHandler2 = new BlocklyProjectDbHandler(DatabaseUtils.getDaoSession(true).a());
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
if (i == ModelType.DEFAULT.getType()) {
|
||||
String str3 = ExternalOverFroyoUtils.a(JimuApplication.l(), ModelType.DEFAULT) + str2 + File.separator + str2 + Utils.BLOCKLY_ADD_PATH + File.separator + str2 + ".config";
|
||||
if (new File(str3).exists() && (arrayList = (ArrayList) JsonHelper.a(FileHelper.b(str3, ""), new TypeToken<List<BlocklyProject>>() { // from class: com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler.1
|
||||
}.getType())) != null && arrayList.size() > 0) {
|
||||
Iterator it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
((BlocklyProject) it.next()).setBlocklyType("newBlockly");
|
||||
}
|
||||
arrayList2.addAll(arrayList);
|
||||
}
|
||||
}
|
||||
List<BlocklyProject> blocklyProjects = blocklyProjectDbHandler2.getBlocklyProjects(str, String.valueOf(i), str2);
|
||||
if (blocklyProjects != null && blocklyProjects.size() > 0) {
|
||||
ArrayList arrayList3 = new ArrayList();
|
||||
String str4 = DiyRobotDbHandler.getCustomModelPath() + str2 + File.separator + str2;
|
||||
if (ModelType.DEFAULT.getType() == i) {
|
||||
str4 = DiyRobotDbHandler.getDefaultModelPath() + str2 + File.separator + str2;
|
||||
}
|
||||
for (BlocklyProject blocklyProject : blocklyProjects) {
|
||||
String str5 = str4 + File.separator + blocklyProject.getXmlId() + ".xml";
|
||||
if ("newBlockly".equals(blocklyProject.getBlocklyType())) {
|
||||
str5 = str4 + Utils.BLOCKLY_ADD_PATH + File.separator + blocklyProject.getXmlId() + ".xml";
|
||||
}
|
||||
if (!new File(str5).exists()) {
|
||||
arrayList3.add(blocklyProject);
|
||||
}
|
||||
}
|
||||
if (arrayList3.size() > 0) {
|
||||
blocklyProjects.removeAll(arrayList3);
|
||||
}
|
||||
arrayList2.addAll(blocklyProjects);
|
||||
}
|
||||
return arrayList2;
|
||||
}
|
||||
|
||||
private static void updateToVersion3(String str, String str2, int i) {
|
||||
ArrayList arrayList;
|
||||
String str3 = (ModelType.DEFAULT.getType() == i ? DiyRobotDbHandler.getDefaultModelPath(str) : DiyRobotDbHandler.getCustomModelPath(str)) + str2 + File.separator + str2 + File.separator + str2 + ".config";
|
||||
File file = new File(str3);
|
||||
if (!file.exists() || (arrayList = (ArrayList) JsonHelper.a(FileHelper.b(str3, ""), new TypeToken<List<BlocklyProject>>() { // from class: com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler.2
|
||||
}.getType())) == null || arrayList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
BlocklyProjectDbHandler blocklyProjectDbHandler2 = new BlocklyProjectDbHandler(DatabaseUtils.getDaoSession(true).a());
|
||||
Iterator it = arrayList.iterator();
|
||||
while (it.hasNext()) {
|
||||
BlocklyProject blocklyProject = (BlocklyProject) it.next();
|
||||
blocklyProject.setUserId(str);
|
||||
blocklyProject.setCustomModelId(str2);
|
||||
blocklyProject.setModelType(String.valueOf(i));
|
||||
blocklyProject.setIsDeleted("0");
|
||||
if (!"blockly".equals(blocklyProject.getBlocklyType()) && !"newBlockly".equals(blocklyProject.getBlocklyType())) {
|
||||
blocklyProject.setBlocklyType("blockly");
|
||||
}
|
||||
}
|
||||
blocklyProjectDbHandler2.insertOrUpdateInTx(arrayList);
|
||||
Transporter.b().a(file);
|
||||
file.delete();
|
||||
}
|
||||
|
||||
public boolean deleteBlocklyProject(String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) userId), BlocklyProjectDao.Properties.XmlId.a((Object) str));
|
||||
BlocklyProject blocklyProject = (BlocklyProject) k.c();
|
||||
if (blocklyProject == null) {
|
||||
return false;
|
||||
}
|
||||
this.dao.b((AbstractDao<T, Long>) blocklyProject);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void deleteModelBlocklyProjects(String str, int i, String str2) {
|
||||
QueryBuilder<BlocklyProject> queryBuilder = getQueryBuilder();
|
||||
queryBuilder.a(BlocklyProjectDao.Properties.UserId.a((Object) str), BlocklyProjectDao.Properties.ModelType.a(Integer.valueOf(i)), BlocklyProjectDao.Properties.CustomModelId.a((Object) str2));
|
||||
List<BlocklyProject> query = query(queryBuilder);
|
||||
if (query == null || query.size() == 0) {
|
||||
return;
|
||||
}
|
||||
deleteInTx(query);
|
||||
Iterator<BlocklyProject> it = query.iterator();
|
||||
while (it.hasNext()) {
|
||||
try {
|
||||
File file = TransportFileDbHandler.getFile(TransportFileDbHandler2.newBlocklyProjectFile(it.next()));
|
||||
if (file != null && file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlocklyProject getBlocklyByXml(String str) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) userId), BlocklyProjectDao.Properties.XmlId.a((Object) str));
|
||||
return (BlocklyProject) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<BlocklyProject> getBlocklyProject(String str) {
|
||||
List<BlocklyProject> list;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) str), new WhereCondition[0]);
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
return list == null ? new ArrayList() : list;
|
||||
}
|
||||
|
||||
public List<BlocklyProject> getBlocklyProjects(String str, String str2, String str3) {
|
||||
List<BlocklyProject> list;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) str), BlocklyProjectDao.Properties.ModelType.a((Object) str2), BlocklyProjectDao.Properties.CustomModelId.a((Object) str3), BlocklyProjectDao.Properties.IsDeleted.d("1"));
|
||||
k.b(BlocklyProjectDao.Properties.XmlId);
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
return list == null ? new ArrayList() : list;
|
||||
}
|
||||
|
||||
public String getDefaultXmlName(String str, String str2, String str3, String str4) {
|
||||
List<BlocklyProject> blocklyProjects = getBlocklyProjects(str2, str3, str4);
|
||||
if (blocklyProjects == null || blocklyProjects.size() == 0 || TextUtils.isEmpty(str)) {
|
||||
return str + "1";
|
||||
}
|
||||
int[] iArr = new int[blocklyProjects.size()];
|
||||
int i = 0;
|
||||
for (BlocklyProject blocklyProject : blocklyProjects) {
|
||||
if (blocklyProject.getXmlName().startsWith(str)) {
|
||||
String substring = blocklyProject.getXmlName().substring(str.length(), blocklyProject.getXmlName().length());
|
||||
if (TextUtils.isDigitsOnly(substring) && !TextUtils.isEmpty(substring)) {
|
||||
iArr[i] = Integer.parseInt(substring);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Utils.getDefaultName(iArr, i, str);
|
||||
}
|
||||
|
||||
public List<BlocklyProject> getModifyBlocklyOfflineData() {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) userId), BlocklyProjectDao.Properties.ModelId.b(0), BlocklyProjectDao.Properties.IsFirst.a((Object) 1), BlocklyProjectDao.Properties.IsModify.a((Object) 1), BlocklyProjectDao.Properties.IsUploadService.a((Object) 0));
|
||||
return k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<BlocklyProject> getQiNiuBlocklyProject() {
|
||||
List<BlocklyProject> list;
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) userId), BlocklyProjectDao.Properties.ModelId.b(0), BlocklyProjectDao.Properties.IsDeleted.a((Object) 0), BlocklyProjectDao.Properties.IsFirst.a((Object) 0), BlocklyProjectDao.Properties.IsUploadService.a((Object) 0), BlocklyProjectDao.Properties.IsUploadQiNiu.a((Object) 0));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<BlocklyProject> getServiceBlocklyProject() {
|
||||
List<BlocklyProject> list;
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) userId), BlocklyProjectDao.Properties.ModelId.b(0), BlocklyProjectDao.Properties.IsUploadQiNiu.a((Object) 1), BlocklyProjectDao.Properties.IsFirst.a((Object) 0), BlocklyProjectDao.Properties.IsUploadService.a((Object) 0));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public BlocklyProject getSyncBlocklyByXml(String str) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) userId), BlocklyProjectDao.Properties.XmlId.a((Object) str), BlocklyProjectDao.Properties.IsFirst.a((Object) 1));
|
||||
return (BlocklyProject) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFirs(String str, int i) {
|
||||
BlocklyProject blocklyByXml;
|
||||
if (TextUtils.isEmpty(str) || (blocklyByXml = getBlocklyByXml(str)) == null) {
|
||||
return false;
|
||||
}
|
||||
blocklyByXml.setIsFirst(i);
|
||||
update(blocklyByXml);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isFirstUpload(String str, boolean z) {
|
||||
BlocklyProject blocklyProject;
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
|
||||
blocklyProject = (BlocklyProject) k.c();
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
blocklyProject = null;
|
||||
}
|
||||
if (blocklyProject == null) {
|
||||
return false;
|
||||
}
|
||||
if (z) {
|
||||
blocklyProject.setId(1L);
|
||||
} else {
|
||||
blocklyProject.setId(0L);
|
||||
}
|
||||
update(blocklyProject);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNameExist(BlocklyProject blocklyProject) {
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.XmlName.a((Object) blocklyProject.getXmlName()), BlocklyProjectDao.Properties.ModelType.a((Object) blocklyProject.getModelType()), BlocklyProjectDao.Properties.CustomModelId.a((Object) blocklyProject.getCustomModelId()), BlocklyProjectDao.Properties.IsDeleted.d("1"), BlocklyProjectDao.Properties.UserId.a((Object) blocklyProject.getUserId()));
|
||||
List<BlocklyProject> b = k.b();
|
||||
if (b == null || b.size() <= 0) {
|
||||
return false;
|
||||
}
|
||||
for (BlocklyProject blocklyProject2 : b) {
|
||||
if (!"1".equals(blocklyProject2.getIsDeleted()) && !blocklyProject2.getXmlId().equals(blocklyProject.getXmlId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setDeleteState(String str, boolean z) {
|
||||
BlocklyProject blocklyByXml;
|
||||
if (TextUtils.isEmpty(str) || (blocklyByXml = getBlocklyByXml(str)) == null) {
|
||||
return false;
|
||||
}
|
||||
if (z) {
|
||||
blocklyByXml.setIsDeleted("1");
|
||||
} else {
|
||||
blocklyByXml.setIsDeleted("0");
|
||||
}
|
||||
update(blocklyByXml);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setQiNiuUplaodState(String str, boolean z) {
|
||||
BlocklyProject blocklyByXml;
|
||||
if (TextUtils.isEmpty(str) || (blocklyByXml = getBlocklyByXml(str)) == null) {
|
||||
return false;
|
||||
}
|
||||
blocklyByXml.setUploadQiNiu(z);
|
||||
update(blocklyByXml);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setServiceUplaodState(String str, boolean z) {
|
||||
BlocklyProject blocklyByXml;
|
||||
if (TextUtils.isEmpty(str) || (blocklyByXml = getBlocklyByXml(str)) == null) {
|
||||
return false;
|
||||
}
|
||||
blocklyByXml.setUploadService(z);
|
||||
update(blocklyByXml);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setsetModifyState(String str, boolean z) {
|
||||
BlocklyProject blocklyByXml;
|
||||
if (TextUtils.isEmpty(str) || (blocklyByXml = getBlocklyByXml(str)) == null) {
|
||||
return false;
|
||||
}
|
||||
blocklyByXml.setModify(z);
|
||||
update(blocklyByXml);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean updateBlocklyState(String str, boolean z) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) userId), BlocklyProjectDao.Properties.XmlId.a((Object) str), BlocklyProjectDao.Properties.IsDeleted.d("1"));
|
||||
BlocklyProject blocklyProject = (BlocklyProject) k.c();
|
||||
if (blocklyProject == null) {
|
||||
return false;
|
||||
}
|
||||
blocklyProject.setIsModify(z);
|
||||
update(blocklyProject);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean updateUbtSyncState(String str, boolean z) {
|
||||
BlocklyProject blocklyProject;
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(TransportFileDao.Properties.UserId.a((Object) userId), TransportFileDao.Properties.FilePath.a((Object) str));
|
||||
blocklyProject = (BlocklyProject) k.c();
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
blocklyProject = null;
|
||||
}
|
||||
if (blocklyProject == null) {
|
||||
return false;
|
||||
}
|
||||
blocklyProject.setIsModify(z);
|
||||
update(blocklyProject);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void uploadUserIdAndModelId(String str, int i) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.CustomModelId.a((Object) str), BlocklyProjectDao.Properties.IsUploadQiNiu.a((Object) 0), BlocklyProjectDao.Properties.IsUploadService.a((Object) 0));
|
||||
List<BlocklyProject> query = query(k);
|
||||
if (query == null || query.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (BlocklyProject blocklyProject : query) {
|
||||
blocklyProject.setUserId(userId);
|
||||
blocklyProject.setModelId(i);
|
||||
insertOrUpdate(blocklyProject);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
|
||||
public BlocklyProject selectUnique(BlocklyProject blocklyProject) {
|
||||
return getBlocklyProject(blocklyProject.getUserId(), blocklyProject.getModelType(), blocklyProject.getCustomModelId(), blocklyProject.getXmlId());
|
||||
}
|
||||
|
||||
public BlocklyProject getBlocklyProject(String str, String str2, String str3, String str4) {
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(BlocklyProjectDao.Properties.UserId.a((Object) str), BlocklyProjectDao.Properties.ModelType.a((Object) str2), BlocklyProjectDao.Properties.CustomModelId.a((Object) str3), BlocklyProjectDao.Properties.XmlId.a((Object) str4));
|
||||
return (BlocklyProject) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
224
sources/com/ubt/jimu/blockly/dao/JimuMotionDbHandler.java
Normal file
224
sources/com/ubt/jimu/blockly/dao/JimuMotionDbHandler.java
Normal file
@@ -0,0 +1,224 @@
|
||||
package com.ubt.jimu.blockly.dao;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.AbstractDaoHandler;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.gen.JimuMotionDao;
|
||||
import com.ubtech.utils.StringUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
import org.greenrobot.greendao.query.WhereCondition;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuMotionDbHandler extends AbstractDaoHandler<JimuMotion> {
|
||||
private static JimuMotionDbHandler instance;
|
||||
|
||||
public static class JimuMotionComparator implements Comparator<JimuMotion> {
|
||||
@Override // java.util.Comparator
|
||||
public int compare(JimuMotion jimuMotion, JimuMotion jimuMotion2) {
|
||||
if (jimuMotion == null || jimuMotion2 == null) {
|
||||
return 1;
|
||||
}
|
||||
return (StringUtils.f(jimuMotion.getActionID()) && StringUtils.f(jimuMotion2.getActionID()) && Long.parseLong(jimuMotion.getActionID()) <= Long.parseLong(jimuMotion2.getActionID())) ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
public JimuMotionDbHandler(JimuMotionDao jimuMotionDao) {
|
||||
super(jimuMotionDao);
|
||||
}
|
||||
|
||||
public static synchronized JimuMotionDbHandler getInstance() {
|
||||
JimuMotionDbHandler jimuMotionDbHandler;
|
||||
synchronized (JimuMotionDbHandler.class) {
|
||||
if (instance == null) {
|
||||
instance = new JimuMotionDbHandler(DatabaseUtils.getDaoSession(true).o());
|
||||
}
|
||||
jimuMotionDbHandler = instance;
|
||||
}
|
||||
return jimuMotionDbHandler;
|
||||
}
|
||||
|
||||
public boolean deleteJimuMotionByModeelId(String str) {
|
||||
JimuMotion jimuMotion;
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
TextUtils.isEmpty(Cache.getInstance().getUserId());
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.ActionID.a((Object) str), new WhereCondition[0]);
|
||||
jimuMotion = (JimuMotion) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
jimuMotion = null;
|
||||
}
|
||||
if (jimuMotion == null) {
|
||||
return false;
|
||||
}
|
||||
delete(jimuMotion);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void deleteModelMotions(String str, String str2) {
|
||||
QueryBuilder<JimuMotion> queryBuilder = getQueryBuilder();
|
||||
queryBuilder.a(JimuMotionDao.Properties.UserId.a((Object) str), JimuMotionDao.Properties.CustomModelId.a((Object) str2));
|
||||
List<JimuMotion> query = query(queryBuilder);
|
||||
if (query == null || query.size() == 0) {
|
||||
return;
|
||||
}
|
||||
deleteInTx(query);
|
||||
}
|
||||
|
||||
public String getDefaultMotionName(String str, String str2, String str3) {
|
||||
List<JimuMotion> userModelMotions = getUserModelMotions(str, str2);
|
||||
if (userModelMotions == null || userModelMotions.size() == 0) {
|
||||
return str3 + "1";
|
||||
}
|
||||
int[] iArr = new int[userModelMotions.size()];
|
||||
int i = 0;
|
||||
for (JimuMotion jimuMotion : userModelMotions) {
|
||||
if (jimuMotion.getActionName().startsWith(str3)) {
|
||||
String substring = jimuMotion.getActionName().substring(str3.length(), jimuMotion.getActionName().length());
|
||||
if (TextUtils.isDigitsOnly(substring) && !TextUtils.isEmpty(substring)) {
|
||||
iArr[i] = Integer.parseInt(substring);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Utils.getDefaultName(iArr, i, str3);
|
||||
}
|
||||
|
||||
public JimuMotion getJimuMotionById(String str, String str2, String str3) {
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.UserId.a((Object) str), JimuMotionDao.Properties.ActionID.a((Object) str3));
|
||||
return (JimuMotion) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public JimuMotion getOfflineJimuMotionById(String str, String str2) {
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.UserId.a((Object) str), JimuMotionDao.Properties.ActionID.a((Object) str2), JimuMotionDao.Properties.IsFirst.a((Object) 1), JimuMotionDao.Properties.ModelId.b(0));
|
||||
return (JimuMotion) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<JimuMotion> getSyncAmendMotions() {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
List<JimuMotion> list = null;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.UserId.a((Object) userId), JimuMotionDao.Properties.ModelId.b(0), JimuMotionDao.Properties.IsFirst.a((Object) 1), JimuMotionDao.Properties.IsUploadService.a((Object) 0));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return (list == null || list.size() == 0) ? new ArrayList() : list;
|
||||
}
|
||||
|
||||
public List<JimuMotion> getSyncModelMotions() {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
List<JimuMotion> list = null;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.UserId.a((Object) userId), JimuMotionDao.Properties.ModelId.b(0), JimuMotionDao.Properties.IsFirst.a((Object) 0), JimuMotionDao.Properties.IsDeleted.a((Object) 0), JimuMotionDao.Properties.IsUploadService.a((Object) 0));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return (list == null || list.size() == 0) ? new ArrayList() : list;
|
||||
}
|
||||
|
||||
public List<JimuMotion> getUserModelMotions(String str, String str2) {
|
||||
List<JimuMotion> list;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.UserId.a((Object) str), JimuMotionDao.Properties.CustomModelId.a((Object) str2), JimuMotionDao.Properties.IsDeleted.d("1"));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
if (list == null || list.size() == 0) {
|
||||
return new ArrayList();
|
||||
}
|
||||
Collections.sort(list, new JimuMotionComparator());
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean nameExist(JimuMotion jimuMotion) {
|
||||
List<JimuMotion> list;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.UserId.a((Object) jimuMotion.getUserId()), JimuMotionDao.Properties.ModelType.a((Object) jimuMotion.getModelType()), JimuMotionDao.Properties.CustomModelId.a((Object) jimuMotion.getCustomModelId()), JimuMotionDao.Properties.ActionName.a((Object) jimuMotion.getActionName()));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
if (list == null || list.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (JimuMotion jimuMotion2 : list) {
|
||||
if (!"1".equals(jimuMotion2.getIsDeleted()) && !jimuMotion2.getActionID().equals(jimuMotion.getActionID())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void uploadUserIdAndModelId(String str, int i) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (i <= 0) {
|
||||
return;
|
||||
}
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.CustomModelId.a((Object) str), JimuMotionDao.Properties.IsUploadService.a((Object) 0), JimuMotionDao.Properties.IsFirst.a((Object) 0));
|
||||
List<JimuMotion> query = query(k);
|
||||
if (query == null || query.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (JimuMotion jimuMotion : query) {
|
||||
jimuMotion.setUserId(userId);
|
||||
jimuMotion.setModelId(i);
|
||||
insertOrUpdate(jimuMotion);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
|
||||
public JimuMotion selectUnique(JimuMotion jimuMotion) {
|
||||
return getJimuMotionById(jimuMotion.getUserId(), jimuMotion.getCustomModelId(), jimuMotion.getActionID());
|
||||
}
|
||||
|
||||
public List<JimuMotion> getUserModelMotions(String str) {
|
||||
List<JimuMotion> list;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuMotionDao.Properties.UserId.a((Object) str), new WhereCondition[0]);
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
return list == null ? new ArrayList() : list;
|
||||
}
|
||||
}
|
||||
338
sources/com/ubt/jimu/blockly/dao/JimuSoundDbHandler.java
Normal file
338
sources/com/ubt/jimu/blockly/dao/JimuSoundDbHandler.java
Normal file
@@ -0,0 +1,338 @@
|
||||
package com.ubt.jimu.blockly.dao;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
||||
import com.ubt.jimu.base.db.AbstractDaoHandler;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioParams;
|
||||
import com.ubt.jimu.gen.JimuSoundDao;
|
||||
import com.ubt.jimu.transport.Transporter;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.unity.ModelType;
|
||||
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.greenrobot.greendao.query.QueryBuilder;
|
||||
import org.greenrobot.greendao.query.WhereCondition;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuSoundDbHandler extends AbstractDaoHandler<JimuSound> {
|
||||
private static final String TAG = "JimuSoundDbHandler";
|
||||
private static JimuSoundDbHandler instance;
|
||||
|
||||
public JimuSoundDbHandler(JimuSoundDao jimuSoundDao) {
|
||||
super(jimuSoundDao);
|
||||
}
|
||||
|
||||
public static synchronized JimuSoundDbHandler getInstance() {
|
||||
JimuSoundDbHandler jimuSoundDbHandler;
|
||||
synchronized (JimuSoundDbHandler.class) {
|
||||
if (instance == null) {
|
||||
instance = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
}
|
||||
jimuSoundDbHandler = instance;
|
||||
}
|
||||
return jimuSoundDbHandler;
|
||||
}
|
||||
|
||||
public static void update2Version3() {
|
||||
String[] list;
|
||||
SharePreferenceHelper sharePreferenceHelper = new SharePreferenceHelper();
|
||||
if (sharePreferenceHelper.getBoolean("jimu_sound_update", true).booleanValue()) {
|
||||
String str = ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + "users" + File.separator;
|
||||
File file = new File(str);
|
||||
if (!file.exists() || (list = file.list()) == null || list.length == 0) {
|
||||
return;
|
||||
}
|
||||
JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
for (String str2 : list) {
|
||||
String str3 = str + str2 + File.separator + TransportFileDbHandler2.DIR_SOUNDS + File.separator + JimuRobot.SOUNDS;
|
||||
List<JimuSound> list2 = (List) JsonHelper.a(FileHelper.b(str3, ""), new TypeToken<List<JimuSound>>() { // from class: com.ubt.jimu.blockly.dao.JimuSoundDbHandler.2
|
||||
}.getType());
|
||||
if (list2 != null && list2.size() != 0) {
|
||||
for (JimuSound jimuSound : list2) {
|
||||
jimuSound.setUserId(str2);
|
||||
jimuSound.setIsDeleted("0");
|
||||
}
|
||||
try {
|
||||
jimuSoundDbHandler.insertOrUpdateInTx(list2);
|
||||
new File(str3).delete();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "迁移用户:" + str2 + " 的录音数据到数据表失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
sharePreferenceHelper.put("jimu_sound_update", false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean deleteJimuSound(JimuSound jimuSound) {
|
||||
JimuSound jimuSound2;
|
||||
if (jimuSound == null || (jimuSound2 = getJimuSound(jimuSound)) == null) {
|
||||
return false;
|
||||
}
|
||||
delete(jimuSound2);
|
||||
File file = new File(jimuSound.getLocalFilePath());
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
String parent = file.getParent();
|
||||
LogUtils.c("path:" + parent);
|
||||
File file2 = new File(parent);
|
||||
if (!file2.exists() || !file2.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
file2.delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getDefaultSoundName(String str, String str2) {
|
||||
List<JimuSound> jimuSounds = getJimuSounds(str);
|
||||
if (jimuSounds == null || jimuSounds.size() == 0 || TextUtils.isEmpty(str2)) {
|
||||
return str2 + "1";
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (JimuSound jimuSound : jimuSounds) {
|
||||
if ("1".equals(jimuSound.getIsDeleted())) {
|
||||
arrayList.add(jimuSound);
|
||||
}
|
||||
}
|
||||
if (arrayList.size() > 0) {
|
||||
jimuSounds.removeAll(arrayList);
|
||||
}
|
||||
int[] iArr = new int[jimuSounds.size()];
|
||||
int i = 0;
|
||||
for (JimuSound jimuSound2 : jimuSounds) {
|
||||
if (jimuSound2.getDescription().startsWith(str2)) {
|
||||
String substring = jimuSound2.getDescription().substring(str2.length(), jimuSound2.getDescription().length());
|
||||
if (TextUtils.isDigitsOnly(substring) && !TextUtils.isEmpty(substring)) {
|
||||
iArr[i] = Integer.parseInt(substring);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Utils.getDefaultName(iArr, i, str2);
|
||||
}
|
||||
|
||||
public JimuSound getJimuSound(JimuSound jimuSound) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
if (!TextUtils.isEmpty(jimuSound.getAudioId())) {
|
||||
k.a(JimuSoundDao.Properties.UserId.a((Object) userId), JimuSoundDao.Properties.AudioId.a((Object) jimuSound.getAudioId()), JimuSoundDao.Properties.IsDeleted.a((Object) 0));
|
||||
} else {
|
||||
if (TextUtils.isEmpty(jimuSound.getKey())) {
|
||||
return null;
|
||||
}
|
||||
k.a(JimuSoundDao.Properties.UserId.a((Object) userId), JimuSoundDao.Properties.IsDeleted.a((Object) 0), JimuSoundDao.Properties.Key.a((Object) jimuSound.getKey()));
|
||||
}
|
||||
return (JimuSound) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<JimuSound> getJimuSounds(String str) {
|
||||
List<JimuSound> list;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuSoundDao.Properties.UserId.a((Object) str), new WhereCondition[0]);
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
list = null;
|
||||
}
|
||||
return list == null ? new ArrayList() : list;
|
||||
}
|
||||
|
||||
public List<JimuSound> getOfflineQiNiuFile() {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
List<JimuSound> list = null;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuSoundDao.Properties.UserId.a((Object) userId), JimuSoundDao.Properties.IsUploadQiNiu.a((Object) 0), JimuSoundDao.Properties.IsSyncUbtService.a((Object) 0));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list == null ? new ArrayList() : list;
|
||||
}
|
||||
|
||||
public List<JimuSound> getOfflineServiceFile() {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
List<JimuSound> list = null;
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuSoundDao.Properties.UserId.a((Object) userId), JimuSoundDao.Properties.IsUploadQiNiu.a((Object) 1), JimuSoundDao.Properties.IsSyncUbtService.a((Object) 0));
|
||||
list = k.b();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list == null ? new ArrayList() : list;
|
||||
}
|
||||
|
||||
public boolean insertOrUpdateFromService(JimuSound jimuSound) {
|
||||
if (jimuSound == null) {
|
||||
return false;
|
||||
}
|
||||
if (TextUtils.isEmpty(jimuSound.getAudioId()) && TextUtils.isEmpty(jimuSound.getKey())) {
|
||||
return false;
|
||||
}
|
||||
JimuSound jimuSound2 = getJimuSound(jimuSound);
|
||||
if (jimuSound2 != null) {
|
||||
jimuSound2.setLastUploadTime(jimuSound.getLastUploadTime());
|
||||
jimuSound2.setAudioId(jimuSound.getAudioId());
|
||||
jimuSound2.setDescription(jimuSound.getDescription());
|
||||
jimuSound2.setDuration(jimuSound.getDuration());
|
||||
jimuSound2.setIsDeleted("0");
|
||||
jimuSound2.setIsSyncUbtService(true);
|
||||
jimuSound2.setIsUploadQiNiu(true);
|
||||
insertOrUpdate(jimuSound2);
|
||||
} else {
|
||||
JimuSound jimuSound3 = new JimuSound();
|
||||
jimuSound3.setUserId(jimuSound.getUserId());
|
||||
jimuSound3.setIsDeleted("0");
|
||||
jimuSound3.setKey(jimuSound.getAudioId());
|
||||
jimuSound3.setIsSyncUbtService(true);
|
||||
jimuSound3.setIsUploadQiNiu(true);
|
||||
jimuSound3.setDescription(jimuSound.getDescription());
|
||||
jimuSound3.setDuration(jimuSound.getDuration());
|
||||
jimuSound3.setIsSyncUbtService(true);
|
||||
jimuSound3.setIsUploadQiNiu(true);
|
||||
jimuSound3.setType(jimuSound.getType());
|
||||
jimuSound3.setLastUploadTime(jimuSound.getLastUploadTime());
|
||||
jimuSound3.setAudioId(jimuSound.getAudioId());
|
||||
insertOrUpdate(jimuSound3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean nameExist(String str, String str2) {
|
||||
List<JimuSound> jimuSounds = getJimuSounds(str);
|
||||
if (jimuSounds != null && jimuSounds.size() != 0) {
|
||||
for (JimuSound jimuSound : jimuSounds) {
|
||||
if (jimuSound.getDescription().equals(str2) && !"1".equals(jimuSound.getIsDeleted())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean updateJimuSoundUbtServiceState(JimuSound jimuSound, boolean z) {
|
||||
JimuSound selectUnique;
|
||||
if (jimuSound == null || (selectUnique = selectUnique(jimuSound)) == null) {
|
||||
return false;
|
||||
}
|
||||
selectUnique.setSyncUbtService(z);
|
||||
insertOrUpdate(selectUnique);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean updateQiNiuSyncState(JimuSound jimuSound, boolean z) {
|
||||
JimuSound selectUnique;
|
||||
if (jimuSound == null || (selectUnique = selectUnique(jimuSound)) == null) {
|
||||
return false;
|
||||
}
|
||||
selectUnique.setUploadQiNiu(z);
|
||||
insertOrUpdate(selectUnique);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateToVersion3(String str, String str2) {
|
||||
String str3 = str + JimuRobot.SOUNDS;
|
||||
File file = new File(str3);
|
||||
if (file.exists()) {
|
||||
List<JimuSound> list = (List) JsonHelper.a(FileHelper.b(str3, ""), new TypeToken<List<JimuSound>>() { // from class: com.ubt.jimu.blockly.dao.JimuSoundDbHandler.1
|
||||
}.getType());
|
||||
if (list == null || list.size() == 0) {
|
||||
Transporter.b().a(file);
|
||||
file.delete();
|
||||
return;
|
||||
}
|
||||
for (JimuSound jimuSound : list) {
|
||||
jimuSound.setUserId(str2);
|
||||
if ("1".equals(jimuSound.getIsDeleted())) {
|
||||
jimuSound.setIsDeleted(jimuSound.getIsDeleted());
|
||||
}
|
||||
}
|
||||
try {
|
||||
insertOrUpdateInTx(list);
|
||||
Transporter.b().a(file);
|
||||
file.delete();
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
Log.e(TAG, "updateToVersion3 on error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean uploadDeleteState(JimuSound jimuSound, boolean z) {
|
||||
JimuSound selectUnique;
|
||||
if (jimuSound == null || (selectUnique = selectUnique(jimuSound)) == null) {
|
||||
return false;
|
||||
}
|
||||
selectUnique.setIsDeleted(z ? "1" : "0");
|
||||
update(jimuSound);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler
|
||||
public JimuSound selectUnique(JimuSound jimuSound) {
|
||||
return getJimuSound(jimuSound.getUserId(), jimuSound.getKey());
|
||||
}
|
||||
|
||||
public List<JimuSound> getJimuSounds(String str, String str2) {
|
||||
updateToVersion3(str, str2);
|
||||
List<JimuSound> jimuSounds = getJimuSounds(str2);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (jimuSounds != null && jimuSounds.size() != 0) {
|
||||
for (JimuSound jimuSound : jimuSounds) {
|
||||
if (!"1".equals(jimuSound.getIsDeleted())) {
|
||||
String key = jimuSound.getKey();
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
key = jimuSound.getAudioId();
|
||||
}
|
||||
File file = new File(str + key + File.separator + key + AudioParams.AAC);
|
||||
if (file.exists() && file.isFile()) {
|
||||
arrayList.add(jimuSound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public JimuSound getJimuSound(String str, String str2) {
|
||||
try {
|
||||
QueryBuilder k = this.dao.k();
|
||||
k.a(JimuSoundDao.Properties.UserId.a((Object) str), JimuSoundDao.Properties.Key.a((Object) str2));
|
||||
return (JimuSound) k.c();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
sources/com/ubt/jimu/blockly/exception/BlocklyEvent.java
Normal file
28
sources/com/ubt/jimu/blockly/exception/BlocklyEvent.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.ubt.jimu.blockly.exception;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyEvent<T> {
|
||||
public static final int BLOCKLY_DISCONNECT_BLE = 1006;
|
||||
public static final int CALL_JAVASCRIPT = 1004;
|
||||
public static final int COMMON_EXCEPTION = 1001;
|
||||
public static final int DISCONNECT_BLE = 1003;
|
||||
public static final int JS_EXCEPTION = 1002;
|
||||
|
||||
@Deprecated
|
||||
public static final int RESTART_BLOCKLY = 1005;
|
||||
private T msg;
|
||||
private int type;
|
||||
|
||||
public BlocklyEvent(int i, T t) {
|
||||
this.msg = t;
|
||||
this.type = i;
|
||||
}
|
||||
|
||||
public T getMessage() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.ubt.jimu.blockly.exception;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum JimuConnectionException {
|
||||
UNKNOW_EXCEPTION("unknow", 0, R.string.connect_ex_search),
|
||||
NOT_FOUND_DEVICE("searchJimu", 1, R.string.connect_ex_search),
|
||||
SERVO_ID_REPEAT("servoIdRepeat", 2, R.string.connect_ex_id_repeat),
|
||||
SERVO_ID_NOT_MATCH("servoVSLine", 3, R.string.connect_ex_servo_vs_line),
|
||||
SERVO_NUM_NOT_MATCH("servoNumVsLine", 4, R.string.connect_ex_servo_num_vs_line),
|
||||
SERVO_CONNECT_EXCEPTION("servoLineError", 5, R.string.connect_ex_servo_line),
|
||||
FIRMWARE_UPDATE_ERROR("firmwareUpdateError", 6, R.string.connect_ex_update_error),
|
||||
SYSTEM_HELP("systemHelp", 7, R.string.title_blockly_help),
|
||||
CONNECT_FAIL("connectFail", 8, R.string.title_blockly_help),
|
||||
UNICORN_AR_HELP("unicornARHelp", 9, R.string.title_blockly_help);
|
||||
|
||||
private String name;
|
||||
private int tipsResId;
|
||||
private int type;
|
||||
|
||||
JimuConnectionException(String str, int i, int i2) {
|
||||
this.name = str;
|
||||
this.type = i;
|
||||
this.tipsResId = i2;
|
||||
}
|
||||
|
||||
public static String getUrl(String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
int parseInt = Integer.parseInt(str);
|
||||
for (JimuConnectionException jimuConnectionException : values()) {
|
||||
if (jimuConnectionException.getType() == parseInt) {
|
||||
return "https://video.ubtrobot.com/jimu/product/h5/u3dLinkTips/index.html?pageType=" + jimuConnectionException.getName() + "&language=" + JimuApplication.l().g();
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getTipsResId() {
|
||||
return this.tipsResId;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
18
sources/com/ubt/jimu/blockly/exception/JimuRobotMessage.java
Normal file
18
sources/com/ubt/jimu/blockly/exception/JimuRobotMessage.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.ubt.jimu.blockly.exception;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuRobotMessage {
|
||||
public static final int ERROR = 2;
|
||||
public static final int SUCCESS = 1;
|
||||
public static final int WAITING = 0;
|
||||
private int level;
|
||||
private String msg;
|
||||
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ubt.jimu.blockly.feature.audio;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AndroidManufacturer {
|
||||
public static final String ASUS = "asus";
|
||||
public static final String SAMSUNG = "samsung";
|
||||
public static final String VIVO = "vivo";
|
||||
public static final String XIAO_MI = "Xiaomi";
|
||||
|
||||
public static boolean match(String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
return Build.MANUFACTURER.toLowerCase().equals(str.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.ubt.jimu.blockly.feature.audio;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AudioParams {
|
||||
public static final String AAC = ".aac";
|
||||
public static final String MP3 = ".mp3";
|
||||
public static final String WAV = ".wav";
|
||||
public static final String gpp = ".3gp";
|
||||
}
|
||||
195
sources/com/ubt/jimu/blockly/feature/audio/AudioPlayer.java
Normal file
195
sources/com/ubt/jimu/blockly/feature/audio/AudioPlayer.java
Normal file
@@ -0,0 +1,195 @@
|
||||
package com.ubt.jimu.blockly.feature.audio;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AudioPlayer {
|
||||
private static AudioPlayer player;
|
||||
private MediaPlayer mPlayer;
|
||||
private String source;
|
||||
private Timer timer;
|
||||
private final String TAG = AudioPlayer.class.getSimpleName();
|
||||
private boolean isPausing = false;
|
||||
private int progress = -1;
|
||||
|
||||
public interface IProgressListener {
|
||||
void onError();
|
||||
|
||||
void onFinished();
|
||||
}
|
||||
|
||||
private class MyTimerTask extends TimerTask {
|
||||
private long future;
|
||||
|
||||
public MyTimerTask(long j) {
|
||||
this.future = j;
|
||||
}
|
||||
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
if (AudioPlayer.this.mPlayer == null || AudioPlayer.this.mPlayer.getCurrentPosition() < this.future) {
|
||||
return;
|
||||
}
|
||||
AudioPlayer.this.stop();
|
||||
AudioPlayer.this.timer.cancel();
|
||||
AudioPlayer.this.timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private AudioPlayer() {
|
||||
this.mPlayer = null;
|
||||
this.mPlayer = new MediaPlayer();
|
||||
this.mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { // from class: com.ubt.jimu.blockly.feature.audio.AudioPlayer.1
|
||||
@Override // android.media.MediaPlayer.OnCompletionListener
|
||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||
Log.i(AudioPlayer.this.TAG, "onCompletion");
|
||||
}
|
||||
});
|
||||
this.mPlayer.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() { // from class: com.ubt.jimu.blockly.feature.audio.AudioPlayer.2
|
||||
@Override // android.media.MediaPlayer.OnSeekCompleteListener
|
||||
public void onSeekComplete(MediaPlayer mediaPlayer) {
|
||||
Log.i(AudioPlayer.this.TAG, "onSeekComplete");
|
||||
}
|
||||
});
|
||||
this.mPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { // from class: com.ubt.jimu.blockly.feature.audio.AudioPlayer.3
|
||||
@Override // android.media.MediaPlayer.OnErrorListener
|
||||
public boolean onError(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
Log.e(AudioPlayer.this.TAG, "播放onError:what=" + i + " extra=" + i2);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.mPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() { // from class: com.ubt.jimu.blockly.feature.audio.AudioPlayer.4
|
||||
@Override // android.media.MediaPlayer.OnInfoListener
|
||||
public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
Log.e(AudioPlayer.this.TAG, "onInfo:what=" + i + " extra=" + i2);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static synchronized AudioPlayer getInstance() {
|
||||
AudioPlayer audioPlayer;
|
||||
synchronized (AudioPlayer.class) {
|
||||
if (player == null) {
|
||||
player = new AudioPlayer();
|
||||
}
|
||||
audioPlayer = player;
|
||||
}
|
||||
return audioPlayer;
|
||||
}
|
||||
|
||||
private void startTimer(long j) {
|
||||
Timer timer = this.timer;
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
this.timer = new Timer();
|
||||
this.timer.schedule(new MyTimerTask(j), 0L, 50L);
|
||||
}
|
||||
|
||||
public long getAudioDuration(String str) {
|
||||
try {
|
||||
this.mPlayer.reset();
|
||||
this.mPlayer.setDataSource(str);
|
||||
this.mPlayer.prepare();
|
||||
return this.mPlayer.getDuration();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
try {
|
||||
this.progress = this.mPlayer.getCurrentPosition();
|
||||
this.isPausing = true;
|
||||
this.mPlayer.pause();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean play(String str) {
|
||||
if (!new File(str).exists()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
this.mPlayer.reset();
|
||||
this.mPlayer.setDataSource(str);
|
||||
this.mPlayer.prepare();
|
||||
if (TextUtils.isEmpty(this.source)) {
|
||||
this.source = str;
|
||||
this.progress = -1;
|
||||
this.isPausing = false;
|
||||
} else if (this.source.equals(str)) {
|
||||
if (!this.isPausing) {
|
||||
this.source = str;
|
||||
this.progress = -1;
|
||||
this.isPausing = false;
|
||||
} else if (this.progress > -1) {
|
||||
this.mPlayer.seekTo(this.progress);
|
||||
this.progress = -1;
|
||||
this.isPausing = false;
|
||||
}
|
||||
}
|
||||
this.mPlayer.start();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
this.mPlayer.release();
|
||||
this.mPlayer = null;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
try {
|
||||
this.source = null;
|
||||
this.mPlayer.stop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean play(String str, final IProgressListener iProgressListener) {
|
||||
this.mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { // from class: com.ubt.jimu.blockly.feature.audio.AudioPlayer.5
|
||||
@Override // android.media.MediaPlayer.OnCompletionListener
|
||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||
IProgressListener iProgressListener2 = iProgressListener;
|
||||
if (iProgressListener2 != null) {
|
||||
iProgressListener2.onFinished();
|
||||
}
|
||||
AudioPlayer.this.mPlayer.setOnCompletionListener(null);
|
||||
}
|
||||
});
|
||||
this.mPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { // from class: com.ubt.jimu.blockly.feature.audio.AudioPlayer.6
|
||||
@Override // android.media.MediaPlayer.OnErrorListener
|
||||
public boolean onError(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
Log.e(AudioPlayer.this.TAG, "MediaPlayer onError:what=" + i + " extra=" + i2);
|
||||
IProgressListener iProgressListener2 = iProgressListener;
|
||||
if (iProgressListener2 != null) {
|
||||
iProgressListener2.onError();
|
||||
}
|
||||
AudioPlayer.this.mPlayer.setOnErrorListener(null);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return play(str);
|
||||
}
|
||||
|
||||
public void play(String str, long j, IProgressListener iProgressListener) {
|
||||
if (!play(str, iProgressListener) || j <= 0) {
|
||||
return;
|
||||
}
|
||||
startTimer(j);
|
||||
}
|
||||
}
|
||||
159
sources/com/ubt/jimu/blockly/feature/audio/AudioRecoder.java
Normal file
159
sources/com/ubt/jimu/blockly/feature/audio/AudioRecoder.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package com.ubt.jimu.blockly.feature.audio;
|
||||
|
||||
import android.media.MediaRecorder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AudioRecoder {
|
||||
private static AudioRecoder audioRecoder = null;
|
||||
public static boolean recoding = false;
|
||||
private String fileName;
|
||||
private MediaRecorder recorder;
|
||||
private final String TAG = AudioRecoder.class.getSimpleName();
|
||||
private int sampleRateInHz = 16000;
|
||||
private long lastRecordTime = 0;
|
||||
|
||||
private class RecorderInfoListener implements MediaRecorder.OnInfoListener {
|
||||
private RecorderInfoListener() {
|
||||
}
|
||||
|
||||
@Override // android.media.MediaRecorder.OnInfoListener
|
||||
public void onInfo(MediaRecorder mediaRecorder, int i, int i2) {
|
||||
if (i == 1) {
|
||||
Log.e(AudioRecoder.this.TAG, "OnInfo: MEDIA_RECORDER_INFO_UNKNOWN");
|
||||
return;
|
||||
}
|
||||
if (i == 800) {
|
||||
AudioRecoder.recoding = false;
|
||||
Log.e(AudioRecoder.this.TAG, "OnInfo: MEDIA_RECORDER_INFO_MAX_DURATION_REACHED");
|
||||
} else {
|
||||
if (i != 801) {
|
||||
return;
|
||||
}
|
||||
AudioRecoder.recoding = false;
|
||||
Log.e(AudioRecoder.this.TAG, "OnInfo: MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RecorderOnErrorListener implements MediaRecorder.OnErrorListener {
|
||||
private RecorderOnErrorListener() {
|
||||
}
|
||||
|
||||
@Override // android.media.MediaRecorder.OnErrorListener
|
||||
public void onError(MediaRecorder mediaRecorder, int i, int i2) {
|
||||
AudioRecoder.recoding = false;
|
||||
Log.e(AudioRecoder.this.TAG, "录音失败:what=" + i + " extra=" + i2);
|
||||
File file = new File(AudioRecoder.this.fileName);
|
||||
if (file.exists()) {
|
||||
FileHelper.a(file.getParentFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private AudioRecoder() {
|
||||
}
|
||||
|
||||
private boolean aacLibRecord(String str) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean aacRecord(String str) throws Exception {
|
||||
try {
|
||||
release();
|
||||
File parentFile = new File(str).getParentFile();
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
this.fileName = str;
|
||||
this.recorder = new MediaRecorder();
|
||||
this.recorder.setAudioSource(1);
|
||||
this.recorder.setOutputFormat(6);
|
||||
this.recorder.setAudioEncoder(3);
|
||||
this.recorder.setAudioSamplingRate(8000);
|
||||
this.recorder.setAudioChannels(1);
|
||||
this.recorder.setOutputFile(str);
|
||||
this.recorder.setOnErrorListener(new RecorderOnErrorListener());
|
||||
this.recorder.setOnInfoListener(new RecorderInfoListener());
|
||||
this.recorder.prepare();
|
||||
this.recorder.start();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
onRecordFailed(str);
|
||||
e.printStackTrace();
|
||||
release();
|
||||
Log.e(this.TAG, "prepare() failed");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized AudioRecoder getInstance() {
|
||||
AudioRecoder audioRecoder2;
|
||||
synchronized (AudioRecoder.class) {
|
||||
if (audioRecoder == null) {
|
||||
audioRecoder = new AudioRecoder();
|
||||
}
|
||||
audioRecoder2 = audioRecoder;
|
||||
}
|
||||
return audioRecoder2;
|
||||
}
|
||||
|
||||
private void onRecordFailed(String str) {
|
||||
File parentFile = new File(str).getParentFile();
|
||||
if (parentFile.exists()) {
|
||||
FileHelper.a(parentFile);
|
||||
try {
|
||||
FileHelper.a(parentFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
if (TextUtils.isEmpty(this.fileName)) {
|
||||
return null;
|
||||
}
|
||||
String str = this.fileName;
|
||||
String substring = str.substring(str.lastIndexOf(File.separator) + 1, this.fileName.length());
|
||||
return substring.substring(0, substring.lastIndexOf("."));
|
||||
}
|
||||
|
||||
public void release() {
|
||||
MediaRecorder mediaRecorder = this.recorder;
|
||||
if (mediaRecorder != null) {
|
||||
try {
|
||||
try {
|
||||
mediaRecorder.release();
|
||||
} catch (IllegalStateException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
this.recorder = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean startRecord(String str) throws Exception {
|
||||
recoding = true;
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (currentTimeMillis - this.lastRecordTime < 500) {
|
||||
return false;
|
||||
}
|
||||
Log.i(this.TAG, "调用录音:" + str);
|
||||
this.lastRecordTime = currentTimeMillis;
|
||||
return aacRecord(str);
|
||||
}
|
||||
|
||||
public void stopRecod() {
|
||||
recoding = false;
|
||||
release();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyEmotion {
|
||||
private boolean islightLock;
|
||||
private List<Emotion> lightArray;
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || BlocklyEmotion.class != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BlocklyEmotion blocklyEmotion = (BlocklyEmotion) obj;
|
||||
return this.islightLock == blocklyEmotion.islightLock && Objects.equals(this.lightArray, blocklyEmotion.lightArray);
|
||||
}
|
||||
|
||||
public List<Emotion> getLightArray() {
|
||||
return this.lightArray;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(Boolean.valueOf(this.islightLock), this.lightArray);
|
||||
}
|
||||
|
||||
public boolean islightLock() {
|
||||
return this.islightLock;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyLight {
|
||||
private boolean islightLock;
|
||||
private List<Light> lightArray;
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || BlocklyLight.class != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BlocklyLight blocklyLight = (BlocklyLight) obj;
|
||||
return this.islightLock == blocklyLight.islightLock && Objects.equals(getLightArray(), blocklyLight.getLightArray());
|
||||
}
|
||||
|
||||
public List<Light> getLightArray() {
|
||||
return this.lightArray;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(Boolean.valueOf(this.islightLock), getLightArray());
|
||||
}
|
||||
|
||||
public boolean islightLock() {
|
||||
return this.islightLock;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ColorSensor {
|
||||
private String color;
|
||||
private int id;
|
||||
private String realColor;
|
||||
|
||||
public ColorSensor() {
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getRealColor() {
|
||||
return this.realColor;
|
||||
}
|
||||
|
||||
public ColorSensor(int i, String str) {
|
||||
this.id = i;
|
||||
this.color = str;
|
||||
}
|
||||
}
|
||||
37
sources/com/ubt/jimu/blockly/feature/blockly/Emotion.java
Normal file
37
sources/com/ubt/jimu/blockly/feature/blockly/Emotion.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Emotion {
|
||||
private String color;
|
||||
private int emotionIndex;
|
||||
private int id;
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Emotion)) {
|
||||
return false;
|
||||
}
|
||||
Emotion emotion = (Emotion) obj;
|
||||
return this.id == emotion.id && this.emotionIndex == emotion.emotionIndex;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public int getEmotionIndex() {
|
||||
return this.emotionIndex;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(Integer.valueOf(this.id), Integer.valueOf(this.emotionIndex));
|
||||
}
|
||||
}
|
||||
25
sources/com/ubt/jimu/blockly/feature/blockly/Gyroscope.java
Normal file
25
sources/com/ubt/jimu/blockly/feature/blockly/Gyroscope.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Gyroscope {
|
||||
private int id;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuAction {
|
||||
public String icon;
|
||||
public String id;
|
||||
public String name;
|
||||
}
|
||||
100
sources/com/ubt/jimu/blockly/feature/blockly/JimuSensor.java
Normal file
100
sources/com/ubt/jimu/blockly/feature/blockly/JimuSensor.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuSensor {
|
||||
private int id;
|
||||
private float result;
|
||||
private String type;
|
||||
|
||||
public enum SensorType {
|
||||
Phone("phone", 99),
|
||||
Infrared("Infrared", 101),
|
||||
Touch("Touch", 102),
|
||||
Gyroscope("Gyroscope", 103),
|
||||
Light("Light", 104),
|
||||
Gravity("Gravity", 105),
|
||||
Ultrasonic("Ultrasonic", 106),
|
||||
DigitalTube("DigitalTube", 107),
|
||||
Speaker("Speaker", 108),
|
||||
ULTRASONIC("ultrasonic", 109),
|
||||
COLOR("color", 110);
|
||||
|
||||
private String name;
|
||||
private int type;
|
||||
|
||||
SensorType(String str, int i) {
|
||||
this.name = str;
|
||||
this.type = i;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean sameSensor(String str) {
|
||||
return this.name.toLowerCase().equals(str.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public JimuSensor() {
|
||||
}
|
||||
|
||||
public static float convertInfraredValueToLevel2(float f) {
|
||||
int i;
|
||||
double d;
|
||||
double d2;
|
||||
float f2 = f - 850.0f;
|
||||
if (f2 < 0.0f) {
|
||||
i = 0;
|
||||
} else {
|
||||
if (f2 < 70.0f) {
|
||||
d = f2 - 15.0f;
|
||||
d2 = 13.5d;
|
||||
} else if (f2 < 1210.0f) {
|
||||
d = f2 + 1134.0f;
|
||||
d2 = 288.0d;
|
||||
} else if (f2 < 1565.0f) {
|
||||
i = (int) ((f2 + 206.0f) / 177.0f);
|
||||
} else if (f2 < 1821.0f) {
|
||||
d = f2 - 1033.0f;
|
||||
d2 = 53.75d;
|
||||
} else if (f2 < 2200.0f) {
|
||||
d = f2 - 1462.0f;
|
||||
d2 = 22.75d;
|
||||
} else {
|
||||
i = 20;
|
||||
}
|
||||
i = (int) (d / d2);
|
||||
}
|
||||
if (i > 20) {
|
||||
i = 20;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public float getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setResult(float f) {
|
||||
this.result = f;
|
||||
}
|
||||
|
||||
public JimuSensor(SensorType sensorType, int i, int i2) {
|
||||
this.type = sensorType.getName();
|
||||
this.id = i;
|
||||
this.result = i2;
|
||||
}
|
||||
}
|
||||
45
sources/com/ubt/jimu/blockly/feature/blockly/Light.java
Normal file
45
sources/com/ubt/jimu/blockly/feature/blockly/Light.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.ubt.jimu.blockly.feature.blockly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Light {
|
||||
private int id;
|
||||
private List<String> lights;
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && (obj instanceof Light)) {
|
||||
Light light = (Light) obj;
|
||||
if (this.id != light.id) {
|
||||
return false;
|
||||
}
|
||||
if (this.lights == null && light.lights == null) {
|
||||
return true;
|
||||
}
|
||||
List<String> list = this.lights;
|
||||
if (list == null || light.lights == null || list.size() != light.lights.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.lights.size(); i++) {
|
||||
if (!this.lights.get(i).toLowerCase().equals(light.lights.get(i).toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<String> getLights() {
|
||||
return this.lights;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(Integer.valueOf(this.id), this.lights);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
package com.ubt.jimu.blockly.feature.course;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.feature.blockly.BlocklyEmotion;
|
||||
import com.ubt.jimu.blockly.feature.blockly.BlocklyLight;
|
||||
import com.ubt.jimu.controller.data.widget.JockstickDataConverter;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubtech.utils.XmlHelper;
|
||||
import com.unity3d.ads.metadata.MediationMetaData;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklyDomCompare {
|
||||
private final String TAG = BlocklyDomCompare.class.getSimpleName();
|
||||
public final String correct = "0";
|
||||
public final String error = "-1";
|
||||
public final String attri = "x,y,id,SceneLight,PROGRAM_BRANCH";
|
||||
|
||||
private String checkProgramDocument(Node node, Node node2) {
|
||||
if (node == null || node2 == null) {
|
||||
return "-1";
|
||||
}
|
||||
if (!node.hasChildNodes() && !node2.hasChildNodes()) {
|
||||
return node.getNodeType() != node2.getNodeType() ? "-1" : node.getNodeType() == 3 ? !compareTextNode(node, node2) ? getNodeId(node2) : "0" : compareAttribute(node, node2) ? "0" : getNodeId(node2);
|
||||
}
|
||||
NodeList childNodes = node.getChildNodes();
|
||||
NodeList childNodes2 = node2.getChildNodes();
|
||||
if (childNodes == null && childNodes2 == null) {
|
||||
return "0";
|
||||
}
|
||||
if (childNodes == null || childNodes2 == null || childNodes.getLength() == 0 || childNodes2.getLength() == 0) {
|
||||
return getNodeId(node2);
|
||||
}
|
||||
int i = 0;
|
||||
String str = "0";
|
||||
while (true) {
|
||||
if (i < childNodes.getLength()) {
|
||||
if (i < childNodes2.getLength()) {
|
||||
Node item = childNodes.item(i);
|
||||
Node item2 = childNodes2.item(i);
|
||||
if (!compareAttribute(item, item2)) {
|
||||
str = getNodeId(item2);
|
||||
break;
|
||||
}
|
||||
if (item != null && !item.getNodeName().equals(item2.getNodeName())) {
|
||||
str = getNodeId(item2);
|
||||
break;
|
||||
}
|
||||
str = checkProgramDocument(item, item2);
|
||||
if (!"0".equals(str)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
str = getNodeId(childNodes2.item(childNodes2.getLength() - 1));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (i == childNodes.getLength() && "0".equals(str) && childNodes.getLength() < childNodes2.getLength()) ? getNodeId(childNodes2.item(i)) : str;
|
||||
}
|
||||
|
||||
private boolean compareAttribute(Node node, Node node2) {
|
||||
if (node == null && node2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (node != null && node2 != null) {
|
||||
NamedNodeMap attributes = node.getAttributes();
|
||||
NamedNodeMap attributes2 = node2.getAttributes();
|
||||
if (attributes == null && attributes2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (attributes != null && attributes2 != null && attributes.getLength() == attributes2.getLength()) {
|
||||
HashMap hashMap = new HashMap();
|
||||
HashMap hashMap2 = new HashMap();
|
||||
for (int i = 0; i < attributes.getLength(); i++) {
|
||||
Node item = attributes.item(i);
|
||||
if (!"x,y,id,SceneLight,PROGRAM_BRANCH".contains(item.getNodeName())) {
|
||||
hashMap.put(item.getNodeName(), item.getNodeValue());
|
||||
}
|
||||
}
|
||||
for (int i2 = 0; i2 < attributes2.getLength(); i2++) {
|
||||
Node item2 = attributes2.item(i2);
|
||||
if (!"x,y,id,SceneLight,PROGRAM_BRANCH".contains(item2.getNodeName())) {
|
||||
hashMap2.put(item2.getNodeName(), item2.getNodeValue());
|
||||
}
|
||||
}
|
||||
if (hashMap.size() != hashMap2.size()) {
|
||||
return false;
|
||||
}
|
||||
for (String str : hashMap.keySet()) {
|
||||
if (!((String) hashMap.get(str)).equals(hashMap2.get(str))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean compareEmotion(Node node, Node node2) {
|
||||
BlocklyEmotion blocklyEmotion = (BlocklyEmotion) JsonHelper.a(node.getNodeValue(), (Class<?>) BlocklyEmotion.class);
|
||||
BlocklyEmotion blocklyEmotion2 = (BlocklyEmotion) JsonHelper.a(node2.getNodeValue(), (Class<?>) BlocklyEmotion.class);
|
||||
if (blocklyEmotion == null && blocklyEmotion2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (blocklyEmotion == null || blocklyEmotion2 == null) {
|
||||
return false;
|
||||
}
|
||||
return blocklyEmotion.equals(blocklyEmotion2);
|
||||
}
|
||||
|
||||
private boolean compareLight(Node node, Node node2) {
|
||||
BlocklyLight blocklyLight = (BlocklyLight) JsonHelper.a(node.getNodeValue(), (Class<?>) BlocklyLight.class);
|
||||
BlocklyLight blocklyLight2 = (BlocklyLight) JsonHelper.a(node2.getNodeValue(), (Class<?>) BlocklyLight.class);
|
||||
if (blocklyLight == null && blocklyLight2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (blocklyLight == null || blocklyLight2 == null) {
|
||||
return false;
|
||||
}
|
||||
return blocklyLight.equals(blocklyLight2);
|
||||
}
|
||||
|
||||
private boolean compareSound(Node node, Node node2) {
|
||||
JimuSound jimuSound = (JimuSound) JsonHelper.a(node.getNodeValue(), (Class<?>) JimuSound.class);
|
||||
JimuSound jimuSound2 = (JimuSound) JsonHelper.a(node2.getNodeValue(), (Class<?>) JimuSound.class);
|
||||
if (jimuSound == null && jimuSound2 == null) {
|
||||
return true;
|
||||
}
|
||||
if (jimuSound == null || jimuSound2 == null) {
|
||||
return false;
|
||||
}
|
||||
return jimuSound.equals(jimuSound2);
|
||||
}
|
||||
|
||||
private boolean compareTextNode(Node node, Node node2) {
|
||||
NamedNodeMap attributes = node.getParentNode().getAttributes();
|
||||
for (int i = 0; i < attributes.getLength(); i++) {
|
||||
Node item = attributes.item(i);
|
||||
if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "PROGRAM_BRANCH".equals(item.getNodeValue())) {
|
||||
return true;
|
||||
}
|
||||
if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "Effect".equals(item.getNodeValue())) {
|
||||
return compareSound(node, node2);
|
||||
}
|
||||
if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "Light".equals(item.getNodeValue())) {
|
||||
return compareLight(node, node2);
|
||||
}
|
||||
if (MediationMetaData.KEY_NAME.equals(item.getNodeName()) && "Emotion".equals(item.getNodeValue())) {
|
||||
return compareEmotion(node, node2);
|
||||
}
|
||||
}
|
||||
return node.getNodeValue().equals(node2.getNodeValue());
|
||||
}
|
||||
|
||||
private String getNodeId(Node node) {
|
||||
if (node == null) {
|
||||
return "-1";
|
||||
}
|
||||
if (!node.hasAttributes()) {
|
||||
return getNodeId(node.getParentNode());
|
||||
}
|
||||
NamedNodeMap attributes = node.getAttributes();
|
||||
for (int i = 0; i < attributes.getLength(); i++) {
|
||||
Node item = attributes.item(i);
|
||||
if (JockstickDataConverter.ID.equals(item.getNodeName())) {
|
||||
return item.getNodeValue();
|
||||
}
|
||||
}
|
||||
return getNodeId(node.getParentNode());
|
||||
}
|
||||
|
||||
public static void main(String[] strArr) {
|
||||
System.out.println(new BlocklyDomCompare().check(new File("C:\\Users\\lenovo\\Desktop\\2018\\Jimu-开发设计文档\\Jimu3.0-android\\课程\\standarXml.xml"), new File("C:\\Users\\lenovo\\Desktop\\2018\\Jimu-开发设计文档\\Jimu3.0-android\\课程\\currentXml.xml")));
|
||||
System.out.println("-------华丽的分割线-----------");
|
||||
}
|
||||
|
||||
private void traverse(Node node) {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
if (node.hasChildNodes()) {
|
||||
NodeList childNodes = node.getChildNodes();
|
||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||
Node item = childNodes.item(i);
|
||||
if (item.hasChildNodes()) {
|
||||
System.out.println(item.getNodeName());
|
||||
NamedNodeMap attributes = item.getAttributes();
|
||||
if (attributes != null) {
|
||||
for (int i2 = 0; i2 < attributes.getLength(); i2++) {
|
||||
Node item2 = attributes.item(i2);
|
||||
System.out.println("属性:" + item2.getNodeName() + ":" + item2.getNodeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
traverse(item);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (node.getNodeType() == 3) {
|
||||
System.out.println("文本节点:" + node.getNodeName() + ":" + node.getNodeValue());
|
||||
return;
|
||||
}
|
||||
if (node.getNodeValue() != null && !"".equals(node.getNodeValue().trim())) {
|
||||
System.out.println("非文本节点:" + node.getNodeName() + ":" + node.getNodeValue());
|
||||
}
|
||||
NamedNodeMap attributes2 = node.getAttributes();
|
||||
if (attributes2 != null) {
|
||||
for (int i3 = 0; i3 < attributes2.getLength(); i3++) {
|
||||
Node item3 = attributes2.item(i3);
|
||||
System.out.println("属性:" + item3.getNodeName() + ":" + item3.getNodeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String check(File file, File file2) {
|
||||
try {
|
||||
Document a = XmlHelper.a(file);
|
||||
Document a2 = XmlHelper.a(file2);
|
||||
Element documentElement = a.getDocumentElement();
|
||||
Element documentElement2 = a2.getDocumentElement();
|
||||
removeWhiteSpaceTextElement(documentElement);
|
||||
removeWhiteSpaceTextElement(documentElement2);
|
||||
return checkProgramDocument(documentElement, documentElement2);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "-1";
|
||||
}
|
||||
}
|
||||
|
||||
public int removeWhiteSpaceTextElement(Node node) {
|
||||
int i = 0;
|
||||
if (node == null) {
|
||||
return 0;
|
||||
}
|
||||
if (node.getNodeType() == 1) {
|
||||
Node firstChild = node.getFirstChild();
|
||||
while (firstChild != null) {
|
||||
Node nextSibling = firstChild.getNextSibling();
|
||||
i += removeWhiteSpaceTextElement(firstChild);
|
||||
firstChild = nextSibling;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
if (node.getNodeType() != 3) {
|
||||
return 0;
|
||||
}
|
||||
Text text = (Text) node;
|
||||
if (!text.getData().trim().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
text.getParentNode().removeChild(text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* JADX ERROR: Types fix failed
|
||||
jadx.core.utils.exceptions.JadxOverflowException: Type inference error: updates count limit reached
|
||||
at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:59)
|
||||
at jadx.core.utils.ErrorsCounter.error(ErrorsCounter.java:31)
|
||||
at jadx.core.dex.attributes.nodes.NotificationAttrNode.addError(NotificationAttrNode.java:19)
|
||||
at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:96)
|
||||
*/
|
||||
public java.lang.String check(java.lang.String r8, java.lang.String r9) {
|
||||
/*
|
||||
r7 = this;
|
||||
java.lang.String r0 = "-1"
|
||||
org.w3c.dom.Document r8 = com.ubtech.utils.XmlHelper.a(r8) // Catch: java.lang.Exception -> L61
|
||||
org.w3c.dom.Document r9 = com.ubtech.utils.XmlHelper.a(r9) // Catch: java.lang.Exception -> L61
|
||||
org.w3c.dom.Element r8 = r8.getDocumentElement() // Catch: java.lang.Exception -> L61
|
||||
org.w3c.dom.Element r9 = r9.getDocumentElement() // Catch: java.lang.Exception -> L61
|
||||
r7.removeWhiteSpaceTextElement(r8) // Catch: java.lang.Exception -> L61
|
||||
r7.removeWhiteSpaceTextElement(r9) // Catch: java.lang.Exception -> L61
|
||||
org.w3c.dom.NodeList r1 = r8.getChildNodes() // Catch: java.lang.Exception -> L61
|
||||
org.w3c.dom.NodeList r2 = r9.getChildNodes() // Catch: java.lang.Exception -> L61
|
||||
int r3 = r1.getLength() // Catch: java.lang.Exception -> L61
|
||||
r4 = 1
|
||||
if (r3 != r4) goto L2c
|
||||
java.lang.String r8 = r7.checkProgramDocument(r8, r9) // Catch: java.lang.Exception -> L61
|
||||
goto L66
|
||||
L2c:
|
||||
r8 = 0
|
||||
r9 = 0
|
||||
L2e:
|
||||
int r3 = r1.getLength() // Catch: java.lang.Exception -> L61
|
||||
if (r9 >= r3) goto L65
|
||||
org.w3c.dom.Node r3 = r1.item(r9) // Catch: java.lang.Exception -> L61
|
||||
r5 = r0
|
||||
r0 = 0
|
||||
L3a:
|
||||
int r6 = r2.getLength() // Catch: java.lang.Exception -> L5e
|
||||
if (r0 >= r6) goto L55
|
||||
org.w3c.dom.Node r6 = r2.item(r0) // Catch: java.lang.Exception -> L5e
|
||||
java.lang.String r5 = r7.checkProgramDocument(r3, r6) // Catch: java.lang.Exception -> L5e
|
||||
java.lang.String r6 = "0"
|
||||
boolean r6 = r6.equals(r5) // Catch: java.lang.Exception -> L5e
|
||||
if (r6 == 0) goto L52
|
||||
r0 = 1
|
||||
goto L56
|
||||
L52:
|
||||
int r0 = r0 + 1
|
||||
goto L3a
|
||||
L55:
|
||||
r0 = 0
|
||||
L56:
|
||||
if (r0 == 0) goto L5c
|
||||
int r9 = r9 + 1
|
||||
r0 = r5
|
||||
goto L2e
|
||||
L5c:
|
||||
r8 = r5
|
||||
goto L66
|
||||
L5e:
|
||||
r8 = move-exception
|
||||
r0 = r5
|
||||
goto L62
|
||||
L61:
|
||||
r8 = move-exception
|
||||
L62:
|
||||
r8.printStackTrace()
|
||||
L65:
|
||||
r8 = r0
|
||||
L66:
|
||||
return r8
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.blockly.feature.course.BlocklyDomCompare.check(java.lang.String, java.lang.String):java.lang.String");
|
||||
}
|
||||
}
|
||||
25
sources/com/ubt/jimu/blockly/feature/course/Rule.java
Normal file
25
sources/com/ubt/jimu/blockly/feature/course/Rule.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.ubt.jimu.blockly.feature.course;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Rule {
|
||||
private String id;
|
||||
private List<String> name;
|
||||
|
||||
public Rule() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<String> getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Rule(String str, List<String> list) {
|
||||
this.id = str;
|
||||
this.name = list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ubt.jimu.blockly.feature.sensor;
|
||||
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum DeviceDirection {
|
||||
NONE(TransportFile.TYPE_NONE, 0),
|
||||
LEFT("left", 1),
|
||||
RIGHT("right", 2),
|
||||
UP("up", 3),
|
||||
DOWN("down", 4),
|
||||
SWING("swing", 5);
|
||||
|
||||
private int type;
|
||||
private String value;
|
||||
|
||||
DeviceDirection(String str, int i) {
|
||||
this.value = str;
|
||||
this.type = i;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.ubt.jimu.blockly.feature.sensor;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import com.ubt.jimu.blockly.command.result.QueryResult;
|
||||
import com.ubt.jimu.blockly.feature.blockly.JimuSensor;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DirectionSensorEventListener implements SensorEventListener {
|
||||
private long currentUpdateTime;
|
||||
private long lastUpdateTime;
|
||||
private IShakeListener shakeListener;
|
||||
private long timeInterval;
|
||||
private final String TAG = DirectionSensorEventListener.class.getSimpleName();
|
||||
private float[] accelerometerValues = new float[3];
|
||||
private float[] magneticFieldValues = new float[3];
|
||||
private final int SPEED_SHRESHOLD = 17;
|
||||
private final int UPTATE_INTERVAL_TIME = 100;
|
||||
private float xAcceleration = 0.0f;
|
||||
private float yAcceleration = 0.0f;
|
||||
private boolean shake = false;
|
||||
private float radios = 0.5f;
|
||||
|
||||
public interface IShakeListener {
|
||||
void onShake(long j, float[] fArr);
|
||||
}
|
||||
|
||||
public DirectionSensorEventListener(IShakeListener iShakeListener) {
|
||||
this.shakeListener = iShakeListener;
|
||||
}
|
||||
|
||||
private void calculateOrientation() {
|
||||
float[] fArr = new float[3];
|
||||
float[] fArr2 = new float[9];
|
||||
SensorManager.getRotationMatrix(fArr2, null, this.accelerometerValues, this.magneticFieldValues);
|
||||
SensorManager.getOrientation(fArr2, fArr);
|
||||
this.xAcceleration = fArr[1];
|
||||
this.yAcceleration = fArr[2];
|
||||
getDeviceDirection();
|
||||
}
|
||||
|
||||
private void notifyDirectionChange(int i) {
|
||||
QueryResult queryResult = new QueryResult();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(new JimuSensor(JimuSensor.SensorType.Phone, 1, i));
|
||||
queryResult.setPhone(arrayList);
|
||||
SensorObservable.getInstance().setData(queryResult);
|
||||
}
|
||||
|
||||
public boolean directionNotChange() {
|
||||
float f = this.xAcceleration;
|
||||
float f2 = this.radios;
|
||||
if (f > (-f2) && f < f2) {
|
||||
float f3 = this.yAcceleration;
|
||||
if (f3 > (-f2) && f3 < f2 && !this.shake) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized DeviceDirection getDeviceDirection() {
|
||||
DeviceDirection deviceDirection = DeviceDirection.NONE;
|
||||
if (this.xAcceleration == 0.0f && this.yAcceleration == 0.0f) {
|
||||
return deviceDirection;
|
||||
}
|
||||
if (Math.abs(this.xAcceleration) > Math.abs(this.yAcceleration)) {
|
||||
if (this.xAcceleration < (-this.radios)) {
|
||||
notifyDirectionChange(DeviceDirection.RIGHT.getType());
|
||||
deviceDirection = DeviceDirection.RIGHT;
|
||||
} else if (this.xAcceleration > this.radios) {
|
||||
notifyDirectionChange(DeviceDirection.LEFT.getType());
|
||||
deviceDirection = DeviceDirection.LEFT;
|
||||
}
|
||||
} else if (this.yAcceleration >= this.radios) {
|
||||
notifyDirectionChange(DeviceDirection.UP.getType());
|
||||
deviceDirection = DeviceDirection.UP;
|
||||
} else if (this.yAcceleration < (-this.radios)) {
|
||||
notifyDirectionChange(DeviceDirection.DOWN.getType());
|
||||
deviceDirection = DeviceDirection.DOWN;
|
||||
}
|
||||
return deviceDirection;
|
||||
}
|
||||
|
||||
public float getxAcceleration() {
|
||||
return this.xAcceleration;
|
||||
}
|
||||
|
||||
public float getyAcceleration() {
|
||||
return this.yAcceleration;
|
||||
}
|
||||
|
||||
public boolean isShake() {
|
||||
return this.shake;
|
||||
}
|
||||
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onAccuracyChanged(Sensor sensor, int i) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
||||
this.currentUpdateTime = System.currentTimeMillis();
|
||||
long j = this.currentUpdateTime;
|
||||
this.timeInterval = j - this.lastUpdateTime;
|
||||
if (this.timeInterval < 100) {
|
||||
return;
|
||||
}
|
||||
this.lastUpdateTime = j;
|
||||
if (sensorEvent.sensor.getType() == 2) {
|
||||
this.magneticFieldValues = sensorEvent.values;
|
||||
}
|
||||
if (sensorEvent.sensor.getType() == 1) {
|
||||
float[] fArr = sensorEvent.values;
|
||||
this.accelerometerValues = fArr;
|
||||
if (this.shakeListener != null) {
|
||||
float f = fArr[0];
|
||||
float f2 = fArr[1];
|
||||
float f3 = fArr[2];
|
||||
if (Math.abs(f) >= 17.0f || Math.abs(f2) >= 17.0f || Math.abs(f3) >= 17.0f) {
|
||||
notifyDirectionChange(DeviceDirection.SWING.getType());
|
||||
this.shakeListener.onShake(this.currentUpdateTime, sensorEvent.values);
|
||||
this.shake = true;
|
||||
} else {
|
||||
this.shake = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
calculateOrientation();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
package com.ubt.jimu.blockly.feature.sensor;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.view.WindowManager;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.blockly.command.result.QueryResult;
|
||||
import com.ubt.jimu.blockly.feature.blockly.JimuSensor;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DirectionSensorEventListerCompact implements SensorEventListener {
|
||||
private static final float CHANGE_RADIO = 2.5f;
|
||||
private static final int INTERVAL_TIME = 100;
|
||||
private static final float SHAKE_RADIO = 1.5f;
|
||||
private static final int SPEED_SHRESHOLD = 12;
|
||||
private static final double mDegress = 20.0d;
|
||||
private static final float mGravity = 9.80665f;
|
||||
private long currentUpdateTime;
|
||||
private boolean isShaking;
|
||||
private long lastUpdateTime;
|
||||
private ActionListener listener;
|
||||
private int rotation;
|
||||
private final String TAG = DirectionSensorEventListerCompact.class.getSimpleName();
|
||||
private DeviceDirection dd = DeviceDirection.NONE;
|
||||
|
||||
public interface ActionListener {
|
||||
void onBottomUp();
|
||||
|
||||
void onChange(float[] fArr);
|
||||
|
||||
void onLeftUp();
|
||||
|
||||
void onNormal();
|
||||
|
||||
void onRightUp();
|
||||
|
||||
void onShake(long j, float[] fArr);
|
||||
|
||||
void onTopUp();
|
||||
}
|
||||
|
||||
public DirectionSensorEventListerCompact(ActionListener actionListener) {
|
||||
this.listener = actionListener;
|
||||
}
|
||||
|
||||
private void bottom() {
|
||||
log("下倾斜");
|
||||
DeviceDirection deviceDirection = DeviceDirection.DOWN;
|
||||
this.dd = deviceDirection;
|
||||
notifyDirectionChange(deviceDirection);
|
||||
ActionListener actionListener = this.listener;
|
||||
if (actionListener != null) {
|
||||
actionListener.onBottomUp();
|
||||
}
|
||||
}
|
||||
|
||||
private void left() {
|
||||
log("左倾斜");
|
||||
DeviceDirection deviceDirection = DeviceDirection.LEFT;
|
||||
this.dd = deviceDirection;
|
||||
notifyDirectionChange(deviceDirection);
|
||||
ActionListener actionListener = this.listener;
|
||||
if (actionListener != null) {
|
||||
actionListener.onLeftUp();
|
||||
}
|
||||
}
|
||||
|
||||
private void log(String str) {
|
||||
ALog.a(this.TAG).d(str);
|
||||
}
|
||||
|
||||
private void normal() {
|
||||
log("normal");
|
||||
DeviceDirection deviceDirection = DeviceDirection.NONE;
|
||||
this.dd = deviceDirection;
|
||||
notifyDirectionChange(deviceDirection);
|
||||
ActionListener actionListener = this.listener;
|
||||
if (actionListener != null) {
|
||||
actionListener.onNormal();
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyDirectionChange(DeviceDirection deviceDirection) {
|
||||
QueryResult queryResult = new QueryResult();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.add(new JimuSensor(JimuSensor.SensorType.Phone, 1, deviceDirection.getType()));
|
||||
queryResult.setPhone(arrayList);
|
||||
SensorObservable.getInstance().setData(queryResult);
|
||||
}
|
||||
|
||||
private void right() {
|
||||
log("右倾斜");
|
||||
DeviceDirection deviceDirection = DeviceDirection.RIGHT;
|
||||
this.dd = deviceDirection;
|
||||
notifyDirectionChange(deviceDirection);
|
||||
ActionListener actionListener = this.listener;
|
||||
if (actionListener != null) {
|
||||
actionListener.onRightUp();
|
||||
}
|
||||
}
|
||||
|
||||
private void top() {
|
||||
log("上倾斜");
|
||||
DeviceDirection deviceDirection = DeviceDirection.UP;
|
||||
this.dd = deviceDirection;
|
||||
notifyDirectionChange(deviceDirection);
|
||||
ActionListener actionListener = this.listener;
|
||||
if (actionListener != null) {
|
||||
actionListener.onTopUp();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean directionNotChange() {
|
||||
return this.dd == DeviceDirection.NONE;
|
||||
}
|
||||
|
||||
public DeviceDirection getDeviceDirection() {
|
||||
return this.dd;
|
||||
}
|
||||
|
||||
public boolean isShaking() {
|
||||
return this.isShaking;
|
||||
}
|
||||
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onAccuracyChanged(Sensor sensor, int i) {
|
||||
}
|
||||
|
||||
@Override // android.hardware.SensorEventListener
|
||||
public void onSensorChanged(SensorEvent sensorEvent) {
|
||||
this.rotation = ((WindowManager) JimuApplication.l().getSystemService("window")).getDefaultDisplay().getRotation();
|
||||
this.currentUpdateTime = System.currentTimeMillis();
|
||||
long j = this.currentUpdateTime;
|
||||
if (j - this.lastUpdateTime < 100) {
|
||||
return;
|
||||
}
|
||||
this.lastUpdateTime = j;
|
||||
float[] fArr = sensorEvent.values;
|
||||
float f = fArr[0];
|
||||
float f2 = fArr[1];
|
||||
float f3 = fArr[2];
|
||||
double degrees = Math.toDegrees(Math.tan(f / mGravity));
|
||||
double degrees2 = Math.toDegrees(Math.tan(f2 / mGravity));
|
||||
double degrees3 = Math.toDegrees(Math.tan(f3 / mGravity));
|
||||
log("X轴: " + f + " y轴: " + f2 + " z轴: " + f3);
|
||||
log("x轴: " + degrees + " y轴: " + degrees2 + " z轴: " + degrees3 + "----方向:" + this.rotation);
|
||||
if (Math.abs(f) >= 12.0f || Math.abs(f2) >= 12.0f || Math.abs(f3) >= 12.0f) {
|
||||
DeviceDirection deviceDirection = DeviceDirection.SWING;
|
||||
this.dd = deviceDirection;
|
||||
this.isShaking = true;
|
||||
notifyDirectionChange(deviceDirection);
|
||||
this.listener.onShake(this.currentUpdateTime, sensorEvent.values);
|
||||
return;
|
||||
}
|
||||
this.isShaking = false;
|
||||
if (Math.abs(degrees) >= Math.abs(degrees2) && Math.abs(degrees) > mDegress) {
|
||||
log("X坐标大于Y坐标");
|
||||
int i = this.rotation;
|
||||
if (i != 0) {
|
||||
if (i != 1) {
|
||||
if (i != 2) {
|
||||
if (i == 3) {
|
||||
if (degrees > 0.0d) {
|
||||
top();
|
||||
} else {
|
||||
bottom();
|
||||
}
|
||||
}
|
||||
} else if (degrees > 0.0d) {
|
||||
right();
|
||||
} else {
|
||||
left();
|
||||
}
|
||||
} else if (degrees > 0.0d) {
|
||||
bottom();
|
||||
} else {
|
||||
top();
|
||||
}
|
||||
} else if (degrees > 0.0d) {
|
||||
left();
|
||||
} else {
|
||||
right();
|
||||
}
|
||||
} else if (Math.abs(degrees) >= Math.abs(degrees2) || Math.abs(degrees2) <= mDegress) {
|
||||
normal();
|
||||
} else {
|
||||
log("Y坐标大于X坐标");
|
||||
int i2 = this.rotation;
|
||||
if (i2 != 0) {
|
||||
if (i2 != 1) {
|
||||
if (i2 != 2) {
|
||||
if (i2 == 3) {
|
||||
if (degrees2 > 0.0d) {
|
||||
left();
|
||||
} else {
|
||||
right();
|
||||
}
|
||||
}
|
||||
} else if (degrees2 > 0.0d) {
|
||||
top();
|
||||
} else {
|
||||
bottom();
|
||||
}
|
||||
} else if (degrees2 > 0.0d) {
|
||||
right();
|
||||
} else {
|
||||
left();
|
||||
}
|
||||
} else if (degrees2 > 0.0d) {
|
||||
bottom();
|
||||
} else {
|
||||
top();
|
||||
}
|
||||
}
|
||||
if (Math.abs(f2) >= CHANGE_RADIO || Math.abs(f) >= CHANGE_RADIO) {
|
||||
return;
|
||||
}
|
||||
this.dd = DeviceDirection.NONE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.ubt.jimu.blockly.feature.sensor;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ManagerHelper {
|
||||
private Context context;
|
||||
private SensorManager manager;
|
||||
|
||||
public ManagerHelper(Context context) {
|
||||
this.context = context;
|
||||
this.manager = (SensorManager) context.getSystemService("sensor");
|
||||
}
|
||||
|
||||
private boolean hasSensor(SensorManager sensorManager, int i) {
|
||||
List<Sensor> sensorList;
|
||||
if (sensorManager == null || (sensorList = sensorManager.getSensorList(-1)) == null || sensorList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
Iterator<Sensor> it = sensorList.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (it.next().getType() == i) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean registerListener(SensorEventListener sensorEventListener, int i, int i2) {
|
||||
Sensor defaultSensor;
|
||||
if (hasSensor(this.manager, i) && (defaultSensor = this.manager.getDefaultSensor(i)) != null) {
|
||||
return this.manager.registerListener(sensorEventListener, defaultSensor, i2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void unRegisterListener(SensorEventListener sensorEventListener) {
|
||||
SensorManager sensorManager = this.manager;
|
||||
if (sensorManager != null) {
|
||||
sensorManager.unregisterListener(sensorEventListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ubt.jimu.blockly.feature.sensor;
|
||||
|
||||
import com.ubt.jimu.blockly.command.result.QueryResult;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SensorObservable extends Observable {
|
||||
private static SensorObservable instance;
|
||||
private final String TAG = SensorObservable.class.getSimpleName();
|
||||
private Observer activedObserver;
|
||||
private QueryResult data;
|
||||
|
||||
public static synchronized SensorObservable getInstance() {
|
||||
SensorObservable sensorObservable;
|
||||
synchronized (SensorObservable.class) {
|
||||
if (instance == null) {
|
||||
instance = new SensorObservable();
|
||||
}
|
||||
sensorObservable = instance;
|
||||
}
|
||||
return sensorObservable;
|
||||
}
|
||||
|
||||
public void clearActiveObserver() {
|
||||
this.activedObserver = null;
|
||||
}
|
||||
|
||||
@Override // java.util.Observable
|
||||
public synchronized void deleteObserver(Observer observer) {
|
||||
super.deleteObserver(observer);
|
||||
reActiveObserver();
|
||||
this.activedObserver = observer;
|
||||
}
|
||||
|
||||
public void reActiveObserver() {
|
||||
if (this.activedObserver != null) {
|
||||
ALog.a(this.TAG).d("重新监听观察者:");
|
||||
addObserver(this.activedObserver);
|
||||
this.activedObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setData(QueryResult queryResult) {
|
||||
if (countObservers() < 1) {
|
||||
return;
|
||||
}
|
||||
this.data = queryResult;
|
||||
setChanged();
|
||||
notifyObservers(queryResult);
|
||||
}
|
||||
}
|
||||
323
sources/com/ubt/jimu/blockly/feature/sensor/SensorObserver.java
Normal file
323
sources/com/ubt/jimu/blockly/feature/sensor/SensorObserver.java
Normal file
@@ -0,0 +1,323 @@
|
||||
package com.ubt.jimu.blockly.feature.sensor;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.ubt.jimu.blockly.command.result.QueryResult;
|
||||
import com.ubt.jimu.blockly.exception.BlocklyEvent;
|
||||
import com.ubt.jimu.blockly.feature.blockly.ColorSensor;
|
||||
import com.ubt.jimu.blockly.feature.blockly.JimuSensor;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SensorObserver implements Observer {
|
||||
private final String TAG = SensorObserver.class.getSimpleName();
|
||||
private String branchId;
|
||||
private String callback;
|
||||
private String operator;
|
||||
private String result;
|
||||
private String sensorId;
|
||||
private String sensorType;
|
||||
private String value;
|
||||
|
||||
public static class Compareration {
|
||||
public static final String OP_EQUALS = "EQ";
|
||||
public static final String OP_GREATER_THAN = "GTE";
|
||||
public static final String OP_LESS_THAN = "LTE";
|
||||
public static final String OP_NOT_EQUALS = "NEQ";
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:13:0x004e, code lost:
|
||||
|
||||
if (r1 == 1) goto L35;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:14:0x0050, code lost:
|
||||
|
||||
if (r1 == 2) goto L32;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:15:0x0052, code lost:
|
||||
|
||||
if (r1 == 3) goto L29;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:17:0x0057, code lost:
|
||||
|
||||
if (r7 == r9) goto L45;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:20:?, code lost:
|
||||
|
||||
return false;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:21:?, code lost:
|
||||
|
||||
return false;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:23:0x005d, code lost:
|
||||
|
||||
if (r7 > r9) goto L47;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:24:?, code lost:
|
||||
|
||||
return false;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:26:0x0062, code lost:
|
||||
|
||||
if (r7 != r9) goto L48;
|
||||
*/
|
||||
/* JADX WARN: Code restructure failed: missing block: B:27:?, code lost:
|
||||
|
||||
return false;
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public static boolean compare(java.lang.String r7, java.lang.String r8, java.lang.String r9) {
|
||||
/*
|
||||
r0 = 0
|
||||
float r7 = java.lang.Float.parseFloat(r7) // Catch: java.lang.NumberFormatException -> L6a
|
||||
float r9 = java.lang.Float.parseFloat(r9) // Catch: java.lang.NumberFormatException -> L6a
|
||||
r1 = -1
|
||||
int r2 = r8.hashCode() // Catch: java.lang.NumberFormatException -> L6a
|
||||
r3 = 2220(0x8ac, float:3.111E-42)
|
||||
r4 = 3
|
||||
r5 = 2
|
||||
r6 = 1
|
||||
if (r2 == r3) goto L43
|
||||
r3 = 70904(0x114f8, float:9.9358E-41)
|
||||
if (r2 == r3) goto L39
|
||||
r3 = 75709(0x127bd, float:1.06091E-40)
|
||||
if (r2 == r3) goto L2f
|
||||
r3 = 77178(0x12d7a, float:1.0815E-40)
|
||||
if (r2 == r3) goto L25
|
||||
goto L4c
|
||||
L25:
|
||||
java.lang.String r2 = "NEQ"
|
||||
boolean r8 = r8.equals(r2) // Catch: java.lang.NumberFormatException -> L6a
|
||||
if (r8 == 0) goto L4c
|
||||
r1 = 3
|
||||
goto L4c
|
||||
L2f:
|
||||
java.lang.String r2 = "LTE"
|
||||
boolean r8 = r8.equals(r2) // Catch: java.lang.NumberFormatException -> L6a
|
||||
if (r8 == 0) goto L4c
|
||||
r1 = 2
|
||||
goto L4c
|
||||
L39:
|
||||
java.lang.String r2 = "GTE"
|
||||
boolean r8 = r8.equals(r2) // Catch: java.lang.NumberFormatException -> L6a
|
||||
if (r8 == 0) goto L4c
|
||||
r1 = 0
|
||||
goto L4c
|
||||
L43:
|
||||
java.lang.String r2 = "EQ"
|
||||
boolean r8 = r8.equals(r2) // Catch: java.lang.NumberFormatException -> L6a
|
||||
if (r8 == 0) goto L4c
|
||||
r1 = 1
|
||||
L4c:
|
||||
if (r1 == 0) goto L65
|
||||
if (r1 == r6) goto L60
|
||||
if (r1 == r5) goto L5b
|
||||
if (r1 == r4) goto L55
|
||||
goto L77
|
||||
L55:
|
||||
int r7 = (r7 > r9 ? 1 : (r7 == r9 ? 0 : -1))
|
||||
if (r7 == 0) goto L77
|
||||
L59:
|
||||
r0 = 1
|
||||
goto L77
|
||||
L5b:
|
||||
int r7 = (r7 > r9 ? 1 : (r7 == r9 ? 0 : -1))
|
||||
if (r7 > 0) goto L77
|
||||
goto L59
|
||||
L60:
|
||||
int r7 = (r7 > r9 ? 1 : (r7 == r9 ? 0 : -1))
|
||||
if (r7 != 0) goto L77
|
||||
goto L59
|
||||
L65:
|
||||
int r7 = (r7 > r9 ? 1 : (r7 == r9 ? 0 : -1))
|
||||
if (r7 < 0) goto L77
|
||||
goto L59
|
||||
L6a:
|
||||
r7 = move-exception
|
||||
r7.printStackTrace()
|
||||
java.lang.String r7 = r7.getMessage()
|
||||
java.lang.String r8 = "Comparation"
|
||||
android.util.Log.e(r8, r7)
|
||||
L77:
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.blockly.feature.sensor.SensorObserver.Compareration.compare(java.lang.String, java.lang.String, java.lang.String):boolean");
|
||||
}
|
||||
}
|
||||
|
||||
private void check(Observable observable, QueryResult queryResult) {
|
||||
if (TextUtils.isEmpty(this.sensorId)) {
|
||||
return;
|
||||
}
|
||||
if (JimuSensor.SensorType.Infrared.sameSensor(this.sensorType)) {
|
||||
checkInfrared(observable, queryResult);
|
||||
return;
|
||||
}
|
||||
if (JimuSensor.SensorType.Gyroscope.sameSensor(this.sensorType)) {
|
||||
checkGyroscope(observable, queryResult);
|
||||
return;
|
||||
}
|
||||
if (JimuSensor.SensorType.Touch.sameSensor(this.sensorType)) {
|
||||
checkTouch(observable, queryResult);
|
||||
return;
|
||||
}
|
||||
if (JimuSensor.SensorType.Phone.sameSensor(this.sensorType)) {
|
||||
checkPhone(observable, queryResult);
|
||||
} else if (JimuSensor.SensorType.ULTRASONIC.sameSensor(this.sensorType)) {
|
||||
checkUltrasonic(observable, queryResult);
|
||||
} else if (JimuSensor.SensorType.COLOR.sameSensor(this.sensorType)) {
|
||||
checkColor(observable, queryResult);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkColor(Observable observable, QueryResult queryResult) {
|
||||
List<ColorSensor> color = queryResult.getColor();
|
||||
if (color == null || color.size() == 0) {
|
||||
return;
|
||||
}
|
||||
for (ColorSensor colorSensor : color) {
|
||||
if (!TextUtils.isEmpty(this.sensorId) && this.sensorId.equals(String.valueOf(colorSensor.getId()))) {
|
||||
if (Compareration.OP_EQUALS.equals(this.operator)) {
|
||||
if (!TextUtils.isEmpty(colorSensor.getColor()) && colorSensor.getColor().equals(this.value)) {
|
||||
setJSResult(this.callback, this.branchId, colorSensor.getColor());
|
||||
observable.deleteObserver(this);
|
||||
return;
|
||||
}
|
||||
} else if (Compareration.OP_NOT_EQUALS.equals(this.operator) && !TextUtils.isEmpty(colorSensor.getColor()) && !colorSensor.getColor().equals(this.value)) {
|
||||
setJSResult(this.callback, this.branchId, colorSensor.getColor());
|
||||
observable.deleteObserver(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGyroscope(Observable observable, QueryResult queryResult) {
|
||||
}
|
||||
|
||||
private void checkInfrared(Observable observable, QueryResult queryResult) {
|
||||
List<JimuSensor> infrared = queryResult.getInfrared();
|
||||
if (infrared == null || infrared.size() < 1) {
|
||||
return;
|
||||
}
|
||||
Iterator<JimuSensor> it = infrared.iterator();
|
||||
while (it.hasNext() && !setResult(observable, it.next())) {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPhone(Observable observable, QueryResult queryResult) {
|
||||
List<JimuSensor> phone = queryResult.getPhone();
|
||||
if (phone == null || phone.size() < 1) {
|
||||
return;
|
||||
}
|
||||
this.result = phone.get(0).getResult() + "";
|
||||
int i = -1;
|
||||
DeviceDirection[] values = DeviceDirection.values();
|
||||
int length = values.length;
|
||||
int i2 = 0;
|
||||
while (true) {
|
||||
if (i2 >= length) {
|
||||
break;
|
||||
}
|
||||
DeviceDirection deviceDirection = values[i2];
|
||||
if (deviceDirection.getValue().equals(this.value)) {
|
||||
i = deviceDirection.getType();
|
||||
break;
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
if (Compareration.compare(this.result, this.operator, i + "")) {
|
||||
setJSResult(this.callback, this.branchId, this.result);
|
||||
observable.deleteObserver(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkTouch(Observable observable, QueryResult queryResult) {
|
||||
List<JimuSensor> touch = queryResult.getTouch();
|
||||
if (touch == null || touch.size() < 1) {
|
||||
return;
|
||||
}
|
||||
for (JimuSensor jimuSensor : touch) {
|
||||
if (this.sensorId.equals(jimuSensor.getId() + "")) {
|
||||
this.result = jimuSensor.getResult() + "";
|
||||
if (Compareration.compare(this.result, this.operator, this.value)) {
|
||||
setJSResult(this.callback, this.branchId, this.result);
|
||||
if (observable instanceof SensorObservable) {
|
||||
((SensorObservable) observable).reActiveObserver();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUltrasonic(Observable observable, QueryResult queryResult) {
|
||||
List<JimuSensor> ultrasonic = queryResult.getUltrasonic();
|
||||
if (ultrasonic == null || ultrasonic.size() < 1) {
|
||||
return;
|
||||
}
|
||||
Iterator<JimuSensor> it = ultrasonic.iterator();
|
||||
while (it.hasNext() && !setResult(observable, it.next())) {
|
||||
}
|
||||
}
|
||||
|
||||
private void setJSResult(String str, String... strArr) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("javascript:");
|
||||
sb.append(str);
|
||||
sb.append("(");
|
||||
if (strArr != null && strArr.length > 0) {
|
||||
for (int i = 0; i < strArr.length; i++) {
|
||||
sb.append("'");
|
||||
sb.append(strArr[i]);
|
||||
sb.append("'");
|
||||
if (i < strArr.length - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
String sb2 = sb.toString();
|
||||
Log.i(this.TAG, sb2);
|
||||
EventBus.b().b(new BlocklyEvent(1004, sb2));
|
||||
}
|
||||
|
||||
private boolean setResult(Observable observable, JimuSensor jimuSensor) {
|
||||
if (!this.sensorId.equals(jimuSensor.getId() + "")) {
|
||||
return false;
|
||||
}
|
||||
this.result = jimuSensor.getResult() + "";
|
||||
if (Compareration.compare(this.result, this.operator, this.value)) {
|
||||
setJSResult(this.callback, this.branchId, this.result);
|
||||
observable.deleteObserver(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof SensorObserver)) {
|
||||
return false;
|
||||
}
|
||||
SensorObserver sensorObserver = (SensorObserver) obj;
|
||||
return !TextUtils.isEmpty(sensorObserver.branchId) && sensorObserver.branchId.equals(this.branchId);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.branchId);
|
||||
}
|
||||
|
||||
@Override // java.util.Observer
|
||||
public void update(Observable observable, Object obj) {
|
||||
check(observable, (QueryResult) obj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,681 @@
|
||||
package com.ubt.jimu.blockly.networkSync;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.DatabaseUtils;
|
||||
import com.ubt.jimu.base.http.ApiResponse;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProgramsReturnBean;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProjectParameter;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotionParameter;
|
||||
import com.ubt.jimu.blockly.bean.JimuMotionReturnBean;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.bean.JimuSoundParameter;
|
||||
import com.ubt.jimu.blockly.command.interaction.BlocklyUploadType;
|
||||
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuMotionDbHandler;
|
||||
import com.ubt.jimu.blockly.dao.JimuSoundDbHandler;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.JimuMotionHttpListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.RenameHttpListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.SimplifyDownloadListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.UploadBlocklyHttpListener;
|
||||
import com.ubt.jimu.blockly.networkSync.httpListener.UploadJimuSoundHttpListener;
|
||||
import com.ubt.jimu.blockly.networkSync.utils.QiNiuUtils;
|
||||
import com.ubt.jimu.transport3.api.DiyTransportServiceProxy;
|
||||
import com.ubt.jimu.transport3.bean.request.UploadAudioBean;
|
||||
import com.ubt.jimu.transport3.bean.request.UploadModelMotionBean;
|
||||
import com.ubt.jimu.transport3.bean.request.UploadModelProgramBean;
|
||||
import com.ubt.jimu.transport3.download.AsyncTransportFileDownloader;
|
||||
import com.ubt.jimu.upload.DataUploadProxy;
|
||||
import com.ubt.jimu.upload.SimpleUploadCallback;
|
||||
import com.ubt.jimu.upload.UploadFilePathUtils;
|
||||
import com.ubt.jimu.upload.UploadRequest;
|
||||
import com.ubt.jimu.upload.UploadResponse;
|
||||
import com.ubt.jimu.utils.FileTools;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import com.ubt.jimu.utils.SystemUtils;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BlocklySyncHttpImpl {
|
||||
private static BlocklySyncHttpImpl mBlocklySyncHttp;
|
||||
private CompositeDisposable disposables = new CompositeDisposable();
|
||||
private JimuMotionHttpListener jimuMotionHttpListener;
|
||||
private RenameHttpListener renameHttpListener;
|
||||
private UploadBlocklyHttpListener uploadBlocklyHttpListener;
|
||||
private UploadJimuSoundHttpListener uploadJimuSoundHttpListener;
|
||||
|
||||
/* renamed from: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl$13, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass13 {
|
||||
static final /* synthetic */ int[] $SwitchMap$com$ubt$jimu$blockly$command$interaction$BlocklyUploadType = new int[BlocklyUploadType.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
$SwitchMap$com$ubt$jimu$blockly$command$interaction$BlocklyUploadType[BlocklyUploadType.ADD_TYPE.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$ubt$jimu$blockly$command$interaction$BlocklyUploadType[BlocklyUploadType.UPDATE_TYPE.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
$SwitchMap$com$ubt$jimu$blockly$command$interaction$BlocklyUploadType[BlocklyUploadType.DELETE_TYPE.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BlocklySyncHttpImpl() {
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void compareLocalJimuMotionDb(List<JimuMotionReturnBean.ModelsBean> list) {
|
||||
JimuMotionDbHandler jimuMotionDbHandler = JimuMotionDbHandler.getInstance();
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
for (JimuMotionReturnBean.ModelsBean modelsBean : list) {
|
||||
JimuMotion jimuMotionById = jimuMotionDbHandler.getJimuMotionById(userId, modelsBean.getCustomModelId(), modelsBean.getPostureId());
|
||||
if (jimuMotionById != null && "1".equals(modelsBean.getIsDeleted())) {
|
||||
jimuMotionDbHandler.delete(jimuMotionById);
|
||||
} else if (jimuMotionById != null || !"1".equals(modelsBean.getIsDeleted())) {
|
||||
if ((jimuMotionById == null && "0".equals(modelsBean.getIsDeleted())) || (jimuMotionById != null && modelsBean.getLastUploadTime() > jimuMotionById.getLastUploadTime() && "0".equals(modelsBean.getIsDeleted()))) {
|
||||
JimuMotion modelBeanToJimuMotion = modelBeanToJimuMotion(modelsBean);
|
||||
modelBeanToJimuMotion.setIsFirst(1);
|
||||
modelBeanToJimuMotion.setIsUploadService(true);
|
||||
if (modelBeanToJimuMotion != null) {
|
||||
jimuMotionDbHandler.insertOrUpdate(modelBeanToJimuMotion);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void compareLocalJimuSoundBd(List<JimuSound> list) {
|
||||
JimuSoundDbHandler jimuSoundDbHandler = JimuSoundDbHandler.getInstance();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (JimuSound jimuSound : list) {
|
||||
if (!TextUtils.isEmpty(jimuSound.getAudioId()) && !TextUtils.isEmpty(jimuSound.getDescription())) {
|
||||
if ("1".equals(jimuSound.getIsDeleted())) {
|
||||
jimuSound.setLocalFilePath(QiNiuUtils.getLocalJimuSoundFilePath(jimuSound));
|
||||
jimuSoundDbHandler.deleteJimuSound(jimuSound);
|
||||
} else {
|
||||
JimuSound jimuSound2 = jimuSoundDbHandler.getJimuSound(jimuSound);
|
||||
if (jimuSound2 == null) {
|
||||
jimuSound.setLocalFilePath(QiNiuUtils.getLocalJimuSoundFilePath(jimuSound));
|
||||
arrayList.add(jimuSound);
|
||||
} else {
|
||||
long lastUploadTime = jimuSound2.getLastUploadTime();
|
||||
long lastUploadTime2 = jimuSound.getLastUploadTime();
|
||||
if (lastUploadTime < lastUploadTime2) {
|
||||
if (lastUploadTime >= lastUploadTime2 || jimuSound.getDescription().equals(jimuSound2.getDescription())) {
|
||||
arrayList.add(jimuSound2);
|
||||
} else {
|
||||
jimuSound2.setDescription(jimuSound.getDescription());
|
||||
jimuSoundDbHandler.insertOrUpdate(jimuSound2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
downloadJimuSound(arrayList);
|
||||
}
|
||||
|
||||
private void downloadJimuSound(List<JimuSound> list) {
|
||||
final JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
if (list == null || list.size() == 0) {
|
||||
return;
|
||||
}
|
||||
new AsyncTransportFileDownloader().downloadFile(list, new SimplifyDownloadListener<JimuSound>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.9
|
||||
@Override // com.ubt.jimu.blockly.networkSync.httpListener.SimplifyDownloadListener
|
||||
public void downloadSucceed(JimuSound jimuSound) {
|
||||
jimuSound.setIsUploadQiNiu(true);
|
||||
jimuSound.setIsSyncUbtService(true);
|
||||
jimuSoundDbHandler.insertOrUpdateFromService(jimuSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void downloaderBlocklyFile(List<BlocklyProject> list) {
|
||||
new AsyncTransportFileDownloader().downloadFile(list, new AsyncTransportFileDownloader.OnDownloadListener<BlocklyProject>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.5
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onBlockComplete(BlocklyProject blocklyProject) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onBlockError(BlocklyProject blocklyProject) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onCompleted() {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onBlockCompleted(BlocklyProject blocklyProject) {
|
||||
blocklyProject.setIsDeleted("0");
|
||||
blocklyProject.setUploadQiNiu(true);
|
||||
blocklyProject.setUploadService(true);
|
||||
blocklyProject.setIsFirst(1);
|
||||
BlocklyProjectDbHandler.getInstance().insertOrUpdate(blocklyProject);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public BlocklyProject getBlocklyProjectFromBlocklyProjectParametert(BlocklyProjectParameter blocklyProjectParameter) {
|
||||
BlocklyProject blocklyProject = new BlocklyProject();
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
String modelId = blocklyProjectParameter.getModelId();
|
||||
if (!TextUtils.isEmpty(modelId)) {
|
||||
blocklyProject.setModelId(Long.parseLong(modelId));
|
||||
}
|
||||
blocklyProject.setBlocklyType(blocklyProjectParameter.getBlocklyType());
|
||||
blocklyProject.setBlocklyVersion(blocklyProjectParameter.getBlocklyVersion());
|
||||
blocklyProject.setCustomModelId(blocklyProjectParameter.getCustomModelId());
|
||||
blocklyProject.setIsDeleted(blocklyProjectParameter.getIsDeleted());
|
||||
blocklyProject.setLastUploadTime(blocklyProjectParameter.getLastUploadTime());
|
||||
blocklyProject.setModelType(blocklyProjectParameter.getModelType());
|
||||
blocklyProject.setUserId(userId);
|
||||
blocklyProject.setXmlId(blocklyProjectParameter.getXmlId());
|
||||
blocklyProject.setXmlName(blocklyProjectParameter.getFileName());
|
||||
return blocklyProject;
|
||||
}
|
||||
|
||||
private BlocklyProject getBlocklyProjectFromModelsBean(BlocklyProgramsReturnBean.ModelsBean modelsBean) {
|
||||
BlocklyProject blocklyProject = new BlocklyProject();
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
blocklyProject.setXmlName(modelsBean.getFileName());
|
||||
blocklyProject.setXmlId(modelsBean.getXmlId());
|
||||
blocklyProject.setUserId(userId);
|
||||
blocklyProject.setModelType(modelsBean.getModelType() + "");
|
||||
blocklyProject.setLastUploadTime(modelsBean.getLastUploadTime());
|
||||
blocklyProject.setIsDeleted(modelsBean.getIsDeleted());
|
||||
blocklyProject.setCustomModelId(modelsBean.getCustomModelId());
|
||||
blocklyProject.setBlocklyVersion(modelsBean.getBlocklyVersion());
|
||||
blocklyProject.setBlocklyType(modelsBean.getBlocklyType());
|
||||
blocklyProject.setModelId(modelsBean.getModelId());
|
||||
blocklyProject.setFileUrl(modelsBean.getFileUrl() + "?t=" + SystemUtils.a());
|
||||
blocklyProject.setLocalFilePath(modelsBean.getLoaclFilePath());
|
||||
return blocklyProject;
|
||||
}
|
||||
|
||||
private BlocklyProjectParameter getBlocklyProjectParameter(BlocklyProgramsReturnBean.ModelsBean modelsBean) {
|
||||
BlocklyProjectParameter blocklyProjectParameter = new BlocklyProjectParameter();
|
||||
blocklyProjectParameter.setBlocklyType(modelsBean.getBlocklyType());
|
||||
blocklyProjectParameter.setBlocklyVersion(modelsBean.getBlocklyVersion());
|
||||
blocklyProjectParameter.setCustomModelId(modelsBean.getCustomModelId());
|
||||
blocklyProjectParameter.setFileName(modelsBean.getFileName());
|
||||
blocklyProjectParameter.setFileUrl(modelsBean.getFileUrl());
|
||||
blocklyProjectParameter.setIsDeleted("0");
|
||||
blocklyProjectParameter.setLastUploadTime(modelsBean.getLastUploadTime());
|
||||
blocklyProjectParameter.setModelId(modelsBean.getModelId() + "");
|
||||
blocklyProjectParameter.setXmlId(modelsBean.getXmlId());
|
||||
return blocklyProjectParameter;
|
||||
}
|
||||
|
||||
public static BlocklySyncHttpImpl getInstance() {
|
||||
if (mBlocklySyncHttp == null) {
|
||||
mBlocklySyncHttp = new BlocklySyncHttpImpl();
|
||||
}
|
||||
return mBlocklySyncHttp;
|
||||
}
|
||||
|
||||
private JimuMotion modelBeanToJimuMotion(JimuMotionReturnBean.ModelsBean modelsBean) {
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
JimuMotion jimuMotion = new JimuMotion();
|
||||
Type type = new TypeToken<ArrayList<JimuMotion.JimuServo>>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.12
|
||||
}.getType();
|
||||
if (TextUtils.isEmpty(modelsBean.getPostureCmd())) {
|
||||
return null;
|
||||
}
|
||||
jimuMotion.setActionData((ArrayList) JsonHelper.a(modelsBean.getPostureCmd(), type));
|
||||
jimuMotion.setActionID(modelsBean.getPostureId());
|
||||
jimuMotion.setActionName(modelsBean.getPostureName());
|
||||
jimuMotion.setIsDeleted("0");
|
||||
jimuMotion.setCustomModelId(modelsBean.getCustomModelId());
|
||||
jimuMotion.setUserId(userId);
|
||||
jimuMotion.setModelId(modelsBean.getModelId());
|
||||
jimuMotion.setModelType(modelsBean.getModelType());
|
||||
jimuMotion.setLastUploadTime(modelsBean.getLastUploadTime());
|
||||
return jimuMotion;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void startContrastFile(List<BlocklyProgramsReturnBean.ModelsBean> list) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (BlocklyProgramsReturnBean.ModelsBean modelsBean : list) {
|
||||
if (!TextUtils.isEmpty(modelsBean.getFileName()) && !TextUtils.isEmpty(modelsBean.getFileUrl())) {
|
||||
BlocklyProject blocklyByXml = BlocklyProjectDbHandler.getInstance().getBlocklyByXml(modelsBean.getXmlId());
|
||||
if (blocklyByXml != null) {
|
||||
if ("1".equals(modelsBean.getIsDeleted())) {
|
||||
BlocklyProjectDbHandler.getInstance().deleteBlocklyProject(modelsBean.getXmlId());
|
||||
String str = QiNiuUtils.getAndroidSystemRootPath() + QiNiuUtils.getProgrammingLocalPath(modelsBean);
|
||||
LogUtils.c("localPath:" + str);
|
||||
FileTools.a(str);
|
||||
} else {
|
||||
long lastUploadTime = modelsBean.getLastUploadTime();
|
||||
long lastUploadTime2 = blocklyByXml.getLastUploadTime();
|
||||
if (lastUploadTime > lastUploadTime2 && lastUploadTime > lastUploadTime2 && "0".equals(modelsBean.getIsDeleted())) {
|
||||
modelsBean.setLoaclFilePath(QiNiuUtils.getAndroidSystemRootPath() + QiNiuUtils.getProgrammingLocalPath(modelsBean));
|
||||
arrayList.add(getBlocklyProjectFromModelsBean(modelsBean));
|
||||
}
|
||||
}
|
||||
} else if (blocklyByXml == null && !"1".equals(modelsBean.getIsDeleted())) {
|
||||
modelsBean.setLoaclFilePath(QiNiuUtils.getAndroidSystemRootPath() + QiNiuUtils.getProgrammingLocalPath(modelsBean));
|
||||
arrayList.add(getBlocklyProjectFromModelsBean(modelsBean));
|
||||
}
|
||||
}
|
||||
}
|
||||
downloaderBlocklyFile(arrayList);
|
||||
}
|
||||
|
||||
private void startUploadBlockly(final BlocklyUploadType blocklyUploadType, final BlocklyProject blocklyProject) {
|
||||
String str = UploadFilePathUtils.b() + UploadFilePathUtils.a(blocklyProject);
|
||||
if (!TextUtils.isEmpty(str) && new File(str).exists()) {
|
||||
UploadRequest uploadRequest = new UploadRequest();
|
||||
uploadRequest.b(str);
|
||||
uploadRequest.a(UploadFilePathUtils.a(str));
|
||||
LogUtils.c("获取的到逻辑编程目录:" + UploadFilePathUtils.a(str));
|
||||
DataUploadProxy.c().a(uploadRequest, new SimpleUploadCallback() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.1
|
||||
@Override // com.ubt.jimu.upload.IUploadCallback
|
||||
public void uploadFaulted(UploadRequest uploadRequest2, Exception exc) {
|
||||
LogUtils.c("逻辑编程上传失败:" + exc.getMessage());
|
||||
BlocklyProjectDbHandler.getInstance().setQiNiuUplaodState(blocklyProject.getXmlId(), false);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.upload.IUploadCallback
|
||||
public void uploadSucceed(UploadResponse uploadResponse) {
|
||||
LogUtils.c("逻辑编程上传成功:" + uploadResponse.c());
|
||||
BlocklyProjectDbHandler.getInstance().setQiNiuUplaodState(blocklyProject.getXmlId(), true);
|
||||
BlocklyProjectParameter blocklyProjectParameterFromProject = BlocklySyncHttpImpl.this.getBlocklyProjectParameterFromProject(blocklyProject);
|
||||
blocklyProjectParameterFromProject.setFileUrl(uploadResponse.c());
|
||||
BlocklySyncHttpImpl.this.syncDataToUbtHttp(blocklyUploadType, blocklyProjectParameterFromProject);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void startUploadJimuSound(final BlocklyUploadType blocklyUploadType, final JimuSound jimuSound) {
|
||||
String localFilePath = jimuSound.getLocalFilePath();
|
||||
if (TextUtils.isEmpty(localFilePath)) {
|
||||
return;
|
||||
}
|
||||
if (!new File(localFilePath).exists()) {
|
||||
LogUtils.c(" sound file is null");
|
||||
return;
|
||||
}
|
||||
UploadRequest uploadRequest = new UploadRequest();
|
||||
uploadRequest.b(localFilePath);
|
||||
uploadRequest.a(UploadFilePathUtils.a(localFilePath));
|
||||
DataUploadProxy.c().a(uploadRequest, new SimpleUploadCallback() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.6
|
||||
@Override // com.ubt.jimu.upload.IUploadCallback
|
||||
public void uploadFaulted(UploadRequest uploadRequest2, Exception exc) {
|
||||
LogUtils.c("录音文件上传失败");
|
||||
new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p()).updateQiNiuSyncState(jimuSound, false);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.upload.IUploadCallback
|
||||
public void uploadSucceed(UploadResponse uploadResponse) {
|
||||
LogUtils.c("录音文件上传成功:" + uploadResponse.c());
|
||||
jimuSound.setFileUrl(uploadResponse.c());
|
||||
JimuSoundDbHandler jimuSoundDbHandler = new JimuSoundDbHandler(DatabaseUtils.getDaoSession(true).p());
|
||||
if (blocklyUploadType == BlocklyUploadType.ADD_TYPE) {
|
||||
jimuSoundDbHandler.updateQiNiuSyncState(jimuSound, true);
|
||||
}
|
||||
BlocklySyncHttpImpl.this.syncJimuSoundToUbtService(blocklyUploadType, jimuSound);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void blocklyRenameSyncHttp(final BlocklyProject blocklyProject) {
|
||||
if ("local".equals(TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId())) {
|
||||
return;
|
||||
}
|
||||
DiyTransportServiceProxy diyTransportServiceProxy = new DiyTransportServiceProxy();
|
||||
UploadModelProgramBean uploadModelProgramBean = new UploadModelProgramBean(Cache.getInstance().getUserToken(), blocklyProject.getModelId() + "", blocklyProject.getCustomModelId());
|
||||
ArrayList arrayList = new ArrayList();
|
||||
BlocklyProjectParameter blocklyProjectParameter = new BlocklyProjectParameter();
|
||||
blocklyProjectParameter.setLastUploadTime(blocklyProject.getLastUploadTime());
|
||||
blocklyProjectParameter.setModelType(blocklyProject.getModelType());
|
||||
blocklyProjectParameter.setModelId(blocklyProject.getModelId() + "");
|
||||
blocklyProjectParameter.setBlocklyType(blocklyProject.getBlocklyType());
|
||||
blocklyProjectParameter.setBlocklyVersion(blocklyProject.getBlocklyVersion());
|
||||
blocklyProjectParameter.setCustomModelId(blocklyProject.getCustomModelId());
|
||||
blocklyProjectParameter.setFileName(blocklyProject.getXmlName());
|
||||
blocklyProjectParameter.setIsDeleted("0");
|
||||
blocklyProjectParameter.setXmlId(blocklyProject.getXmlId());
|
||||
blocklyProjectParameter.setFileUrl(UploadFilePathUtils.a() + "/" + QiNiuUtils.getProgrammingQiNiuKey(blocklyProject));
|
||||
arrayList.add(blocklyProjectParameter);
|
||||
uploadModelProgramBean.setUpdatePrograms(arrayList);
|
||||
diyTransportServiceProxy.uploadPrograms(uploadModelProgramBean).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Observer<ApiResponse<Object>>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.3
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (BlocklySyncHttpImpl.this.renameHttpListener != null) {
|
||||
BlocklySyncHttpImpl.this.renameHttpListener.renameHttpFaulted(blocklyProject);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
BlocklySyncHttpImpl.this.disposables.b(disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(ApiResponse<Object> apiResponse) {
|
||||
if (BlocklySyncHttpImpl.this.renameHttpListener != null) {
|
||||
BlocklySyncHttpImpl.this.renameHttpListener.renameHttpSucceed(blocklyProject);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void checkAudioList() {
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
String userToken = Cache.getInstance().getUserToken();
|
||||
if (TextUtils.isEmpty(userId) || "local".equals(userId)) {
|
||||
return;
|
||||
}
|
||||
new DiyTransportServiceProxy().audios(userToken, userId).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer<ApiResponse<List<JimuSound>>>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.8
|
||||
@Override // io.reactivex.functions.Consumer
|
||||
public void accept(ApiResponse<List<JimuSound>> apiResponse) throws Exception {
|
||||
List<JimuSound> models;
|
||||
if (!apiResponse.isStatus() || (models = apiResponse.getModels()) == null || models.size() == 0) {
|
||||
return;
|
||||
}
|
||||
BlocklySyncHttpImpl.this.compareLocalJimuSoundBd(models);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void clearNetworkRequest() {
|
||||
CompositeDisposable compositeDisposable = this.disposables;
|
||||
if (compositeDisposable != null) {
|
||||
compositeDisposable.dispose();
|
||||
this.disposables.a();
|
||||
}
|
||||
}
|
||||
|
||||
public BlocklyProjectParameter getBlocklyProjectParameterFromProject(BlocklyProject blocklyProject) {
|
||||
BlocklyProjectParameter blocklyProjectParameter = new BlocklyProjectParameter();
|
||||
blocklyProjectParameter.setXmlId(blocklyProject.getXmlId());
|
||||
blocklyProjectParameter.setIsDeleted("0");
|
||||
blocklyProjectParameter.setFileName(blocklyProject.getXmlName());
|
||||
blocklyProjectParameter.setCustomModelId(blocklyProject.getCustomModelId());
|
||||
blocklyProjectParameter.setBlocklyVersion(blocklyProject.getBlocklyVersion());
|
||||
blocklyProjectParameter.setBlocklyType(blocklyProject.getBlocklyType());
|
||||
blocklyProjectParameter.setLastUploadTime(blocklyProject.getLastUploadTime());
|
||||
blocklyProjectParameter.setModelId(blocklyProject.getModelId() + "");
|
||||
blocklyProjectParameter.setModelType(blocklyProject.getModelType());
|
||||
return blocklyProjectParameter;
|
||||
}
|
||||
|
||||
public void getServiceMotionList(int i) {
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
String userToken = Cache.getInstance().getUserToken();
|
||||
if (TextUtils.isEmpty(userId) || "local".equals(userId)) {
|
||||
return;
|
||||
}
|
||||
new DiyTransportServiceProxy().postures(userToken, i + "").subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer<JimuMotionReturnBean>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.11
|
||||
@Override // io.reactivex.functions.Consumer
|
||||
public void accept(JimuMotionReturnBean jimuMotionReturnBean) throws Exception {
|
||||
List<JimuMotionReturnBean.ModelsBean> models;
|
||||
if (!jimuMotionReturnBean.isStatus() || (models = jimuMotionReturnBean.getModels()) == null || models.size() == 0) {
|
||||
return;
|
||||
}
|
||||
BlocklySyncHttpImpl.this.compareLocalJimuMotionDb(models);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void inspectBlockData(long j) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
String userToken = Cache.getInstance().getUserToken();
|
||||
if (TextUtils.isEmpty(userId) || userId.equals("local")) {
|
||||
return;
|
||||
}
|
||||
new DiyTransportServiceProxy().programs(userToken, j).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Consumer<BlocklyProgramsReturnBean>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.4
|
||||
@Override // io.reactivex.functions.Consumer
|
||||
public void accept(BlocklyProgramsReturnBean blocklyProgramsReturnBean) throws Exception {
|
||||
List<BlocklyProgramsReturnBean.ModelsBean> models;
|
||||
LogUtils.c("逻辑编程请求成功:" + blocklyProgramsReturnBean.isStatus());
|
||||
if (blocklyProgramsReturnBean == null || !blocklyProgramsReturnBean.isStatus() || (models = blocklyProgramsReturnBean.getModels()) == null || models.size() == 0) {
|
||||
return;
|
||||
}
|
||||
BlocklySyncHttpImpl.this.startContrastFile(models);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void prepareUploadBlockly(BlocklyUploadType blocklyUploadType, BlocklyProject blocklyProject) {
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
if ("local".equals(userId) || TextUtils.isEmpty(userId)) {
|
||||
return;
|
||||
}
|
||||
startUploadBlockly(blocklyUploadType, blocklyProject);
|
||||
}
|
||||
|
||||
public void prepareUploadJimuSound(BlocklyUploadType blocklyUploadType, JimuSound jimuSound) {
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
if ("local".equals(userId) || TextUtils.isEmpty(userId)) {
|
||||
return;
|
||||
}
|
||||
startUploadJimuSound(blocklyUploadType, jimuSound);
|
||||
}
|
||||
|
||||
public void setJimuMotionHttpListener(JimuMotionHttpListener jimuMotionHttpListener) {
|
||||
this.jimuMotionHttpListener = jimuMotionHttpListener;
|
||||
}
|
||||
|
||||
public void setRenameHttpListener(RenameHttpListener renameHttpListener) {
|
||||
this.renameHttpListener = renameHttpListener;
|
||||
}
|
||||
|
||||
public void setUploadBlocklyHttpListener(UploadBlocklyHttpListener uploadBlocklyHttpListener) {
|
||||
this.uploadBlocklyHttpListener = uploadBlocklyHttpListener;
|
||||
}
|
||||
|
||||
public void setUploadJimuSoundHttpListener(UploadJimuSoundHttpListener uploadJimuSoundHttpListener) {
|
||||
this.uploadJimuSoundHttpListener = uploadJimuSoundHttpListener;
|
||||
}
|
||||
|
||||
public void syncDataToUbtHttp(final BlocklyUploadType blocklyUploadType, final BlocklyProjectParameter blocklyProjectParameter) {
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
String userToken = Cache.getInstance().getUserToken();
|
||||
if ("local".equals(userId) || TextUtils.isEmpty(userId)) {
|
||||
return;
|
||||
}
|
||||
DiyTransportServiceProxy diyTransportServiceProxy = new DiyTransportServiceProxy();
|
||||
String modelId = blocklyProjectParameter.getModelId();
|
||||
String customModelId = blocklyProjectParameter.getCustomModelId();
|
||||
ArrayList arrayList = new ArrayList();
|
||||
UploadModelProgramBean uploadModelProgramBean = new UploadModelProgramBean(userToken, modelId, customModelId);
|
||||
if (blocklyUploadType == BlocklyUploadType.UPDATE_TYPE) {
|
||||
arrayList.add(blocklyProjectParameter);
|
||||
uploadModelProgramBean.setUpdatePrograms(arrayList);
|
||||
} else if (blocklyUploadType == BlocklyUploadType.ADD_TYPE) {
|
||||
arrayList.add(blocklyProjectParameter);
|
||||
uploadModelProgramBean.setAddPrograms(arrayList);
|
||||
} else if (blocklyUploadType == BlocklyUploadType.DELETE_TYPE) {
|
||||
blocklyProjectParameter.setLastUploadTime(SystemUtils.a());
|
||||
arrayList.add(blocklyProjectParameter);
|
||||
uploadModelProgramBean.setDeletePrograms(arrayList);
|
||||
}
|
||||
diyTransportServiceProxy.uploadPrograms(uploadModelProgramBean).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Observer<ApiResponse<Object>>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.2
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (BlocklySyncHttpImpl.this.uploadBlocklyHttpListener != null) {
|
||||
BlocklySyncHttpImpl.this.uploadBlocklyHttpListener.syncDataToUbtHttpFaulted(BlocklySyncHttpImpl.this.getBlocklyProjectFromBlocklyProjectParametert(blocklyProjectParameter), blocklyUploadType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
BlocklySyncHttpImpl.this.disposables.b(disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(ApiResponse<Object> apiResponse) {
|
||||
BlocklyProject blocklyProjectFromBlocklyProjectParametert = BlocklySyncHttpImpl.this.getBlocklyProjectFromBlocklyProjectParametert(blocklyProjectParameter);
|
||||
if (!apiResponse.isStatus()) {
|
||||
if (BlocklySyncHttpImpl.this.uploadBlocklyHttpListener != null) {
|
||||
BlocklySyncHttpImpl.this.uploadBlocklyHttpListener.syncDataToUbtHttpFaulted(blocklyProjectFromBlocklyProjectParametert, blocklyUploadType);
|
||||
}
|
||||
} else if (BlocklySyncHttpImpl.this.uploadBlocklyHttpListener != null) {
|
||||
blocklyProjectFromBlocklyProjectParametert.setIsFirst(1);
|
||||
blocklyProjectFromBlocklyProjectParametert.setIsUploadService(true);
|
||||
BlocklySyncHttpImpl.this.uploadBlocklyHttpListener.syncDataToUbtHttpSucceed(blocklyProjectFromBlocklyProjectParametert, blocklyUploadType);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void syncJimuMotionToUbtService(final BlocklyUploadType blocklyUploadType, final JimuMotion jimuMotion) {
|
||||
int modelId;
|
||||
if (jimuMotion != null && (modelId = jimuMotion.getModelId()) > 0) {
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
String userToken = Cache.getInstance().getUserToken();
|
||||
if (TextUtils.isEmpty(userId) || userId.equals("local")) {
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
DiyTransportServiceProxy diyTransportServiceProxy = new DiyTransportServiceProxy();
|
||||
UploadModelMotionBean uploadModelMotionBean = new UploadModelMotionBean(userToken, modelId + "", jimuMotion.getCustomModelId());
|
||||
JimuMotionParameter jimuMotionParameter = new JimuMotionParameter();
|
||||
jimuMotionParameter.setCustomModelId(jimuMotion.getCustomModelId());
|
||||
jimuMotionParameter.setIsDeleted("0");
|
||||
jimuMotionParameter.setModelId(modelId + "");
|
||||
jimuMotionParameter.setLastUploadTime(jimuMotion.getLastUploadTime());
|
||||
jimuMotionParameter.setModelType(jimuMotion.getModelType());
|
||||
jimuMotionParameter.setPostureCmd(JsonHelper.a(jimuMotion.getActionData()));
|
||||
jimuMotionParameter.setPostureId(jimuMotion.getActionID());
|
||||
jimuMotionParameter.setPostureName(jimuMotion.getActionName());
|
||||
arrayList.add(jimuMotionParameter);
|
||||
int i = AnonymousClass13.$SwitchMap$com$ubt$jimu$blockly$command$interaction$BlocklyUploadType[blocklyUploadType.ordinal()];
|
||||
if (i == 1) {
|
||||
uploadModelMotionBean.setAddPostures(arrayList);
|
||||
} else if (i == 2) {
|
||||
uploadModelMotionBean.setUpdatePostures(arrayList);
|
||||
} else if (i == 3) {
|
||||
uploadModelMotionBean.setDeletePostures(arrayList);
|
||||
}
|
||||
diyTransportServiceProxy.uploadPostures(uploadModelMotionBean).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Observer<ApiResponse<Object>>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.10
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (BlocklySyncHttpImpl.this.jimuMotionHttpListener == null) {
|
||||
return;
|
||||
}
|
||||
BlocklySyncHttpImpl.this.jimuMotionHttpListener.uploadMotionToUbtServiceFaulted(blocklyUploadType, jimuMotion);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
BlocklySyncHttpImpl.this.disposables.b(disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(ApiResponse<Object> apiResponse) {
|
||||
if (BlocklySyncHttpImpl.this.jimuMotionHttpListener == null) {
|
||||
return;
|
||||
}
|
||||
if (apiResponse.isStatus()) {
|
||||
BlocklySyncHttpImpl.this.jimuMotionHttpListener.uploadMotionToUbtServiceSucceed(blocklyUploadType, jimuMotion);
|
||||
} else {
|
||||
BlocklySyncHttpImpl.this.jimuMotionHttpListener.uploadMotionToUbtServiceFaulted(blocklyUploadType, jimuMotion);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void syncJimuSoundToUbtService(final BlocklyUploadType blocklyUploadType, final JimuSound jimuSound) {
|
||||
if (jimuSound != null && jimuSound.isUploadQiNiu()) {
|
||||
String localJimuSoundFilePath = QiNiuUtils.getLocalJimuSoundFilePath(jimuSound);
|
||||
LogUtils.c("localJimuSoundFilePath:" + localJimuSoundFilePath);
|
||||
if (TextUtils.isEmpty(localJimuSoundFilePath)) {
|
||||
return;
|
||||
}
|
||||
jimuSound.setFileUrl(UploadFilePathUtils.a() + File.separator + UploadFilePathUtils.a(localJimuSoundFilePath));
|
||||
String userId = TextUtils.isEmpty(Cache.getInstance().getUserId()) ? "local" : Cache.getInstance().getUserId();
|
||||
String userToken = Cache.getInstance().getUserToken();
|
||||
DiyTransportServiceProxy diyTransportServiceProxy = new DiyTransportServiceProxy();
|
||||
UploadAudioBean uploadAudioBean = new UploadAudioBean(userToken, userId);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
JimuSoundParameter jimuSoundParameter = new JimuSoundParameter();
|
||||
jimuSoundParameter.setAudioId(jimuSound.getKey());
|
||||
jimuSoundParameter.setLastUploadTime(jimuSound.getLastUploadTime());
|
||||
jimuSoundParameter.setUserId(userId);
|
||||
jimuSoundParameter.setDescription(jimuSound.getDescription());
|
||||
jimuSoundParameter.setDuration(jimuSound.getDuration());
|
||||
jimuSoundParameter.setFileUrl(jimuSound.getFileUrl());
|
||||
jimuSoundParameter.setType(jimuSound.getType());
|
||||
int i = AnonymousClass13.$SwitchMap$com$ubt$jimu$blockly$command$interaction$BlocklyUploadType[blocklyUploadType.ordinal()];
|
||||
if (i == 1) {
|
||||
jimuSoundParameter.setIsDeleted(0);
|
||||
arrayList.add(jimuSoundParameter);
|
||||
uploadAudioBean.setAddAudios(arrayList);
|
||||
} else if (i == 2) {
|
||||
jimuSoundParameter.setIsDeleted(0);
|
||||
arrayList.add(jimuSoundParameter);
|
||||
uploadAudioBean.setUpdateAudios(arrayList);
|
||||
} else if (i == 3) {
|
||||
jimuSoundParameter.setIsDeleted(1);
|
||||
arrayList.add(jimuSoundParameter);
|
||||
uploadAudioBean.setDeleteAudios(arrayList);
|
||||
}
|
||||
diyTransportServiceProxy.uploadAudios(uploadAudioBean).subscribeOn(Schedulers.b()).observeOn(AndroidSchedulers.a()).subscribe(new Observer<ApiResponse<Object>>() { // from class: com.ubt.jimu.blockly.networkSync.BlocklySyncHttpImpl.7
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (BlocklySyncHttpImpl.this.uploadJimuSoundHttpListener == null) {
|
||||
return;
|
||||
}
|
||||
BlocklySyncHttpImpl.this.uploadJimuSoundHttpListener.syncToUbtServiceFaulted(blocklyUploadType, jimuSound);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
BlocklySyncHttpImpl.this.disposables.b(disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(ApiResponse<Object> apiResponse) {
|
||||
if (BlocklySyncHttpImpl.this.uploadJimuSoundHttpListener == null) {
|
||||
return;
|
||||
}
|
||||
if (apiResponse.isStatus()) {
|
||||
BlocklySyncHttpImpl.this.uploadJimuSoundHttpListener.syncToUbtServiceSucceed(blocklyUploadType, jimuSound);
|
||||
} else {
|
||||
BlocklySyncHttpImpl.this.uploadJimuSoundHttpListener.syncToUbtServiceFaulted(blocklyUploadType, jimuSound);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ubt.jimu.blockly.networkSync.httpListener;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DownloadSoundListener {
|
||||
void downloadSoundFaulted(JimuSound jimuSound);
|
||||
|
||||
void downloadSoundSucceed(JimuSound jimuSound);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ubt.jimu.blockly.networkSync.httpListener;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.JimuMotion;
|
||||
import com.ubt.jimu.blockly.command.interaction.BlocklyUploadType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface JimuMotionHttpListener {
|
||||
void uploadMotionToUbtServiceFaulted(BlocklyUploadType blocklyUploadType, JimuMotion jimuMotion);
|
||||
|
||||
void uploadMotionToUbtServiceSucceed(BlocklyUploadType blocklyUploadType, JimuMotion jimuMotion);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ubt.jimu.blockly.networkSync.httpListener;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface RenameHttpListener {
|
||||
void renameHttpFaulted(BlocklyProject blocklyProject);
|
||||
|
||||
void renameHttpSucceed(BlocklyProject blocklyProject);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ubt.jimu.blockly.networkSync.httpListener;
|
||||
|
||||
import com.ubt.jimu.transport3.download.AsyncTransportFileDownloader;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class SimplifyDownloadListener<T> implements AsyncTransportFileDownloader.OnDownloadListener<T> {
|
||||
public abstract void downloadSucceed(T t);
|
||||
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onBlockComplete(T t) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onBlockCompleted(T t) {
|
||||
downloadSucceed(t);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onBlockError(T t) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.transport3.download.AsyncTransportFileDownloader.OnDownloadListener
|
||||
public void onCompleted() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ubt.jimu.blockly.networkSync.httpListener;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.command.interaction.BlocklyUploadType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface UploadBlocklyHttpListener {
|
||||
void syncDataToUbtHttpFaulted(BlocklyProject blocklyProject, BlocklyUploadType blocklyUploadType);
|
||||
|
||||
void syncDataToUbtHttpSucceed(BlocklyProject blocklyProject, BlocklyUploadType blocklyUploadType);
|
||||
|
||||
void uploadBlocklyToQiNiuFaulted(BlocklyProject blocklyProject);
|
||||
|
||||
void uploadBlocklyToQiNiuSucceed(BlocklyProject blocklyProject);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ubt.jimu.blockly.networkSync.httpListener;
|
||||
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.command.interaction.BlocklyUploadType;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface UploadJimuSoundHttpListener {
|
||||
void syncToUbtServiceFaulted(BlocklyUploadType blocklyUploadType, JimuSound jimuSound);
|
||||
|
||||
void syncToUbtServiceSucceed(BlocklyUploadType blocklyUploadType, JimuSound jimuSound);
|
||||
|
||||
void uploadJimuSoundToQiNiuFaulted(BlocklyUploadType blocklyUploadType, JimuSound jimuSound);
|
||||
|
||||
void uploadJimuSoundToQiNiuSucceed(BlocklyUploadType blocklyUploadType, JimuSound jimuSound);
|
||||
}
|
||||
276
sources/com/ubt/jimu/blockly/networkSync/utils/QiNiuUtils.java
Normal file
276
sources/com/ubt/jimu/blockly/networkSync/utils/QiNiuUtils.java
Normal file
@@ -0,0 +1,276 @@
|
||||
package com.ubt.jimu.blockly.networkSync.utils;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
import com.ubt.jimu.base.cache.Cache;
|
||||
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProgramsReturnBean;
|
||||
import com.ubt.jimu.blockly.bean.BlocklyProject;
|
||||
import com.ubt.jimu.blockly.bean.JimuSound;
|
||||
import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler;
|
||||
import com.ubt.jimu.blockly.feature.audio.AudioParams;
|
||||
import com.ubt.jimu.transport.model.TransportFile;
|
||||
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
|
||||
import com.ubt.jimu.transport3.model.DiyModelAction;
|
||||
import com.ubt.jimu.utils.LogUtils;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class QiNiuUtils {
|
||||
private static final String ONLINE_ROOTPATH = "jimu/user/files/";
|
||||
private static final String TEST_ROOTPATH = "jimu/test/user/files/";
|
||||
private static final String TYPE_BLOCKLY = "blockly";
|
||||
private static final String TYPE_NEW_BLOCKLY = "newBlockly";
|
||||
private static final String URL_FILES = "files";
|
||||
private static final String URL_JIMU = "jimu";
|
||||
private static final String URL_SEPARATOR = "/";
|
||||
private static final String URL_TEST = "test";
|
||||
private static final String URL_USER = "user";
|
||||
|
||||
public static String getAndroidSystemRootPath() {
|
||||
return Environment.getExternalStorageDirectory() + File.separator + "Android/data/" + JimuApplication.l().getPackageName() + "/files/users/";
|
||||
}
|
||||
|
||||
public static String getDiyActionLoaclPath(DiyModelAction diyModelAction) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (diyModelAction == null) {
|
||||
return "";
|
||||
}
|
||||
return userId + File.separator + (diyModelAction.getModelType() == 1 ? "default" : "playerdata") + File.separator + diyModelAction.getCustomModelId() + File.separator + "actions" + File.separator + diyModelAction.getFileName();
|
||||
}
|
||||
|
||||
public static String getDiyActionQiNiuKey(DiyModelAction diyModelAction) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (diyModelAction == null) {
|
||||
return "";
|
||||
}
|
||||
return getQiNiuRootPath() + userId + File.separator + (diyModelAction.getModelType() == 1 ? "default" : "playerdata") + File.separator + diyModelAction.getCustomModelId() + File.separator + "actions" + File.separator + diyModelAction.getFileName();
|
||||
}
|
||||
|
||||
public static String getDiyModelQiNiuKey(DiyDBModel diyDBModel) {
|
||||
return getQiNiuRootPath() + Cache.getInstance().getUserId() + File.separator + "playerdata" + File.separator + diyDBModel.getCustomModelId() + File.separator + diyDBModel.getCustomModelId() + ".jpg";
|
||||
}
|
||||
|
||||
public static String getDiyModelQiNiuPath(DiyDBModel diyDBModel) {
|
||||
return Cache.getInstance().getUserId() + File.separator + "playerdata" + File.separator + diyDBModel.getCustomModelId() + File.separator + diyDBModel.getCustomModelId() + ".jpg";
|
||||
}
|
||||
|
||||
public static String getJimuSoundQiNiuKey(JimuSound jimuSound) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
return null;
|
||||
}
|
||||
String key = jimuSound.getKey();
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
key = jimuSound.getAudioId();
|
||||
}
|
||||
return getQiNiuRootPath() + userId + File.separator + TransportFileDbHandler2.DIR_SOUNDS + File.separator + key + File.separator + key + AudioParams.AAC;
|
||||
}
|
||||
|
||||
public static String getLocalJimuSoundFilePath(JimuSound jimuSound) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
return null;
|
||||
}
|
||||
String key = jimuSound.getKey();
|
||||
if (TextUtils.isEmpty(key)) {
|
||||
key = jimuSound.getAudioId();
|
||||
}
|
||||
return getAndroidSystemRootPath() + userId + File.separator + TransportFileDbHandler2.DIR_SOUNDS + File.separator + key + File.separator + key + AudioParams.AAC;
|
||||
}
|
||||
|
||||
public static String getModelFileLocal(TransportFile transportFile) {
|
||||
if (transportFile == null) {
|
||||
return "";
|
||||
}
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
String str = transportFile.getModelType().equals("1") ? "default" : "playerdata";
|
||||
String fileType = transportFile.getFileType();
|
||||
LogUtils.c("fileType:" + fileType);
|
||||
if ("conn".equals(fileType)) {
|
||||
return getAndroidSystemRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + "servos" + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if ("desc".equals(fileType)) {
|
||||
return getAndroidSystemRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if (TransportFile.TYPE_DIY_SHOW.equals(fileType) || TransportFile.TYPE_AUDIO_SHOW.equals(fileType)) {
|
||||
return getAndroidSystemRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + TransportFile.MODEL_SHOW_DIR + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if (TransportFile.TYPE_CONTROLLER.equals(fileType)) {
|
||||
return getAndroidSystemRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + TransportFile.MODEL_CONTROLLER_DIR + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if ("bg".equals(fileType)) {
|
||||
return getAndroidSystemRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if (!"widgetConfig".equals(fileType)) {
|
||||
return "";
|
||||
}
|
||||
return getAndroidSystemRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + "widgetConfig" + File.separator + "moveConfig.xml";
|
||||
}
|
||||
|
||||
/* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
|
||||
private static String getModelFilePath(TransportFile transportFile) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if ("audio".equals(transportFile.getFileType())) {
|
||||
String fileName = transportFile.getFileName();
|
||||
String substring = fileName.substring(0, fileName.indexOf("."));
|
||||
sb.append(TransportFileDbHandler2.DIR_SOUNDS);
|
||||
sb.append(File.separator);
|
||||
sb.append(substring);
|
||||
} else {
|
||||
if ("1".equals(transportFile.getModelType())) {
|
||||
sb.append("default");
|
||||
} else {
|
||||
sb.append("playerdata");
|
||||
}
|
||||
sb.append(File.separator);
|
||||
sb.append(transportFile.getCustomModelId());
|
||||
String fileType = transportFile.getFileType();
|
||||
char c = 65535;
|
||||
switch (fileType.hashCode()) {
|
||||
case -1422950858:
|
||||
if (fileType.equals("action")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case -309387644:
|
||||
if (fileType.equals(TransportFile.TYPE_PROGRAM)) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3141:
|
||||
if (fileType.equals("bg")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3059500:
|
||||
if (fileType.equals("conn")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3079825:
|
||||
if (fileType.equals("desc")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 93166550:
|
||||
if (fileType.equals("audio")) {
|
||||
c = 5;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c != 0 && c != 1) {
|
||||
if (c == 2) {
|
||||
sb.append(File.separator);
|
||||
sb.append("servos");
|
||||
} else if (c == 3) {
|
||||
sb.append(File.separator);
|
||||
sb.append("actions");
|
||||
} else if (c == 4) {
|
||||
BlocklyProjectDbHandler blocklyProjectDbHandler = BlocklyProjectDbHandler.getInstance();
|
||||
String substring2 = transportFile.getFileName().substring(0, transportFile.getFileName().indexOf("."));
|
||||
BlocklyProject blocklyProject = blocklyProjectDbHandler.getBlocklyProject(transportFile.getUserId(), String.valueOf(transportFile.getModelType() + 1), transportFile.getCustomModelId(), substring2);
|
||||
if (blocklyProject == null) {
|
||||
return "";
|
||||
}
|
||||
if ("blockly".equals(blocklyProject.getBlocklyType())) {
|
||||
sb.append(File.separator);
|
||||
sb.append(transportFile.getCustomModelId());
|
||||
} else {
|
||||
sb.append(File.separator);
|
||||
sb.append(transportFile.getCustomModelId());
|
||||
sb.append(Utils.BLOCKLY_ADD_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String getModelFileQiNiuKey(TransportFile transportFile) {
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
String str = transportFile.getModelType().equals("1") ? "default" : "playerdata";
|
||||
String fileType = transportFile.getFileType();
|
||||
if ("conn".equals(fileType)) {
|
||||
return getQiNiuRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + "servos" + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if ("desc".equals(fileType)) {
|
||||
return getQiNiuRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if (TransportFile.TYPE_DIY_SHOW.equals(fileType)) {
|
||||
return getQiNiuRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + TransportFile.MODEL_SHOW_DIR + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if (TransportFile.TYPE_CONTROLLER.equals(fileType)) {
|
||||
return getQiNiuRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + TransportFile.MODEL_CONTROLLER_DIR + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if ("bg".equals(fileType)) {
|
||||
return getQiNiuRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + transportFile.getFileName();
|
||||
}
|
||||
if (!"widgetConfig".equals(fileType)) {
|
||||
return "";
|
||||
}
|
||||
return getQiNiuRootPath() + userId + File.separator + str + File.separator + transportFile.getCustomModelId() + File.separator + "widgetConfig" + File.separator + "moveConfig.xml";
|
||||
}
|
||||
|
||||
public static String getProgrammingLocalPath(BlocklyProgramsReturnBean.ModelsBean modelsBean) {
|
||||
String str;
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
String str2 = "1".equals(modelsBean.getModelType()) ? "default" : "playerdata";
|
||||
String customModelId = modelsBean.getCustomModelId();
|
||||
if ("newBlockly".equals(modelsBean.getBlocklyType())) {
|
||||
str = customModelId + File.separator + customModelId + Utils.BLOCKLY_ADD_PATH;
|
||||
} else {
|
||||
str = customModelId + File.separator + customModelId;
|
||||
}
|
||||
return userId + File.separator + str2 + File.separator + str + File.separator + (modelsBean.getXmlId() + ".xml");
|
||||
}
|
||||
|
||||
public static String getProgrammingQiNiuKey(BlocklyProject blocklyProject) {
|
||||
String str;
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
return null;
|
||||
}
|
||||
String str2 = blocklyProject.getXmlId() + ".xml";
|
||||
String str3 = "1".equals(blocklyProject.getModelType()) ? "default" : "playerdata";
|
||||
String qiNiuRootPath = getQiNiuRootPath();
|
||||
String customModelId = blocklyProject.getCustomModelId();
|
||||
if ("newBlockly".equals(blocklyProject.getBlocklyType())) {
|
||||
str = customModelId + File.separator + customModelId + Utils.BLOCKLY_ADD_PATH;
|
||||
} else {
|
||||
str = customModelId + File.separator + customModelId;
|
||||
}
|
||||
return qiNiuRootPath + userId + File.separator + str3 + File.separator + str + File.separator + str2;
|
||||
}
|
||||
|
||||
private static String getQiNiuRootPath() {
|
||||
return ONLINE_ROOTPATH;
|
||||
}
|
||||
|
||||
public static String getProgrammingLocalPath(BlocklyProject blocklyProject) {
|
||||
String str;
|
||||
String userId = Cache.getInstance().getUserId();
|
||||
if (TextUtils.isEmpty(userId)) {
|
||||
userId = "local";
|
||||
}
|
||||
String str2 = "1".equals(blocklyProject.getModelType()) ? "default" : "playerdata";
|
||||
String customModelId = blocklyProject.getCustomModelId();
|
||||
if ("newBlockly".equals(blocklyProject.getBlocklyType())) {
|
||||
str = customModelId + File.separator + customModelId + Utils.BLOCKLY_ADD_PATH;
|
||||
} else {
|
||||
str = customModelId + File.separator + customModelId;
|
||||
}
|
||||
return userId + File.separator + str2 + File.separator + str + File.separator + (blocklyProject.getXmlId() + ".xml");
|
||||
}
|
||||
}
|
||||
498
sources/com/ubt/jimu/blockly/view/DialogBlocklyWebView.java
Normal file
498
sources/com/ubt/jimu/blockly/view/DialogBlocklyWebView.java
Normal file
@@ -0,0 +1,498 @@
|
||||
package com.ubt.jimu.blockly.view;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.dialog.IDialogListener;
|
||||
import com.ubt.jimu.base.dialog.SimpleQuestionDialog;
|
||||
import com.ubt.jimu.base.entities.Course;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.blockly.Utils;
|
||||
import com.ubt.jimu.blockly.command.JimuBlocklyCommand;
|
||||
import com.ubt.jimu.blockly.command.JimuJavascriptInterface;
|
||||
import com.ubt.jimu.blockly.command.JimuUnityCommand;
|
||||
import com.ubt.jimu.blockly.command.UnityCommandController;
|
||||
import com.ubt.jimu.blockly.exception.BlocklyEvent;
|
||||
import com.ubt.jimu.blockly.exception.JimuRobotMessage;
|
||||
import com.ubt.jimu.blockly.feature.sensor.DeviceDirection;
|
||||
import com.ubt.jimu.diy.view.BrowseCompletedActivity;
|
||||
import com.ubt.jimu.diy.view.DiyBrowseActivity;
|
||||
import com.ubt.jimu.unity.bluetooth.ConnectionStatus;
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import com.ubt.jimu.utils.JsonHelper;
|
||||
import com.ubt.jimu.utils.PackageHelper;
|
||||
import com.ubt.jimu.utils.SPUtils;
|
||||
import com.ubtech.utils.AndroidVersionCheckUtils;
|
||||
import com.ubtech.view.widget.ToastView;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DialogBlocklyWebView extends Fragment {
|
||||
public static final String BASE_URL = "https://jimu.ubtrobot.com";
|
||||
public static String CODE = "code";
|
||||
public static String STEP = "step";
|
||||
private final String TAG = DialogBlocklyWebView.class.getSimpleName();
|
||||
private int bleState;
|
||||
private JimuBlocklyCommand blocklyObj;
|
||||
private Course course;
|
||||
private DeviceDirection direction;
|
||||
private SimpleQuestionDialog exceptionDialog;
|
||||
protected ImageView imgNextStep;
|
||||
protected ImageView imgPreviousStep;
|
||||
private ImageView imgWait;
|
||||
private JimuUnityCommand javaInterface;
|
||||
private JimuJavascriptInterface javascriptInterface;
|
||||
private String jimuRobotJSON;
|
||||
protected View llBrowseStep;
|
||||
private LinearLayout llWait;
|
||||
private JimuRobot mJimuRobot;
|
||||
private long modelId;
|
||||
private int moduleType;
|
||||
private Animation rotateAnimaLow;
|
||||
protected TextView tvStep;
|
||||
private JimuWebChromeClient webChromeClient;
|
||||
private WebView webView;
|
||||
private JimuWebViewClient webViewClient;
|
||||
|
||||
private void bleDisconnected(BlocklyEvent blocklyEvent) {
|
||||
commonTips((String) blocklyEvent.getMessage(), 2);
|
||||
JimuBlocklyCommand jimuBlocklyCommand = this.blocklyObj;
|
||||
if (jimuBlocklyCommand == null || jimuBlocklyCommand.getJimuRobot() == null) {
|
||||
return;
|
||||
}
|
||||
this.blocklyObj.getJimuRobot().setBlueState(ConnectionStatus.DIS_CONNECT.getStatus());
|
||||
this.bleState = ConnectionStatus.DIS_CONNECT.getStatus();
|
||||
}
|
||||
|
||||
public static DialogBlocklyWebView getInstance(String str, int i, long j, int i2, int i3, int i4, Course course) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("jimuRobotJSON", str);
|
||||
bundle.putInt("bleState", i);
|
||||
bundle.putLong("modelId", j);
|
||||
bundle.putInt("moduleType", i2);
|
||||
bundle.putInt(CODE, i3);
|
||||
bundle.putInt(STEP, i4);
|
||||
bundle.putSerializable("course", course);
|
||||
DialogBlocklyWebView dialogBlocklyWebView = new DialogBlocklyWebView();
|
||||
dialogBlocklyWebView.setArguments(bundle);
|
||||
return dialogBlocklyWebView;
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
if (this.mJimuRobot == null) {
|
||||
this.mJimuRobot = (JimuRobot) JsonHelper.a(this.jimuRobotJSON, (Class<?>) JimuRobot.class);
|
||||
this.mJimuRobot.setBlueState(this.bleState);
|
||||
this.mJimuRobot.setServerModelId(this.modelId);
|
||||
}
|
||||
if (1007 == getArguments().getInt(CODE)) {
|
||||
this.llBrowseStep.setOnTouchListener(new View.OnTouchListener() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.1
|
||||
@Override // android.view.View.OnTouchListener
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
final int i = getArguments().getInt(STEP);
|
||||
this.llBrowseStep.setVisibility(0);
|
||||
this.imgPreviousStep.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
DiyBrowseActivity.start(DialogBlocklyWebView.this.getActivity(), i - 1, UnityActivity.modelBrowse);
|
||||
((UnityActivity) DialogBlocklyWebView.this.getActivity()).setIsBack(true);
|
||||
((UnityActivity) DialogBlocklyWebView.this.getActivity()).closeBlockly();
|
||||
}
|
||||
});
|
||||
this.imgNextStep.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.3
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
BrowseCompletedActivity.start(DialogBlocklyWebView.this.getActivity());
|
||||
SPUtils.b(String.format(DiyBrowseActivity.DIYSTEP, DialogBlocklyWebView.this.mJimuRobot.getModelId()), -5);
|
||||
((UnityActivity) DialogBlocklyWebView.this.getActivity()).setIsBack(true);
|
||||
((UnityActivity) DialogBlocklyWebView.this.getActivity()).closeBlockly();
|
||||
}
|
||||
});
|
||||
this.tvStep.setText(String.format("%s/%s", String.valueOf(i), String.valueOf(i)));
|
||||
} else {
|
||||
this.llBrowseStep.setVisibility(8);
|
||||
}
|
||||
this.blocklyObj = new JimuBlocklyCommand(this.webView, (UnityActivity) getActivity(), this.mJimuRobot);
|
||||
this.blocklyObj.setModuleType(this.moduleType);
|
||||
this.javascriptInterface = new JimuJavascriptInterface(this.webView, getActivity(), this.mJimuRobot);
|
||||
this.javascriptInterface.setDialogBlocklyWebView(this);
|
||||
this.javascriptInterface.setCourse(this.course);
|
||||
this.webChromeClient = new JimuWebChromeClient();
|
||||
this.webViewClient = new JimuWebViewClient(getActivity(), this.blocklyObj);
|
||||
this.webViewClient.setDialog(this);
|
||||
this.webView.removeJavascriptInterface("blocklyObj");
|
||||
this.webView.addJavascriptInterface(this.javascriptInterface, "blocklyObj");
|
||||
this.webView.setWebViewClient(this.webViewClient);
|
||||
this.webView.setWebChromeClient(this.webChromeClient);
|
||||
if (1 != this.moduleType) {
|
||||
this.webView.loadUrl("file:///" + Utils.baseUrl + "teachMaterial/index.html");
|
||||
} else if (this.course != null) {
|
||||
this.webView.loadUrl("file:///" + Utils.baseUrl + "teachOldCourse/course.html");
|
||||
} else {
|
||||
this.webView.loadUrl("file:///" + Utils.baseUrl + "teachCourse/course.html");
|
||||
}
|
||||
this.javaInterface = new JimuUnityCommand(this.webView);
|
||||
showWait();
|
||||
}
|
||||
|
||||
private void initWebView() {
|
||||
PackageHelper.a("CHANNEL_ID");
|
||||
this.webView.getSettings().setTextZoom(100);
|
||||
this.webView.getSettings().setDisplayZoomControls(false);
|
||||
this.webView.getSettings().setSupportZoom(false);
|
||||
this.webView.getSettings().setUseWideViewPort(false);
|
||||
this.webView.getSettings().setJavaScriptEnabled(true);
|
||||
this.webView.getSettings().setLoadWithOverviewMode(true);
|
||||
if (AndroidVersionCheckUtils.c()) {
|
||||
this.webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
|
||||
}
|
||||
if (AndroidVersionCheckUtils.d()) {
|
||||
this.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
||||
}
|
||||
this.webView.getSettings().setAllowContentAccess(true);
|
||||
this.webView.getSettings().setAllowFileAccess(true);
|
||||
this.webView.getSettings().setDatabaseEnabled(true);
|
||||
this.webView.getSettings().setDomStorageEnabled(true);
|
||||
this.webView.getSettings().setAppCacheEnabled(false);
|
||||
this.webView.getSettings().setCacheMode(2);
|
||||
this.webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
this.webView.setScrollContainer(false);
|
||||
}
|
||||
|
||||
private void setJSResult(final String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return;
|
||||
}
|
||||
this.webView.post(new Runnable() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.8
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
DialogBlocklyWebView.this.webView.loadUrl(str);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showException(String str) {
|
||||
JimuBlocklyCommand jimuBlocklyCommand = this.blocklyObj;
|
||||
if (jimuBlocklyCommand != null) {
|
||||
jimuBlocklyCommand.stopSensorTimer("");
|
||||
}
|
||||
this.javaInterface.jsShowException("Error");
|
||||
this.exceptionDialog = SimpleQuestionDialog.newInstance(str);
|
||||
this.exceptionDialog.setListener(new IDialogListener() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.7
|
||||
@Override // com.ubt.jimu.base.dialog.IDialogListener
|
||||
public void onCancle() {
|
||||
UnityActivity.communityWithUnity(DialogBlocklyWebView.this.getActivity(), UnityCommandController.SHOW_EXCEPTION_CALLBACK, "0");
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.dialog.IDialogListener
|
||||
public void onOk() {
|
||||
UnityActivity.communityWithUnity(DialogBlocklyWebView.this.getActivity(), UnityCommandController.SHOW_EXCEPTION_CALLBACK, "1");
|
||||
DialogBlocklyWebView.this.showWait();
|
||||
if (DialogBlocklyWebView.this.blocklyObj != null) {
|
||||
DialogBlocklyWebView.this.blocklyObj.startSensorTimer(DialogBlocklyWebView.this.blocklyObj.getQueryUrl(), DialogBlocklyWebView.this.blocklyObj.getQueryCallback());
|
||||
}
|
||||
}
|
||||
});
|
||||
this.exceptionDialog.show(getFragmentManager(), "");
|
||||
}
|
||||
|
||||
public void blueConnectCallBack(String str) {
|
||||
JimuRobot jimuRobot = (JimuRobot) JsonHelper.a(str, (Class<?>) JimuRobot.class);
|
||||
if (jimuRobot != null) {
|
||||
this.mJimuRobot.setLights(jimuRobot.getLights());
|
||||
this.mJimuRobot.setGyroscopeId(jimuRobot.getGyroscopeId());
|
||||
this.mJimuRobot.setInfraredId(jimuRobot.getInfraredId());
|
||||
this.mJimuRobot.setTouchId(jimuRobot.getTouchId());
|
||||
this.mJimuRobot.setIsLithium(jimuRobot.getIsLithium());
|
||||
this.mJimuRobot.setUltrasonicId(jimuRobot.getUltrasonicId());
|
||||
this.mJimuRobot.setColorId(jimuRobot.getColorId());
|
||||
this.mJimuRobot.setUnicornId(jimuRobot.getUnicornId());
|
||||
jimuRobot.setBlueState(this.mJimuRobot.getBlueState());
|
||||
String a = JsonHelper.a(jimuRobot);
|
||||
JimuUnityCommand jimuUnityCommand = this.javaInterface;
|
||||
if (jimuUnityCommand != null) {
|
||||
jimuUnityCommand.blueConnectCallBack(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void chargeProtected(String str) {
|
||||
JimuUnityCommand jimuUnityCommand = this.javaInterface;
|
||||
if (jimuUnityCommand != null) {
|
||||
jimuUnityCommand.chargeProtected(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void commonTips(String str, int i) {
|
||||
ToastView.a(getActivity(), str, i == 2 ? ToastView.Type.ERROR : i == 1 ? ToastView.Type.SUCCESS : ToastView.Type.NORMAL).a();
|
||||
}
|
||||
|
||||
public DeviceDirection getDirection() {
|
||||
return this.direction;
|
||||
}
|
||||
|
||||
public int getModuleType() {
|
||||
return this.moduleType;
|
||||
}
|
||||
|
||||
public void hideWait() {
|
||||
Animation animation = this.rotateAnimaLow;
|
||||
if (animation != null) {
|
||||
animation.cancel();
|
||||
}
|
||||
this.llWait.postDelayed(new Runnable() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.6
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
DialogBlocklyWebView.this.llWait.setVisibility(8);
|
||||
}
|
||||
}, 100L);
|
||||
}
|
||||
|
||||
public void jsShowException(String str) {
|
||||
JimuUnityCommand jimuUnityCommand = this.javaInterface;
|
||||
if (jimuUnityCommand != null) {
|
||||
jimuUnityCommand.jsShowException(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyKeyboardHidden(String str) {
|
||||
JimuUnityCommand jimuUnityCommand = this.javaInterface;
|
||||
if (jimuUnityCommand != null) {
|
||||
jimuUnityCommand.notifyKeyboardHidden(str);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
this.jimuRobotJSON = arguments.getString("jimuRobotJSON");
|
||||
this.bleState = arguments.getInt("bleState");
|
||||
this.modelId = arguments.getLong("modelId");
|
||||
this.moduleType = arguments.getInt("moduleType");
|
||||
this.course = (Course) arguments.getSerializable("course");
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
View inflate = layoutInflater.inflate(R.layout.dialog_blockly_webview, (ViewGroup) null);
|
||||
this.webView = (WebView) inflate.findViewById(R.id.webView);
|
||||
this.llWait = (LinearLayout) inflate.findViewById(R.id.ll_wait);
|
||||
this.imgWait = (ImageView) inflate.findViewById(R.id.wait_img);
|
||||
this.llBrowseStep = inflate.findViewById(R.id.llStep);
|
||||
this.imgPreviousStep = (ImageView) inflate.findViewById(R.id.imgPreviousStep);
|
||||
this.imgNextStep = (ImageView) inflate.findViewById(R.id.imgNextStep);
|
||||
this.tvStep = (TextView) inflate.findViewById(R.id.tvStep);
|
||||
initWebView();
|
||||
initView();
|
||||
this.llWait.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.4
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
DialogBlocklyWebView.this.llWait.setVisibility(8);
|
||||
}
|
||||
});
|
||||
return inflate;
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onDestroy() {
|
||||
WebView webView = this.webView;
|
||||
if (webView != null) {
|
||||
webView.stopLoading();
|
||||
this.webView.clearHistory();
|
||||
this.webView.removeAllViews();
|
||||
this.webView.destroy();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(BlocklyEvent blocklyEvent) {
|
||||
switch (blocklyEvent.getType()) {
|
||||
case 1001:
|
||||
JimuRobotMessage jimuRobotMessage = (JimuRobotMessage) blocklyEvent.getMessage();
|
||||
if (jimuRobotMessage != null) {
|
||||
commonTips(jimuRobotMessage.getMsg(), jimuRobotMessage.getLevel());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1002:
|
||||
showException((String) blocklyEvent.getMessage());
|
||||
break;
|
||||
case 1003:
|
||||
bleDisconnected(blocklyEvent);
|
||||
break;
|
||||
case 1004:
|
||||
setJSResult((String) blocklyEvent.getMessage());
|
||||
break;
|
||||
case 1006:
|
||||
this.bleState = ConnectionStatus.DIS_CONNECT.getStatus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onPause() {
|
||||
SimpleQuestionDialog simpleQuestionDialog = this.exceptionDialog;
|
||||
if (simpleQuestionDialog != null && simpleQuestionDialog.isVisible()) {
|
||||
this.exceptionDialog.dismiss();
|
||||
}
|
||||
super.onPause();
|
||||
WebView webView = this.webView;
|
||||
if (webView != null) {
|
||||
try {
|
||||
webView.getClass().getMethod("onPause", new Class[0]).invoke(this.webView, null);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e2) {
|
||||
e2.printStackTrace();
|
||||
} catch (InvocationTargetException e3) {
|
||||
e3.printStackTrace();
|
||||
} catch (Exception e4) {
|
||||
e4.printStackTrace();
|
||||
}
|
||||
}
|
||||
stopQueryTimer();
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
WebView webView = this.webView;
|
||||
if (webView != null) {
|
||||
try {
|
||||
webView.getClass().getMethod("onResume", new Class[0]).invoke(this.webView, null);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e2) {
|
||||
e2.printStackTrace();
|
||||
} catch (InvocationTargetException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
EventBus.b().c(this);
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onStop() {
|
||||
EventBus.b().d(this);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public void refreshAllServo(String str, String str2) {
|
||||
JimuRobot jimuRobot = this.mJimuRobot;
|
||||
if (jimuRobot != null) {
|
||||
jimuRobot.setServo(str);
|
||||
this.mJimuRobot.setCircleServos(str2);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshDirection(DeviceDirection deviceDirection) {
|
||||
this.direction = deviceDirection;
|
||||
}
|
||||
|
||||
public void setBlueState(int i) {
|
||||
JimuRobot jimuRobot = this.mJimuRobot;
|
||||
if (jimuRobot != null) {
|
||||
jimuRobot.setBlueState(i);
|
||||
}
|
||||
setJSResult("BLEStateChanged", String.valueOf(i));
|
||||
}
|
||||
|
||||
public void showInfraredRef(String str, String str2) {
|
||||
JimuUnityCommand jimuUnityCommand = this.javaInterface;
|
||||
if (jimuUnityCommand != null) {
|
||||
jimuUnityCommand.showInfraredRef(str, str2);
|
||||
}
|
||||
}
|
||||
|
||||
public void showWait() {
|
||||
if (this.rotateAnimaLow == null) {
|
||||
this.rotateAnimaLow = AnimationUtils.loadAnimation(getActivity(), R.anim.anima_dialog_wait);
|
||||
}
|
||||
this.llWait.setVisibility(0);
|
||||
this.imgWait.startAnimation(this.rotateAnimaLow);
|
||||
((AnimationDrawable) this.imgWait.getBackground()).start();
|
||||
this.webView.postDelayed(new Runnable() { // from class: com.ubt.jimu.blockly.view.DialogBlocklyWebView.5
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
DialogBlocklyWebView.this.hideWait();
|
||||
}
|
||||
}, 10000L);
|
||||
}
|
||||
|
||||
public void stopQueryTimer() {
|
||||
JimuBlocklyCommand jimuBlocklyCommand = this.blocklyObj;
|
||||
if (jimuBlocklyCommand != null) {
|
||||
jimuBlocklyCommand.stopSensorTimer("");
|
||||
}
|
||||
}
|
||||
|
||||
public void updateJimuRobot(String str) {
|
||||
JimuRobot jimuRobot;
|
||||
JimuRobot jimuRobot2 = (JimuRobot) JsonHelper.a(str, (Class<?>) JimuRobot.class);
|
||||
if (jimuRobot2 == null || (jimuRobot = this.mJimuRobot) == null) {
|
||||
return;
|
||||
}
|
||||
jimuRobot.setGyroscopeId(jimuRobot2.getGyroscopeId());
|
||||
this.mJimuRobot.setInfraredId(jimuRobot2.getInfraredId());
|
||||
this.mJimuRobot.setLights(jimuRobot2.getLights());
|
||||
this.mJimuRobot.setTouchId(jimuRobot2.getTouchId());
|
||||
this.mJimuRobot.setMotor(jimuRobot2.getMotor());
|
||||
this.mJimuRobot.setIsLithium(jimuRobot2.getIsLithium());
|
||||
this.mJimuRobot.setUltrasonicId(jimuRobot2.getUltrasonicId());
|
||||
this.mJimuRobot.setColorId(jimuRobot2.getColorId());
|
||||
this.mJimuRobot.setUnicornId(jimuRobot2.getUnicornId());
|
||||
}
|
||||
|
||||
public void wakeupBlockly(String str, int i, String str2, String str3) {
|
||||
JimuUnityCommand jimuUnityCommand = this.javaInterface;
|
||||
if (jimuUnityCommand != null) {
|
||||
jimuUnityCommand.wakeupBlockly(str, i, str2, str3);
|
||||
}
|
||||
}
|
||||
|
||||
public void setJSResult(String str, String... strArr) {
|
||||
Utils.setJSResult(this.webView, str, strArr);
|
||||
}
|
||||
|
||||
public void refreshAllServo(String str) {
|
||||
this.javaInterface.refreshAllServo(str);
|
||||
}
|
||||
}
|
||||
194
sources/com/ubt/jimu/blockly/view/HelpFragmentCompact.java
Normal file
194
sources/com/ubt/jimu/blockly/view/HelpFragmentCompact.java
Normal file
@@ -0,0 +1,194 @@
|
||||
package com.ubt.jimu.blockly.view;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.ProgressBar;
|
||||
import butterknife.ButterKnife;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.utils.NetWorkUtil;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
import com.ubtech.utils.AndroidVersionCheckUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HelpFragmentCompact extends Fragment implements NavigationBarView.OnActionClickListener {
|
||||
private static final String ACTIONBAR_BG_COLOR = "actionbarBackgroundColorResId";
|
||||
private static final String TITLE = "title";
|
||||
private static final String URL = "url";
|
||||
private int actionbarBackgroundColorResId;
|
||||
private OnHelpFragmentInteractionListener mListener;
|
||||
protected NavigationBarView navigationBarView;
|
||||
protected ProgressBar pgLoading;
|
||||
private String title;
|
||||
private String url;
|
||||
protected WebView webView;
|
||||
|
||||
public class MyWebChromeClient extends WebChromeClient {
|
||||
public MyWebChromeClient() {
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onProgressChanged(WebView webView, int i) {
|
||||
HelpFragmentCompact.this.pgLoading.setProgress(i);
|
||||
}
|
||||
}
|
||||
|
||||
public class MyWebViewClient extends WebViewClient {
|
||||
public MyWebViewClient() {
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageFinished(WebView webView, String str) {
|
||||
super.onPageFinished(webView, str);
|
||||
HelpFragmentCompact.this.pgLoading.setProgress(100);
|
||||
if (HelpFragmentCompact.this.actionbarBackgroundColorResId == R.color.bg_unicorn_ar_game_help) {
|
||||
HelpFragmentCompact.this.navigationBarView.setLeftIvSrc(R.drawable.back_white);
|
||||
HelpFragmentCompact helpFragmentCompact = HelpFragmentCompact.this;
|
||||
helpFragmentCompact.navigationBarView.setBackgroundResource(helpFragmentCompact.actionbarBackgroundColorResId);
|
||||
}
|
||||
HelpFragmentCompact helpFragmentCompact2 = HelpFragmentCompact.this;
|
||||
helpFragmentCompact2.navigationBarView.setTitle(TextUtils.isEmpty(helpFragmentCompact2.title) ? webView.getTitle() : HelpFragmentCompact.this.title);
|
||||
HelpFragmentCompact.this.pgLoading.postDelayed(new Runnable() { // from class: com.ubt.jimu.blockly.view.HelpFragmentCompact.MyWebViewClient.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
HelpFragmentCompact.this.pgLoading.setVisibility(8);
|
||||
}
|
||||
}, 500L);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
|
||||
super.onPageStarted(webView, str, bitmap);
|
||||
HelpFragmentCompact.this.pgLoading.setVisibility(0);
|
||||
HelpFragmentCompact.this.pgLoading.setProgress(0);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnHelpFragmentInteractionListener {
|
||||
void onHelpPageBack();
|
||||
}
|
||||
|
||||
private void initWebView() {
|
||||
this.navigationBarView.setBackgroundResource(R.color.theme_background);
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
this.webView.removeJavascriptInterface("searchBoxJavaBridge_");
|
||||
this.webView.removeJavascriptInterface("accessibility");
|
||||
this.webView.removeJavascriptInterface("accessibilityTraversal");
|
||||
}
|
||||
this.webView.getSettings().setDisplayZoomControls(false);
|
||||
this.webView.getSettings().setSupportZoom(false);
|
||||
this.webView.getSettings().setUseWideViewPort(false);
|
||||
this.webView.getSettings().setJavaScriptEnabled(true);
|
||||
this.webView.getSettings().setLoadWithOverviewMode(true);
|
||||
if (AndroidVersionCheckUtils.c()) {
|
||||
this.webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
|
||||
}
|
||||
if (AndroidVersionCheckUtils.d()) {
|
||||
this.webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
|
||||
}
|
||||
this.webView.getSettings().setAllowContentAccess(true);
|
||||
this.webView.getSettings().setAllowFileAccessFromFileURLs(false);
|
||||
this.webView.getSettings().setAllowUniversalAccessFromFileURLs(false);
|
||||
this.webView.getSettings().setDatabaseEnabled(true);
|
||||
this.webView.getSettings().setDomStorageEnabled(true);
|
||||
this.webView.getSettings().setAppCacheEnabled(false);
|
||||
if (NetWorkUtil.b(getActivity())) {
|
||||
this.webView.getSettings().setCacheMode(2);
|
||||
} else {
|
||||
this.webView.getSettings().setCacheMode(-1);
|
||||
}
|
||||
this.webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
this.webView.setScrollContainer(false);
|
||||
this.webView.setWebViewClient(new MyWebViewClient());
|
||||
this.webView.setWebChromeClient(new MyWebChromeClient());
|
||||
this.webView.loadUrl(this.url);
|
||||
}
|
||||
|
||||
public static HelpFragmentCompact newInstance(String str, String str2, int i) {
|
||||
HelpFragmentCompact helpFragmentCompact = new HelpFragmentCompact();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", str);
|
||||
bundle.putString("title", str2);
|
||||
bundle.putInt(ACTIONBAR_BG_COLOR, i);
|
||||
helpFragmentCompact.setArguments(bundle);
|
||||
return helpFragmentCompact;
|
||||
}
|
||||
|
||||
public boolean goBack() {
|
||||
if (!this.webView.canGoBack()) {
|
||||
return false;
|
||||
}
|
||||
this.webView.goBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // android.app.Fragment
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
if (context instanceof OnHelpFragmentInteractionListener) {
|
||||
this.mListener = (OnHelpFragmentInteractionListener) context;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
||||
public void onClick(View view) {
|
||||
OnHelpFragmentInteractionListener onHelpFragmentInteractionListener = this.mListener;
|
||||
if (onHelpFragmentInteractionListener != null) {
|
||||
onHelpFragmentInteractionListener.onHelpPageBack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
if (getArguments() != null) {
|
||||
this.url = getArguments().getString("url");
|
||||
this.title = getArguments().getString("title");
|
||||
this.actionbarBackgroundColorResId = getArguments().getInt(ACTIONBAR_BG_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
View inflate = layoutInflater.inflate(R.layout.fragment_help, viewGroup, false);
|
||||
ButterKnife.a(this, inflate);
|
||||
initWebView();
|
||||
if (TextUtils.isEmpty(this.title)) {
|
||||
this.navigationBarView.setTitle(this.url);
|
||||
} else {
|
||||
this.navigationBarView.setTitle(this.title);
|
||||
}
|
||||
this.navigationBarView.setListener(this);
|
||||
return inflate;
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onDestroy() {
|
||||
this.webView.stopLoading();
|
||||
this.webView.clearHistory();
|
||||
this.webView.removeAllViews();
|
||||
this.webView.destroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // android.app.Fragment
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
this.mListener = null;
|
||||
}
|
||||
|
||||
public void setListener(OnHelpFragmentInteractionListener onHelpFragmentInteractionListener) {
|
||||
this.mListener = onHelpFragmentInteractionListener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ubt.jimu.blockly.view;
|
||||
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ProgressBar;
|
||||
import butterknife.Unbinder;
|
||||
import butterknife.internal.Utils;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.widgets.NavigationBarView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HelpFragmentCompact_ViewBinding implements Unbinder {
|
||||
private HelpFragmentCompact target;
|
||||
|
||||
public HelpFragmentCompact_ViewBinding(HelpFragmentCompact helpFragmentCompact, View view) {
|
||||
this.target = helpFragmentCompact;
|
||||
helpFragmentCompact.navigationBarView = (NavigationBarView) Utils.b(view, R.id.nbv_bar, "field 'navigationBarView'", NavigationBarView.class);
|
||||
helpFragmentCompact.pgLoading = (ProgressBar) Utils.b(view, R.id.pgLoading, "field 'pgLoading'", ProgressBar.class);
|
||||
helpFragmentCompact.webView = (WebView) Utils.b(view, R.id.webView, "field 'webView'", WebView.class);
|
||||
}
|
||||
|
||||
@Override // butterknife.Unbinder
|
||||
public void unbind() {
|
||||
HelpFragmentCompact helpFragmentCompact = this.target;
|
||||
if (helpFragmentCompact == null) {
|
||||
throw new IllegalStateException("Bindings already cleared.");
|
||||
}
|
||||
this.target = null;
|
||||
helpFragmentCompact.navigationBarView = null;
|
||||
helpFragmentCompact.pgLoading = null;
|
||||
helpFragmentCompact.webView = null;
|
||||
}
|
||||
}
|
||||
13
sources/com/ubt/jimu/blockly/view/JimuWebChromeClient.java
Normal file
13
sources/com/ubt/jimu/blockly/view/JimuWebChromeClient.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.ubt.jimu.blockly.view;
|
||||
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuWebChromeClient extends WebChromeClient {
|
||||
private String tag = JimuWebChromeClient.class.getSimpleName();
|
||||
|
||||
@Override // android.webkit.WebChromeClient
|
||||
public void onProgressChanged(WebView webView, int i) {
|
||||
}
|
||||
}
|
||||
126
sources/com/ubt/jimu/blockly/view/JimuWebViewClient.java
Normal file
126
sources/com/ubt/jimu/blockly/view/JimuWebViewClient.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package com.ubt.jimu.blockly.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.webkit.ClientCertRequest;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.webkit.WebResourceError;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import com.ubt.jimu.blockly.JimuRobot;
|
||||
import com.ubt.jimu.blockly.command.BlocklyCommandController;
|
||||
import com.ubt.jimu.blockly.command.JimuBlocklyCommand;
|
||||
import com.ubtech.utils.FileHelper;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class JimuWebViewClient extends WebViewClient {
|
||||
private BlocklyCommandController command;
|
||||
private Context context;
|
||||
private DialogBlocklyWebView dialog;
|
||||
private String tag = JimuWebViewClient.class.getSimpleName();
|
||||
private boolean init = true;
|
||||
|
||||
public JimuWebViewClient(Context context, JimuBlocklyCommand jimuBlocklyCommand) {
|
||||
this.context = context;
|
||||
this.command = new BlocklyCommandController(jimuBlocklyCommand);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void doUpdateVisitedHistory(WebView webView, String str, boolean z) {
|
||||
super.doUpdateVisitedHistory(webView, str, z);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onFormResubmission(WebView webView, Message message, Message message2) {
|
||||
super.onFormResubmission(webView, message, message2);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onLoadResource(WebView webView, String str) {
|
||||
super.onLoadResource(webView, str);
|
||||
Log.i(this.tag, "onLoadResource:" + str);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageCommitVisible(WebView webView, String str) {
|
||||
super.onPageCommitVisible(webView, str);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageFinished(WebView webView, String str) {
|
||||
super.onPageFinished(webView, str);
|
||||
if (this.init) {
|
||||
this.init = false;
|
||||
this.dialog.hideWait();
|
||||
JimuRobot jimuRobot = this.command.getJsInterface().getJimuRobot();
|
||||
if ("0".equals(jimuRobot.getModelType())) {
|
||||
FileHelper.a(jimuRobot.getSamplePath() + "loadFlags.file", "1", "");
|
||||
}
|
||||
}
|
||||
Log.i(this.tag, "onPageFinished load url:" + str);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
|
||||
super.onPageStarted(webView, str, bitmap);
|
||||
Log.i(this.tag, "onPageStarted: " + str);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedClientCertRequest(WebView webView, ClientCertRequest clientCertRequest) {
|
||||
super.onReceivedClientCertRequest(webView, clientCertRequest);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
|
||||
super.onReceivedError(webView, webResourceRequest, webResourceError);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedHttpAuthRequest(WebView webView, HttpAuthHandler httpAuthHandler, String str, String str2) {
|
||||
super.onReceivedHttpAuthRequest(webView, httpAuthHandler, str, str2);
|
||||
Log.i(this.tag, "error:onReceivedHttpAuthRequest");
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
|
||||
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedLoginRequest(WebView webView, String str, String str2, String str3) {
|
||||
super.onReceivedLoginRequest(webView, str, str2, str3);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
|
||||
super.onReceivedSslError(webView, sslErrorHandler, sslError);
|
||||
Log.i(this.tag, "error:onReceivedSslError");
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onScaleChanged(WebView webView, float f, float f2) {
|
||||
super.onScaleChanged(webView, f, f2);
|
||||
}
|
||||
|
||||
public void setDialog(DialogBlocklyWebView dialogBlocklyWebView) {
|
||||
this.dialog = dialogBlocklyWebView;
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
|
||||
return super.shouldInterceptRequest(webView, webResourceRequest);
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
|
||||
Log.i(this.tag, str);
|
||||
return this.command.onBlocklyCommand(webView, str);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user