Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -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);
}
}
});
}
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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() {
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View 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");
}
}