Initial commit
This commit is contained in:
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");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user