140 lines
4.1 KiB
Java
140 lines
4.1 KiB
Java
package com.ubt.jimu.sync;
|
|
|
|
import android.text.TextUtils;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.db.diy.DiyDBModel;
|
|
import com.ubt.jimu.base.db.user.UserDbHandler;
|
|
import com.ubt.jimu.base.entities.User;
|
|
import com.ubt.jimu.transport3.api.DiyTransportServiceProxy;
|
|
import com.ubt.jimu.utils.LogUtils;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class OfflineDataUploadTool implements CreationModelListener {
|
|
private static OfflineDataUploadTool i;
|
|
private OfflineDiyDBModelUpload a;
|
|
private OfflineUploadAction b;
|
|
private OfflineBlockProgramUpload c;
|
|
private OfflineSoundUpload d;
|
|
private OfflineModelFilesUpload e;
|
|
private OfflineMotionUpload f;
|
|
private String g;
|
|
private DiyTransportServiceProxy h;
|
|
|
|
private OfflineDataUploadTool() {
|
|
this.g = Cache.getInstance().getUserId();
|
|
if (TextUtils.isEmpty(this.g)) {
|
|
this.g = "local";
|
|
}
|
|
Cache.getInstance().getUserToken();
|
|
if (this.h == null) {
|
|
this.h = new DiyTransportServiceProxy();
|
|
}
|
|
if (this.a == null) {
|
|
this.a = new OfflineDiyDBModelUpload(this.h);
|
|
}
|
|
if (this.b == null) {
|
|
this.b = new OfflineUploadAction(this.h);
|
|
}
|
|
if (this.c == null) {
|
|
this.c = new OfflineBlockProgramUpload(this.h);
|
|
}
|
|
if (this.d == null) {
|
|
this.d = new OfflineSoundUpload(this.h);
|
|
}
|
|
if (this.f == null) {
|
|
this.f = new OfflineMotionUpload(this.h);
|
|
}
|
|
if (this.e == null) {
|
|
this.e = new OfflineModelFilesUpload(this.h);
|
|
}
|
|
}
|
|
|
|
public static OfflineDataUploadTool h() {
|
|
if (i == null) {
|
|
i = new OfflineDataUploadTool();
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.sync.CreationModelListener
|
|
public void a(DiyDBModel diyDBModel) {
|
|
if (diyDBModel == null || TextUtils.isEmpty(diyDBModel.getCustomModelId()) || diyDBModel.getModelId().intValue() <= 0) {
|
|
return;
|
|
}
|
|
this.e.a(diyDBModel.getCustomModelId(), diyDBModel.getModelId().intValue());
|
|
this.b.a(diyDBModel.getCustomModelId(), diyDBModel.getModelId().intValue());
|
|
this.f.a(diyDBModel.getCustomModelId(), diyDBModel.getModelId().intValue());
|
|
this.c.a(diyDBModel.getCustomModelId(), diyDBModel.getModelId().intValue());
|
|
}
|
|
|
|
public void b() {
|
|
if (Cache.getInstance().getUserId().equals("local")) {
|
|
return;
|
|
}
|
|
this.b.c();
|
|
this.b.b();
|
|
this.b.a();
|
|
}
|
|
|
|
public void c() {
|
|
this.c.c();
|
|
this.c.b();
|
|
this.c.a();
|
|
}
|
|
|
|
public synchronized void d() {
|
|
String userId = Cache.getInstance().getUserId();
|
|
Cache.getInstance().getUserToken();
|
|
if (!TextUtils.isEmpty(userId) && !"local".equals(userId)) {
|
|
this.a.a(this);
|
|
this.a.b();
|
|
}
|
|
}
|
|
|
|
public void e() {
|
|
User user = UserDbHandler.getUser();
|
|
if (user != null && user.getUserId() > 0) {
|
|
String token = user.getToken();
|
|
this.e.b(this.g, token);
|
|
this.e.c(this.g, token);
|
|
this.e.d(this.g, token);
|
|
this.e.e(this.g, token);
|
|
this.e.f(this.g, token);
|
|
this.e.g(this.g, token);
|
|
this.e.a(this.g, token);
|
|
}
|
|
}
|
|
|
|
public void f() {
|
|
String userId = Cache.getInstance().getUserId();
|
|
if (TextUtils.isEmpty(userId) || "local".equals(userId)) {
|
|
return;
|
|
}
|
|
this.f.a();
|
|
this.f.b();
|
|
}
|
|
|
|
public void g() {
|
|
this.d.c();
|
|
this.d.b();
|
|
this.d.a();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.sync.CreationModelListener
|
|
public void a() {
|
|
LogUtils.c("所有模型创建完毕,执行上传动作、编程、等");
|
|
String userId = Cache.getInstance().getUserId();
|
|
if (TextUtils.isEmpty(userId) || "local".equals(userId)) {
|
|
return;
|
|
}
|
|
this.a.c();
|
|
this.a.a();
|
|
this.a.d();
|
|
e();
|
|
b();
|
|
f();
|
|
c();
|
|
g();
|
|
}
|
|
}
|