package com.ubt.jimu.transport3.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.base.db.diy.DiyDBModel; import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler; import com.ubt.jimu.blockly.dao.JimuMotionDbHandler; import com.ubt.jimu.gen.DiyDBModelDao; import com.ubt.jimu.utils.LogUtils; import java.util.Iterator; import java.util.List; import org.greenrobot.greendao.AbstractDao; import org.greenrobot.greendao.query.QueryBuilder; /* loaded from: classes2.dex */ public class DiyDBModelDBHandler extends AbstractDaoHandler { private static DiyDBModelDBHandler diyDBModelDBHandler; public DiyDBModelDBHandler(AbstractDao abstractDao) { super(abstractDao); } public static synchronized DiyDBModelDBHandler getInstance() { DiyDBModelDBHandler diyDBModelDBHandler2; synchronized (DiyDBModelDBHandler.class) { if (diyDBModelDBHandler == null) { diyDBModelDBHandler = new DiyDBModelDBHandler(DatabaseUtils.getDaoSession(true).d()); } diyDBModelDBHandler2 = diyDBModelDBHandler; } return diyDBModelDBHandler2; } /* JADX WARN: Code restructure failed: missing block: B:10:0x0071, code lost: return r1; */ /* JADX WARN: Code restructure failed: missing block: B:14:0x006e, code lost: if (r2 == null) goto L15; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct code enable 'Show inconsistent code' option in preferences */ public static boolean saveModelLogoFile(android.content.Context r5, java.lang.String r6, java.lang.String r7) { /* boolean r0 = com.ubtech.utils.StringUtils.e(r7) r1 = 0 if (r0 == 0) goto L8 return r1 L8: java.lang.StringBuilder r0 = new java.lang.StringBuilder r0.() r2 = 0 java.lang.String r5 = com.ubt.jimu.utils.ExternalOverFroyoUtils.a(r5, r2) r0.append(r5) java.lang.String r5 = com.ubt.jimu.base.cache.Constants.CUSTOM_MODEL r3 = 1 java.lang.Object[] r3 = new java.lang.Object[r3] com.ubt.jimu.base.cache.Cache r4 = com.ubt.jimu.base.cache.Cache.getInstance() java.lang.String r4 = r4.getUserId() r3[r1] = r4 java.lang.String r5 = java.lang.String.format(r5, r3) r0.append(r5) r0.append(r6) java.lang.String r5 = r0.toString() java.lang.StringBuilder r0 = new java.lang.StringBuilder r0.() r0.append(r5) java.lang.String r5 = java.io.File.separator r0.append(r5) r0.append(r6) java.lang.String r5 = ".jpg" r0.append(r5) java.lang.String r5 = r0.toString() android.graphics.Bitmap$Config r6 = android.graphics.Bitmap.Config.RGB_565 // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6a r0 = 2 android.graphics.Bitmap r2 = com.ubtech.utils.BitmapFile.a(r7, r6, r0) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6a android.graphics.Bitmap$CompressFormat r6 = android.graphics.Bitmap.CompressFormat.JPEG // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6a r7 = 60 com.ubtech.utils.BitmapFile.a(r2, r6, r7, r5) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6a java.io.File r6 = new java.io.File // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6a r6.(r5) // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6a boolean r1 = r6.exists() // Catch: java.lang.Throwable -> L68 java.lang.Exception -> L6a if (r2 == 0) goto L71 L64: r2.recycle() goto L71 L68: r5 = move-exception goto L72 L6a: r5 = move-exception r5.printStackTrace() // Catch: java.lang.Throwable -> L68 if (r2 == 0) goto L71 goto L64 L71: return r1 L72: if (r2 == 0) goto L77 r2.recycle() L77: throw r5 */ throw new UnsupportedOperationException("Method not decompiled: com.ubt.jimu.transport3.dao.DiyDBModelDBHandler.saveModelLogoFile(android.content.Context, java.lang.String, java.lang.String):boolean"); } public boolean deleteDiyDBModelByModelId(int i) { DiyDBModel diyDBModelByModelId = getDiyDBModelByModelId(i); if (diyDBModelByModelId == null) { return false; } deleteModel(diyDBModelByModelId); return true; } public void deleteModel(DiyDBModel diyDBModel) { DiyDBModel selectUnique; if (diyDBModel == null || (selectUnique = selectUnique(diyDBModel)) == null) { return; } delete(selectUnique); TransportFileDbHandler2.getInstance().deleteModelFiles(selectUnique.getModelCreatedId(), selectUnique.getCustomModelId()); DiyModelActionDBHandler.getInstance().deleteModelActions(selectUnique.getModelCreatedId(), 2, selectUnique.getCustomModelId()); BlocklyProjectDbHandler.getInstance().deleteModelBlocklyProjects(selectUnique.getModelCreatedId(), 2, selectUnique.getCustomModelId()); JimuMotionDbHandler.getInstance().deleteModelMotions(selectUnique.getModelCreatedId(), selectUnique.getCustomModelId()); } public void deleteModels(List list) { if (list == null || list.size() == 0) { return; } Iterator it = list.iterator(); while (it.hasNext()) { deleteModel(it.next()); } } public List getDeletedDiyModels(String str) { QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) str), DiyDBModelDao.Properties.IsDelete.a((Object) true)); return query(k); } public List getDeletedModelDB() { String userId = Cache.getInstance().getUserId(); if (TextUtils.isEmpty(userId) || userId.equals("local")) { return null; } QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) userId), DiyDBModelDao.Properties.ModelId.b(0), DiyDBModelDao.Properties.IsDelete.a((Object) 1)); return query(k); } public DiyDBModel getDiyDBModelByModelId(int i) { DiyDBModel unique; if (i <= 0) { return null; } String userId = Cache.getInstance().getUserId(); if (TextUtils.isEmpty(userId) || userId.equals("local")) { return null; } QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) userId), DiyDBModelDao.Properties.ModelId.a(Integer.valueOf(i)), DiyDBModelDao.Properties.IsModify.a((Object) 1)); if (k == null || (unique = unique(k)) == null) { return null; } return unique; } public List getNewOrModifyDiyModels(String str) { QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) str), DiyDBModelDao.Properties.IsModify.a((Object) true)); return query(k); } public List getQiNiuDefeatModelDB() { String userId = Cache.getInstance().getUserId(); if (TextUtils.isEmpty(userId) || userId.equals("local")) { return null; } QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) userId), DiyDBModelDao.Properties.ModelId.c(0), DiyDBModelDao.Properties.CompressImagePath.b()); return query(k); } public List getUbtServiceDefeatModelDB() { String userId = Cache.getInstance().getUserId(); if (TextUtils.isEmpty(userId) || userId.equals("local")) { return null; } QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) userId), DiyDBModelDao.Properties.ModelId.c(0), DiyDBModelDao.Properties.CompressImagePath.a()); return query(k); } public List getUserDiyModels(String str) { QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) str), DiyDBModelDao.Properties.IsDelete.a((Object) false)); k.b(DiyDBModelDao.Properties.CustomModelCreatetime); return query(k); } public boolean updateModelId(String str, int i, long j) { DiyDBModel unique; String userId = Cache.getInstance().getUserId(); LogUtils.c("开始将模型数据写入数据库:" + userId + " modelId:" + i); if (TextUtils.isEmpty(userId) || userId.equals("local")) { return false; } QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) userId), DiyDBModelDao.Properties.CustomModelId.a((Object) str)); if (k == null || (unique = unique(k)) == null) { return false; } unique.setModelId(Integer.valueOf(i)); unique.setLastUploadTime(j); unique.setIsModify(false); insertOrUpdate(unique); return true; } public boolean updateQiNiuUrl(DiyDBModel diyDBModel) { DiyDBModel unique; String userId = Cache.getInstance().getUserId(); if (TextUtils.isEmpty(userId) || userId.equals("local")) { return false; } QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) userId), DiyDBModelDao.Properties.CustomModelId.a((Object) diyDBModel.getCustomModelId())); if (k == null || (unique = unique(k)) == null) { return false; } unique.setCompressImagePath(diyDBModel.getCompressImagePath()); insertOrUpdate(unique); return true; } @Override // com.ubt.jimu.base.db.AbstractDaoHandler, com.ubt.jimu.base.db.IDaoHandler public DiyDBModel selectUnique(DiyDBModel diyDBModel) { return selectUnique(diyDBModel.getModelCreatedId(), diyDBModel.getCustomModelId()); } public DiyDBModel selectUnique(String str, String str2) { QueryBuilder k = this.dao.k(); k.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) str), DiyDBModelDao.Properties.CustomModelId.a((Object) str2)); return unique(k); } }