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,73 @@
package com.ubt.jimu.diy.view.popupwindow;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.TextView;
import com.ubt.jimu.R;
import com.ubt.jimu.community.view.popwindow.BaseDialog;
import com.ubtech.permission.JimuPermissionRequest;
import com.ubtech.permission.PermissionRequestListener;
/* loaded from: classes2.dex */
public class ExchangeDialog extends BaseDialog {
private DialogInteraction interaction;
private TextView tvCancel;
private TextView tvExchange;
public interface DialogInteraction {
void onChangeModelLogo();
}
public ExchangeDialog(Context context) {
super(context);
}
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
public void initData() {
this.tvCancel = (TextView) findViewById(R.id.tv_cancel);
this.tvExchange = (TextView) findViewById(R.id.tv_exchange);
this.tvCancel.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.diy.view.popupwindow.ExchangeDialog.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
ExchangeDialog.this.dismiss();
}
});
this.tvExchange.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.diy.view.popupwindow.ExchangeDialog.2
@Override // android.view.View.OnClickListener
public void onClick(View view) {
JimuPermissionRequest.c((Activity) ((BaseDialog) ExchangeDialog.this).mContext, new PermissionRequestListener() { // from class: com.ubt.jimu.diy.view.popupwindow.ExchangeDialog.2.1
@Override // com.ubtech.permission.PermissionRequestListener
public void onDenied() {
}
@Override // com.ubtech.permission.PermissionRequestListener
public void onGranted() {
if (ExchangeDialog.this.interaction != null) {
ExchangeDialog.this.interaction.onChangeModelLogo();
}
ExchangeDialog.this.dismiss();
}
});
}
});
}
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
public int layoutId() {
return R.layout.dialog_exchange;
}
public void setInteraction(DialogInteraction dialogInteraction) {
this.interaction = dialogInteraction;
}
public ExchangeDialog(Context context, int i) {
super(context, i);
}
protected ExchangeDialog(Context context, boolean z, DialogInterface.OnCancelListener onCancelListener) {
super(context, z, onCancelListener);
}
}

View File

@@ -0,0 +1,366 @@
package com.ubt.jimu.diy.view.popupwindow;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.text.Editable;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.signature.ObjectKey;
import com.ubt.jimu.R;
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.RobotLite;
import com.ubt.jimu.blockly.Utils;
import com.ubt.jimu.community.view.popwindow.BaseDialog;
import com.ubt.jimu.connect.ConnectActivity;
import com.ubt.jimu.diy.DiyRobotDbHandler;
import com.ubt.jimu.diy.view.DiyFanActivity;
import com.ubt.jimu.gen.DiyDBModelDao;
import com.ubt.jimu.transport.dao.TransportFileDbHandler;
import com.ubt.jimu.transport.model.TransportFile;
import com.ubt.jimu.transport3.dao.DiyDBModelDBHandler;
import com.ubt.jimu.transport3.dao.TransportFileDbHandler2;
import com.ubt.jimu.unity.ModelType;
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
import com.ubt.jimu.utils.InputMethod;
import com.ubt.jimu.utils.LogUtils;
import com.ubt.jimu.utils.SystemUtils;
import com.ubt.jimu.widgets.EditTextWithDel;
import com.ubt.jimu.widgets.choosePhotos.AlbumActivity;
import com.ubtech.permission.JimuPermissionRequest;
import com.ubtech.permission.PermissionRequestListener;
import com.ubtech.utils.FileHelper;
import com.ubtech.utils.StringUtils;
import com.ubtech.view.widget.UButton;
import com.ubtrobot.log.ALog;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import org.greenrobot.greendao.query.QueryBuilder;
/* loaded from: classes2.dex */
public class SureDialog extends BaseDialog {
private String imageUrl;
private OnSureDialogInteraction interaction;
private boolean isEdit;
public boolean isModify;
private Activity mActivity;
private DiyDBModel mDb;
private EditTextWithDel mEdtRobotName;
private ImageView mLvAdd;
private UButton mSureBtn;
private String name;
private String url;
private String uuid;
public interface OnSureDialogInteraction {
void onCreateOrUpdateModelFailed(String str);
void onModifyModel(DiyDBModel diyDBModel);
void onSaveOrUpdateModel(DiyDBModel diyDBModel, TransportFile transportFile);
}
/* JADX WARN: Multi-variable type inference failed */
public SureDialog(Activity activity, boolean z) {
super(activity);
this.isModify = false;
this.isEdit = false;
this.isEdit = z;
this.mActivity = activity;
if (activity instanceof OnSureDialogInteraction) {
this.interaction = (OnSureDialogInteraction) activity;
}
}
private TransportFile newLogoFile(DiyDBModel diyDBModel, String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
TransportFileDbHandler2 transportFileDbHandler2 = TransportFileDbHandler2.getInstance();
TransportFile modelFile = transportFileDbHandler2.getModelFile(diyDBModel.getModelCreatedId(), diyDBModel.getCustomModelId(), "bg");
long a = SystemUtils.a();
if (modelFile == null) {
modelFile = new TransportFile();
modelFile.setUserId(Cache.getInstance().getUserId());
modelFile.setModelType(String.valueOf(2));
modelFile.setModelId(diyDBModel.getModelId().intValue());
modelFile.setCustomModelId(diyDBModel.getCustomModelId());
modelFile.setFileType("bg");
modelFile.setCreateTime(a);
}
modelFile.setFilePath(TransportFileDbHandler.getFilePath(new File(str)));
modelFile.setFileName(FileHelper.a(str));
modelFile.setIsModify(true);
modelFile.setModifyTime(a);
modelFile.setUploaded(false);
modelFile.setLastUploadTime(a);
transportFileDbHandler2.insertOrUpdate(modelFile);
return modelFile.getCustomFileId().longValue() == 0 ? transportFileDbHandler2.selectUnique(modelFile) : modelFile;
}
private void setModelName() {
boolean z;
ALog.a("timeOfNew").d("start:" + System.currentTimeMillis());
if (this.mDb == null) {
return;
}
if (!TextUtils.isEmpty(this.name) && this.name.equals(this.mDb.getModelName())) {
return;
}
String str = this.name;
if (com.ubt.jimu.utils.TextUtils.a(str, "\\w(\\(\\d+\\))$")) {
String str2 = this.name;
this.name = str2.substring(0, str2.indexOf("("));
}
String userId = Cache.getInstance().getUserId();
DiyDBModelDBHandler diyDBModelDBHandler = DiyDBModelDBHandler.getInstance();
QueryBuilder<DiyDBModel> queryBuilder = diyDBModelDBHandler.getQueryBuilder();
queryBuilder.a(DiyDBModelDao.Properties.ModelCreatedId.a((Object) userId), DiyDBModelDao.Properties.ModelName.a("%" + this.name + "%"));
List<DiyDBModel> query = diyDBModelDBHandler.query(queryBuilder);
if (query == null || query.size() == 0) {
this.mDb.setModelCreatedId(userId);
this.mDb.setModelName(str);
return;
}
String str3 = "\\" + this.name + "(\\(\\d{1,3}\\))$";
ArrayList arrayList = new ArrayList();
for (DiyDBModel diyDBModel : query) {
if (!TextUtils.isEmpty(diyDBModel.getModelName()) && (com.ubt.jimu.utils.TextUtils.a(diyDBModel.getModelName(), str3) || diyDBModel.getModelName().equals(this.name))) {
arrayList.add(diyDBModel);
}
}
if (arrayList.size() == 0) {
this.mDb.setModelCreatedId(userId);
this.mDb.setModelName(str);
return;
}
int i = 0;
while (true) {
String format = i == 0 ? this.name : String.format(this.name + "(%s)", String.valueOf(i));
Iterator it = arrayList.iterator();
while (true) {
if (!it.hasNext()) {
z = false;
break;
}
DiyDBModel diyDBModel2 = (DiyDBModel) it.next();
if (format.equals(diyDBModel2.getModelName()) && !diyDBModel2.getCustomModelId().equals(this.uuid)) {
z = true;
break;
}
}
if (!z) {
this.mDb.setModelCreatedId(userId);
this.mDb.setModelName(format);
ALog.a("timeOfNew").d("end :" + System.currentTimeMillis());
return;
}
i++;
}
}
public /* synthetic */ void a(DialogInterface dialogInterface) {
InputMethod.a((Activity) this.mContext);
}
@Override // android.app.Dialog, android.view.Window.Callback
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
boolean b;
return (motionEvent.getAction() == 0 && InputMethod.a(getCurrentFocus(), motionEvent) && (b = InputMethod.b(this.mActivity, getCurrentFocus()))) ? b : super.dispatchTouchEvent(motionEvent);
}
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
public void initData() {
onCreate();
if (!StringUtils.e(this.mDb.getModelName())) {
this.mEdtRobotName.setText(this.mDb.getModelName());
this.mEdtRobotName.setSelection(this.mDb.getModelName().length());
this.name = this.mDb.getModelName();
}
String logPath = DiyRobotDbHandler.getLogPath(ModelType.PLAYER_DATA, this.mDb.getCustomModelId());
if (new File(logPath).exists()) {
this.url = logPath;
} else {
this.url = this.mDb.getCompressImagePath();
}
if (!StringUtils.e(this.url)) {
RequestBuilder<Drawable> a = Glide.e(this.mContext).a(this.url);
a.a(new RequestOptions().a(new ObjectKey(Long.valueOf(this.mDb.getLastUploadTime()))).a(R.drawable.diy_img_default));
a.a(this.mLvAdd);
}
com.ubt.jimu.utils.TextUtils.a(this.mSureBtn, (StringUtils.e(this.name) || StringUtils.e(this.mDb.getFilePath())) ? false : true);
this.mSureBtn.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.diy.view.popupwindow.c
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
SureDialog.this.a(view);
}
});
this.mLvAdd.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.diy.view.popupwindow.SureDialog.1
@Override // android.view.View.OnClickListener
public void onClick(View view) {
JimuPermissionRequest.c((Activity) ((BaseDialog) SureDialog.this).mContext, new PermissionRequestListener() { // from class: com.ubt.jimu.diy.view.popupwindow.SureDialog.1.1
@Override // com.ubtech.permission.PermissionRequestListener
public void onDenied() {
}
@Override // com.ubtech.permission.PermissionRequestListener
public void onGranted() {
AlbumActivity.a((Activity) ((BaseDialog) SureDialog.this).mContext, 100, 1, null, 1, "UNITERMING_IMAGE");
}
});
}
});
this.mEdtRobotName.addTextChangedListener(new TextWatcher() { // from class: com.ubt.jimu.diy.view.popupwindow.SureDialog.2
@Override // android.text.TextWatcher
public void afterTextChanged(Editable editable) {
SureDialog sureDialog = SureDialog.this;
sureDialog.name = com.ubt.jimu.utils.TextUtils.a(sureDialog.mEdtRobotName, SureDialog.this.mEdtRobotName.getText().toString().trim());
com.ubt.jimu.utils.TextUtils.a(SureDialog.this.mSureBtn, (StringUtils.e(SureDialog.this.name) || StringUtils.e(SureDialog.this.url)) ? false : true);
}
@Override // android.text.TextWatcher
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override // android.text.TextWatcher
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
});
this.mEdtRobotName.setFilters(new InputFilter[]{new InputFilter() { // from class: com.ubt.jimu.diy.view.popupwindow.b
@Override // android.text.InputFilter
public final CharSequence filter(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
return SureDialog.a(charSequence, i, i2, spanned, i3, i4);
}
}, new InputFilter.LengthFilter(20)});
setCancel(true);
}
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
public int layoutId() {
return R.layout.fragment_create_robot;
}
public void onCreate() {
this.mEdtRobotName = (EditTextWithDel) findViewById(R.id.edt_robot_name);
this.mLvAdd = (ImageView) findViewById(R.id.lv_add);
this.mSureBtn = (UButton) findViewById(R.id.btn_sure);
if (StringUtils.e(this.uuid)) {
this.mDb = new DiyDBModel();
long a = SystemUtils.a();
this.uuid = Utils.getFormatId(a);
this.mDb.setCustomModelId(this.uuid);
this.mDb.setCustomModelCreatetime(a);
} else {
this.mDb = DiyHelper.getInstance().queryForUUid(this.uuid);
}
setOnDismissListener(new DialogInterface.OnDismissListener() { // from class: com.ubt.jimu.diy.view.popupwindow.a
@Override // android.content.DialogInterface.OnDismissListener
public final void onDismiss(DialogInterface dialogInterface) {
SureDialog.this.a(dialogInterface);
}
});
}
public void setImageUrl(String str) {
this.url = str;
Glide.e(this.mContext).a(str).a(this.mLvAdd);
com.ubt.jimu.utils.TextUtils.a(this.mSureBtn, (StringUtils.e(this.name) || StringUtils.e(str)) ? false : true);
}
public void showDialog() {
show();
}
public /* synthetic */ void a(View view) {
if (StringUtils.e(this.name)) {
return;
}
String logPath = DiyRobotDbHandler.getLogPath(ModelType.PLAYER_DATA, this.mDb.getCustomModelId());
TransportFile transportFile = null;
if (!TextUtils.isEmpty(this.url) && !logPath.equals(this.url)) {
if (!DiyDBModelDBHandler.saveModelLogoFile(getContext(), this.uuid, this.url)) {
if (this.interaction != null) {
LogUtils.c("保存模型Logo失败创建或者更新Logo失败");
this.interaction.onCreateOrUpdateModelFailed("");
return;
}
return;
}
transportFile = newLogoFile(this.mDb, logPath);
}
long a = SystemUtils.a();
this.mDb.setModelCreatedId(Cache.getInstance().getUserId());
this.mDb.setModifyTime(a);
this.mDb.setLastUploadTime(a);
this.mDb.setIsModify(true);
this.mDb.setFilePath(logPath);
setModelName();
if (DiyDBModelDBHandler.getInstance().insertOrUpdate(this.mDb) <= 0) {
if (this.interaction != null) {
LogUtils.c("插入/更新DiyDBModel失败创建/更新Logo失败");
this.interaction.onCreateOrUpdateModelFailed("");
return;
}
return;
}
OnSureDialogInteraction onSureDialogInteraction = this.interaction;
if (onSureDialogInteraction != null) {
onSureDialogInteraction.onSaveOrUpdateModel(this.mDb, transportFile);
}
dismiss();
if (!ExternalOverFroyoUtils.a(this.uuid)) {
DiyFanActivity.uuid = this.uuid;
Context context = this.mContext;
if (context instanceof Activity) {
ConnectActivity.a(101, (Activity) context, new RobotLite(this.mDb.getModelId().intValue(), this.uuid, this.name, "", true, true));
return;
} else {
Log.e("SureDialog", "Shouldn't to here");
return;
}
}
if (!this.isEdit) {
DiyFanActivity.start(this.mContext, this.mDb.getCustomModelId());
return;
}
OnSureDialogInteraction onSureDialogInteraction2 = this.interaction;
if (onSureDialogInteraction2 != null) {
onSureDialogInteraction2.onModifyModel(this.mDb);
}
}
/* JADX WARN: Multi-variable type inference failed */
public SureDialog(Activity activity, String str, boolean z) {
super(activity);
this.isModify = false;
this.isEdit = false;
this.uuid = str;
this.isEdit = z;
this.mActivity = activity;
if (activity instanceof OnSureDialogInteraction) {
this.interaction = (OnSureDialogInteraction) activity;
}
}
static /* synthetic */ CharSequence a(CharSequence charSequence, int i, int i2, Spanned spanned, int i3, int i4) {
if (Pattern.compile("[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~@#¥%……&*()——+|{}【】‘;:”“’。,、?]").matcher(charSequence.toString()).find()) {
return "";
}
return null;
}
}