From 24e7a66afcfaed8ab59c83695557a77fa97e5b6b Mon Sep 17 00:00:00 2001 From: liup <1454939542@qq.com> Date: Mon, 13 May 2024 17:36:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9UI=E5=88=B7=E6=96=B0=E9=94=99?= =?UTF-8?q?=E4=B9=B1=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE=E5=A4=8D=E6=A0=A1?= =?UTF-8?q?=E5=87=86=E5=BC=B9=E7=AA=97=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 13 +- app/src/main/AndroidManifest.xml | 1 + .../bnframework/HBL/Dialog/WaitDialog.java | 61 +++++-- .../com/bonait/bnframework/HBL/Unity.java | 1 - .../bonait/bnframework/business/MainInit.java | 2 +- .../common/helper/CrashHandler.java | 5 + .../bnframework/common/utils/ToastUtils.java | 42 +++-- .../common/utils/UpdateAppUtils.java | 15 +- .../home/adapter/loadinggood_adapter.java | 36 ++-- .../modules/home/adapter/wdsz_adapter.java | 5 + .../modules/home/adapter/wl_adapter.java | 5 +- .../home/fragment/MakeGoodFragment.java | 24 ++- .../modules/home/fragment/SheZhifragment.java | 2 +- .../home/fragment/from/SilosNewActivity.java | 5 +- .../home/fragment/mode/silos_jiaoyan.java | 171 +++++++++++------- .../main/res/layout/fragment_make_good.xml | 2 + app/src/main/res/layout/fragment_she_zhi.xml | 9 + .../item/layout/silos_jiaoyan_item_edit.xml | 36 +--- .../main/res/layout/item/layout/wdsz_item.xml | 1 + build.gradle | 4 +- gradle.properties | 2 +- 21 files changed, 269 insertions(+), 173 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 127cfff1..680d8662 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,12 @@ +import java.text.DateFormat +import java.text.SimpleDateFormat + apply plugin: 'com.android.application' //apply plugin: 'com.jakewharton.butterknife' - +def releaseTime() { + DateFormat df = new SimpleDateFormat("yyyyMMddHHmm") + return df.format(Calendar.getInstance(Locale.CHINA).getTime()) +} android { compileSdk rootProject.ext.compileSdkVersion @@ -51,6 +57,11 @@ android { } } + applicationVariants.all { variant -> + variant.outputs.all { + outputFileName = "boluobatai-v${defaultConfig.versionCode}-${releaseTime()}"+"-unsigned-${variant.name}.apk" + } + } } dependencies { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e3f47563..686eed94 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -146,6 +146,7 @@ activityWeakReference; + private WeakReference contextWeakReference; + private ProgressDialog progressDialog; + private static WaitDialog mInstance; //实例变量设置私有,防止直接通过类名访问 + + private WaitDialog() { + //默认构造函数私有,防止类外直接new创建对象 + } - public static void Show(String title,String msg,Context _context,Activity _activity){ - context=_context; - activity=_activity; - if(context==null) return; - progressDialog = new ProgressDialog(context); + public static synchronized WaitDialog getInstance() { //静态同步方法作为唯一的实例对象获取方式 + if (mInstance==null) { + synchronized (WaitDialog.class ){ + if(mInstance==null){ + mInstance = new WaitDialog(); + } + } + } + return mInstance; + } + //end + + public void Show(String title,String msg,Context _context,Activity _activity){ + contextWeakReference=new WeakReference<>(_context); + activityWeakReference = new WeakReference<>(_activity); + if(_context==null) return; + if(progressDialog!=null){ + progressDialog.dismiss(); + } + progressDialog = new ProgressDialog(_context); progressDialog.setTitle(title); progressDialog.setCancelable(false); progressDialog.setMessage(msg); progressDialog.show(); } - public static void AddText(String info){ - if(context==null) return; - if(activity==null) return; + public void AddText(String info){ + if(contextWeakReference.get()==null) return; + if(activityWeakReference.get()==null) return; if(progressDialog==null) return; - activity.runOnUiThread(()->{ progressDialog.setMessage(info);}); + activityWeakReference.get().runOnUiThread(()->{ progressDialog.setMessage(info);}); } - public static void Dismiss(){ - if(activity==null) return; + public void Dismiss(){ + if(activityWeakReference.get()==null) return; if(progressDialog==null) return; - activity.runOnUiThread(()->{ progressDialog.dismiss();}); + activityWeakReference.get().runOnUiThread(()->{ progressDialog.dismiss();}); } - public static void TimeOut(String info){ - if(activity==null) return; + public void TimeOut(String info){ + if(activityWeakReference.get()==null) return; if(progressDialog==null) return; Dismiss(); - DialogManager.showError(activity,info,AlertDialogButton.OK,null); + DialogManager.showError(activityWeakReference.get(),info,AlertDialogButton.OK,null); } + + } diff --git a/app/src/main/java/com/bonait/bnframework/HBL/Unity.java b/app/src/main/java/com/bonait/bnframework/HBL/Unity.java index de19b6d9..8580885a 100644 --- a/app/src/main/java/com/bonait/bnframework/HBL/Unity.java +++ b/app/src/main/java/com/bonait/bnframework/HBL/Unity.java @@ -25,7 +25,6 @@ public class Unity { if(func==null) return OperateResult.CreateFailed("条件为空"); boolean tag=false; while(!tag){ - Delay(100); tag=func.Run(); Delay(100); if(timeOut>0&&(System.currentTimeMillis()-startTime)>timeOut) break; diff --git a/app/src/main/java/com/bonait/bnframework/business/MainInit.java b/app/src/main/java/com/bonait/bnframework/business/MainInit.java index e17d262c..d7f8af17 100644 --- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java +++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java @@ -82,7 +82,7 @@ public class MainInit { MainNotification.initNotificationChannel(app); // 内存泄漏检测 - initLeakCanary(BuildConfig.DEBUG,app); + initLeakCanary(true,app); // Log日志打印框架 initLogCat(); diff --git a/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java b/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java index f33a8f4b..2d22b2d6 100644 --- a/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java +++ b/app/src/main/java/com/bonait/bnframework/common/helper/CrashHandler.java @@ -13,6 +13,8 @@ import android.os.SystemClock; import android.util.Log; import android.widget.Toast; +import com.bonait.bnframework.common.constant.ConfigName; + import java.io.File; import java.io.FileOutputStream; import java.io.FilenameFilter; @@ -85,6 +87,9 @@ public class CrashHandler implements UncaughtExceptionHandler { * @return true:��������˸��쳣��Ϣ; ���򷵻�false. */ private boolean handleException(Throwable ex) { + if(ConfigName.TEST){ + return false; + } if (ex == null) return false; diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/ToastUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/ToastUtils.java index 346fb654..3680c408 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/ToastUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/ToastUtils.java @@ -45,25 +45,26 @@ public class ToastUtils { private static final String TOAST_TYPEFACE = "sans-serif-condensed"; + private static Toast currentToastThread; private static Toast currentToast; //***********************普通 使用ApplicationContext 方法*********************// private static long mExitTime; public static void normal(@NonNull String message) { - normal(MainApplication.getContext(), message, Toast.LENGTH_SHORT, null, false).show(); + normal(MainApplication.getContext(), message, Toast.LENGTH_SHORT, null, false);//.show(); } public static void normal(@NonNull String message, Drawable icon) { - normal(MainApplication.getContext(), message, Toast.LENGTH_SHORT, icon, true).show(); + normal(MainApplication.getContext(), message, Toast.LENGTH_SHORT, icon, true);//.show(); } public static void normal(@NonNull String message, int duration) { - normal(MainApplication.getContext(), message, duration, null, false).show(); + normal(MainApplication.getContext(), message, duration, null, false);//.show(); } public static void normal(@NonNull String message, int duration, Drawable icon) { - normal(MainApplication.getContext(), message, duration, icon, true).show(); + normal(MainApplication.getContext(), message, duration, icon, true);//.show(); } public static Toast normal(@NonNull String message, int duration, Drawable icon, boolean withIcon) { @@ -71,11 +72,11 @@ public class ToastUtils { } public static void warning(@NonNull String message) { - warning(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true).show(); + warning(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true);//.show(); } public static void warning(@NonNull String message, int duration) { - warning(MainApplication.getContext(), message, duration, true).show(); + warning(MainApplication.getContext(), message, duration, true);//.show(); } public static Toast warning(@NonNull String message, int duration, boolean withIcon) { @@ -83,11 +84,11 @@ public class ToastUtils { } public static void info(@NonNull String message) { - info(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true).show(); + info(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true);//.show(); } public static void info(@NonNull String message, int duration) { - info(MainApplication.getContext(), message, duration, true).show(); + info(MainApplication.getContext(), message, duration, true);//.show(); } public static Toast info(@NonNull String message, int duration, boolean withIcon) { @@ -95,26 +96,27 @@ public class ToastUtils { } public static void success(@NonNull String message) { - success(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true).show(); + success(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true);//.show(); } public static void success(@NonNull String message, int duration) { - success(MainApplication.getContext(), message, duration, true).show(); + success(MainApplication.getContext(), message, duration, true);//.show(); } public static Toast success(@NonNull String message, int duration, boolean withIcon) { return custom(MainApplication.getContext(), message, getDrawable(MainApplication.getContext(), R.mipmap.ic_check_white_48dp), DEFAULT_TEXT_COLOR, SUCCESS_COLOR, duration, withIcon, true); } + //***********************// public static void error(@NonNull String message) { - error(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true).show(); + error(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true);//.show(); } //===========================================使用ApplicationContext 方法========================= //*******************************************常规方法******************************************** public static void error(@NonNull String message, int duration) { - error(MainApplication.getContext(), message, duration, true).show(); + error(MainApplication.getContext(), message, duration, true);//.show(); } public static Toast error(@NonNull String message, int duration, boolean withIcon) { @@ -259,14 +261,14 @@ public class ToastUtils { // currentToast.setGravity(Gravity.RIGHT | Gravity.TOP, 0, 0);//右上角 // currentToast.setGravity(Gravity.LEFT | Gravity.BOTTOM, 0, 0);//左下角 // currentToast.setGravity(Gravity.RIGHT | Gravity.BOTTOM, 0, 100);//右下角 - + currentToast.show(); return currentToast; } else { mHandler.post(new Runnable() { @Override public void run() { - if (currentToast == null) { - currentToast = new Toast(context); + if (currentToastThread == null) { + currentToastThread = new Toast(context); } final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.toast_layout, null); final ImageView toastIcon = toastLayout.findViewById(R.id.toast_icon); @@ -293,11 +295,11 @@ public class ToastUtils { toastTextView.setText(message); toastTextView.setTypeface(Typeface.create(TOAST_TYPEFACE, Typeface.NORMAL)); - currentToast.setView(toastLayout); - currentToast.setDuration(duration); - - currentToast.setGravity(Gravity.TOP,0,100); + currentToastThread.setView(toastLayout); + currentToastThread.setDuration(duration); + currentToastThread.setGravity(Gravity.TOP,0,100); + currentToastThread.show(); // currentToast.setGravity(Gravity.LEFT | Gravity.TOP, 0, 0);//左上角 // currentToast.setGravity(Gravity.RIGHT | Gravity.TOP, 0, 0);//右上角 // currentToast.setGravity(Gravity.LEFT | Gravity.BOTTOM, 0, 0);//左下角 @@ -307,7 +309,7 @@ public class ToastUtils { } - return currentToast; + return null; } public static final Drawable tint9PatchDrawableFrame(@NonNull Context context, @ColorInt int tintColor) { diff --git a/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java b/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java index d1328c9a..9b12ed31 100644 --- a/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java +++ b/app/src/main/java/com/bonait/bnframework/common/utils/UpdateAppUtils.java @@ -43,7 +43,7 @@ public class UpdateAppUtils { /** * 当前版本号 */ - private static String myVersionCode = "1.0"; + private static String myVersionCode = "1.2"; /** * 服务器的版本号 */ @@ -99,10 +99,15 @@ public class UpdateAppUtils { mode.branchCode="1712279450412756993"; }else { - mode.productCode="1679307017135329280"; - mode.moduleCode="newtwbt"; - mode.serverCode="1680767784879656960";//服务器 - mode.branchCode="1712279534630187009"; +// mode.productCode="1679307017135329280"; +// mode.moduleCode="newtwbt"; +// mode.serverCode="1680767784879656960";//服务器 +// mode.branchCode="1712279534630187009"; + + mode.productCode="1769564215952125952"; + mode.moduleCode="desktopplbt"; + mode.serverCode="1769564338190921728";//服务器 + mode.branchCode="1789857238682284033"; } //调味吧台 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java index 7d36479f..6bc8b18e 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java @@ -1,9 +1,11 @@ package com.bonait.bnframework.modules.home.adapter; import android.app.Activity; +import android.app.Application; import android.content.Context; import android.content.ContextWrapper; import android.media.MediaPlayer; +import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -18,6 +20,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; +import com.bonait.bnframework.MainApplication; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.constant.DataBus; @@ -30,6 +33,7 @@ import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.helper.MediaPlayerHelper; import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.ToastUtils; +import com.http.utils.LogUtils; import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; @@ -46,15 +50,16 @@ public class loadinggood_adapter extends RecyclerView.Adapter datas= DataBus.getInstance().GoodsMake; int resource1; - public Context conmain; - public Activity activity; +// public Context conmain; +// public Activity activity; private final LayoutInflater mLayoutInflater; + Handler handler = new Handler(); - public loadinggood_adapter(Context context,MyClickListener myClickListener,Activity ac) { - this.conmain = context; - activity=ac; + public loadinggood_adapter(Context context,MyClickListener myClickListener) { +// this.conmain = context; +// activity=ac; mListener=myClickListener; mLayoutInflater = LayoutInflater.from(context); } @@ -86,7 +91,7 @@ public class loadinggood_adapter extends RecyclerView.Adapter * 保存值 */ Button save_value; + /** + * 父容器 + */ + RelativeLayout root; RelativeLayout zdbs1,zdbs2,zdbs3,show_wdsz,show_wd; public WDSZViewHolder(View view) { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wl_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wl_adapter.java index 0eec817c..87f7c853 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wl_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/wl_adapter.java @@ -7,6 +7,7 @@ import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -43,8 +44,8 @@ public class wl_adapter extends ArrayAdapter { View view = LayoutInflater.from(getContext()).inflate(resource1, parent, false); //分别获取 image view 和 textview 的实例 TextView name = view.findViewById(R.id.name); - ImageView button = view.findViewById(R.id.button_item); - ImageView button_update = view.findViewById(R.id.button_update); + RelativeLayout button = view.findViewById(R.id.button_item); + RelativeLayout button_update = view.findViewById(R.id.button_update); // 设置要显示的图片和文字 name.setText(bpa_material.name); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java index 7ed5bb5b..9d676aa4 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java @@ -16,6 +16,7 @@ import android.content.res.Resources; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.os.ResultReceiver; import android.text.Editable; @@ -164,7 +165,16 @@ public class MakeGoodFragment extends BaseFragment { RelativeLayout loadgoodliebiao; - + private Handler handler = new Handler(Looper.getMainLooper()){ + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + if(msg.what == 1){ + DataBus.getInstance().loadinggoodAdapter = new loadinggood_adapter(context, myClickListener); + datatab_paiduishangping.setAdapter(DataBus.getInstance().loadinggoodAdapter); + } + } + }; private Context context; @@ -302,10 +312,12 @@ public class MakeGoodFragment extends BaseFragment { // LinearLayoutManager layoutManager = new LinearLayoutManager(context); // layoutManager.setOrientation(LinearLayoutManager.VERTICAL); // datatab_paiduishangping.setLayoutManager(layoutManager); - datatab_paiduishangping.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false)); - DataBus.getInstance().loadinggoodAdapter = new loadinggood_adapter(context, myClickListener, getActivity()); - datatab_paiduishangping.setAdapter(DataBus.getInstance().loadinggoodAdapter); + + handler.removeMessages(1); + handler.sendEmptyMessageDelayed(1,200); + + } @@ -457,6 +469,8 @@ public class MakeGoodFragment extends BaseFragment { } } }; + datatab_paiduishangping.setLayoutManager(new WrapContentLinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false)); + } @OnClick({R.id.good_gengxin, R.id.cheng_clear, R.id.loadgood}) @@ -498,7 +512,7 @@ public class MakeGoodFragment extends BaseFragment { case 0: plc_status.setText(ConfigName.getInstance().PlcIsConnect ? "正常" : "异常"); plc_status.setTextColor(ConfigName.getInstance().PlcIsConnect ? Color.parseColor("#4CAF50") : Color.parseColor("#D32F2F")); - wendu1.setText(ExecuteTheRecipe.WaterTemp + "°C"); +// wendu1.setText(ExecuteTheRecipe.WaterTemp + "°C"); MessageLog.ShowInfo("重量 ExecuteTheRecipe.OutletWeigh="+ExecuteTheRecipe.OutletWeigh); dianzichen.setText(String.valueOf((int) ExecuteTheRecipe.OutletWeigh / 10.0) + " g"); break; diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java index 40072e60..2218a1d3 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/SheZhifragment.java @@ -75,7 +75,7 @@ public class SheZhifragment extends BaseFragment { skipToActivity(DzcjyActivity.class); break; case R.id.wdsz://温度设置 - skipToActivity(WdszActivity.class); +// skipToActivity(WdszActivity.class); break; } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java index 7ee4f431..e9045b4b 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java @@ -144,7 +144,7 @@ public class SilosNewActivity extends BaseActivity { } else if (k == 4) { //校准 silos_jz.SetData((lcMode) data, activity); - silos_jz.setVisibility(View.VISIBLE); + silos_jz.show(); } else if (k == 5) { // } else if (k == 6) { @@ -162,7 +162,7 @@ public class SilosNewActivity extends BaseActivity { @Override public void clickListenerNew(View v, int k, Object data) { if (k == 0) { - silos_jz.setVisibility(View.GONE); + silos_jz.close(); } } }; @@ -228,6 +228,7 @@ public class SilosNewActivity extends BaseActivity { @Override public void onDestroy() { super.onDestroy(); + silos_jz.close(); MessageManager.getInstance().unRegisterMessageReceiver(this); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java index 17b91096..2772df16 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java @@ -33,6 +33,9 @@ import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.helper.MessageLog; import com.bonait.bnframework.common.utils.ToastUtils; +import java.util.Timer; +import java.util.TimerTask; + import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; @@ -71,8 +74,9 @@ public class silos_jiaoyan extends LinearLayout { @BindView(R.id.sim_discharge_weight) EditText sim_discharge_weight; - @BindView(R.id.tv_discharge_result) - TextView tv_discharge_result; + + @BindView(R.id.current_weight) + TextView current_weight; // @BindView(R.id.controlStatus) // TextView controlStatus; @@ -139,11 +143,11 @@ public class silos_jiaoyan extends LinearLayout { if(res!=null){ min_time.setText(String.valueOf(res.outputTimeMin)); max_time.setText(String.valueOf(res.outputTimeMax)); - min_weight.setText(String.valueOf(res.inputWightMin)); - max_weight.setText(String.valueOf(res.inputWightMax)); + min_weight.setText(res.inputWightMin+""); + max_weight.setText(res.inputWightMax+""); }else{ min_time.setText("2"); - max_time.setText("2"); + max_time.setText("5"); min_weight.setText("0"); max_weight.setText("0"); } @@ -180,34 +184,22 @@ public class silos_jiaoyan extends LinearLayout { public void Run() { final int kkk = lcMode.num; try { - if(activity!=null) - { - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - try { - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - // 在2秒后执行按钮操作 - int zhongliangxianshi = ExecuteTheRecipe.OutletWeigh; - ExecuteTheRecipe.WritePLC("校准值" + kkk, (short) zhongliangxianshi, null); - String s = String.valueOf(zhongliangxianshi); - String zll = String.format("%.1f", (Double.parseDouble(s) / 10)); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + // 在2秒后执行按钮操作 + int zhongliangxianshi = ExecuteTheRecipe.OutletWeigh; + ExecuteTheRecipe.WritePLC("校准值" + kkk, (short) zhongliangxianshi, null); + String s = String.valueOf(zhongliangxianshi); + String zll = String.format("%.1f", (Double.parseDouble(s) / 10)); // wljz3.setText(zll + ""); - lcMode.jValue = zll; - QueryDB.UpdateJYZ(lcMode.id, zll); - ToastUtils.warning("通道校准完成!"); - } - }, 2000); - } catch (Exception e) { - ToastUtils.error("重量解析显示异常!" + e.getMessage()); - } - } - }); - } - } catch (Exception ex) { - Log.d("dsds", "Run: " + ex.getMessage()); + lcMode.jValue = zll; + QueryDB.UpdateJYZ(lcMode.id, zll); + ToastUtils.warning("通道校准完成!"); + } + }, 2000); + } catch (Exception e) { + ToastUtils.error("重量解析显示异常!" + e.getMessage()); } } }; @@ -234,11 +226,42 @@ public class silos_jiaoyan extends LinearLayout { */ private Handler mHandler = new Handler() { public void handleMessage(Message msg) { - + if(msg.what == 1){ + } } }; //endregion + private Timer timer; + private TimerTask timerTask; + + public void show(){ + close(); + setVisibility(VISIBLE); + timer = new Timer(); + timerTask = new TimerTask() { + @Override + public void run() { + activity.runOnUiThread(()->{ + float resultWeight = (float) (ExecuteTheRecipe.ReadShort(PLCName.称当前重量)/10.0); + current_weight.setText(resultWeight+"g"); + }); + } + }; + timer.schedule(timerTask,500,500); + } + + public void close(){ + setVisibility(GONE); + if(timer!=null){ + timer.cancel(); + timer = null; + } + if(timerTask!=null){ + timerTask.cancel(); + timerTask = null; + } + } private float EditTextValidate(EditText et,String info){ @@ -267,26 +290,33 @@ public class silos_jiaoyan extends LinearLayout { if(time<0) return; DialogManager.showWarn(activity,"校准前请确认是否准备就绪?\r\n是否开始校准?", AlertDialogButton.YesNo,s->{ if(s){ - WaitDialog.Show(view.getId()==R.id.min_time?"最小校准":"最大校准","开始校准",getContext(),activity); + WaitDialog.getInstance().Show(view.getId()==R.id.min_time?"最小校准":"最大校准","开始校准",getContext(),activity); Executor.get().runThread(()->{ - WaitDialog.AddText("电子秤清零"); - ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 - ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 - ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 - - WaitDialog.AddText("等待清零完成"); + WaitDialog.getInstance().AddText("电子秤清零"); + try { + ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 + Thread.sleep(100); + ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 + Thread.sleep(100); + ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + WaitDialog.getInstance().AddText("等待清零完成"); //等待清零完成 - Unity.Wait(()->{return ExecuteTheRecipe.ReadShort(PLCName.称当前重量)>-20&&ExecuteTheRecipe.ReadShort(PLCName.称当前重量)<=20;},3000).OnSource(()->{ + Unity.Wait(()->{ + return ExecuteTheRecipe.ReadShort(PLCName.称当前重量)>-20&&ExecuteTheRecipe.ReadShort(PLCName.称当前重量)<=20;},3000).OnSource(()->{ - WaitDialog.AddText("下发参数,开始校准"); + WaitDialog.getInstance().AddText("下发参数,开始校准"); ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"出料时间",((int) time)*100,null);//下发出料时间 long startTime = System.currentTimeMillis(); MessageLog.ShowInfo("下发参数,开始校准 当前时间:"+startTime +" 出料时间"+((int) time)*100); ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"启停控制",true,null);//下发启动信号 - WaitDialog.AddText("等待校准完成"); + WaitDialog.getInstance().AddText("等待校准完成"); String name = lcMode.name+lcMode.num+"启停控制"; //等待出料完成 Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},(int)(time*1000+2000)).OnSource(()->{ @@ -304,11 +334,11 @@ public class silos_jiaoyan extends LinearLayout { if(view.getId()==R.id.btn_min_standard) min_weight.setText(weight+""); else max_weight.setText(weight+""); }); - WaitDialog.Dismiss(); + WaitDialog.getInstance().Dismiss(); DialogManager.showInfo(activity,"校准完成",AlertDialogButton.OK,null); - }).OnFailed(msg->{WaitDialog.TimeOut("等待校准完成超时,请退出后重试!");}); + }).OnFailed(msg->{WaitDialog.getInstance().TimeOut("等待校准完成超时,请退出后重试!");}); TTrig.Remove(name); - }).OnFailed((msg)->{WaitDialog.TimeOut("等待清零超时,请退出后重试!");}); + }).OnFailed((msg)->{WaitDialog.getInstance().TimeOut("等待清零超时,请退出后重试!");}); }); } }); @@ -329,49 +359,52 @@ public class silos_jiaoyan extends LinearLayout { // } }catch(Exception e){} - + WaitDialog.getInstance().Show("模拟","模拟出料",getContext(),activity); DialogManager.showWarn(activity,"模拟出料前请将容器放入指定位置!\r\n请问是否继续",AlertDialogButton.YesNo,(s->{ if(s){ try{ float weight = Float.parseFloat(sim_discharge_weight.getText().toString()); BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(lcMode.num); if(res!=null){ - WaitDialog.AddText("电子秤清零"); - ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 - ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 - ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 - WaitDialog.AddText("等待清零完成"); + WaitDialog.getInstance().AddText("电子秤清零"); + try { + ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 + Thread.sleep(100); + ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 + Thread.sleep(100); + ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零 + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + WaitDialog.getInstance().AddText("等待清零完成"); //等待清零完成 - Unity.Wait(()->{return ExecuteTheRecipe.ReadShort(PLCName.称当前重量)>-20&&ExecuteTheRecipe.ReadShort(PLCName.称当前重量)<=20;},3000).OnSource(()->{ + Unity.Wait(()->{ + return ExecuteTheRecipe.ReadShort(PLCName.称当前重量)>-20&&ExecuteTheRecipe.ReadShort(PLCName.称当前重量)<=20;},2000).OnSource(()->{ float outValue = Unity.Scale(weight,res.inputWightMax,res.inputWightMin,res.outputTimeMax,res.outputTimeMin); - WaitDialog.Show("模拟出料","启动模拟出料",getContext(),activity); + WaitDialog.getInstance().Show("模拟出料","启动模拟出料",getContext(),activity); Executor.get().runThread(()->{ ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"出料时间",(short)(outValue*100),null);//下发出料时间 ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"启停控制",true,null);//下发启动信号 - WaitDialog.AddText("等待出料完成"); + WaitDialog.getInstance().AddText("等待出料完成"); String name = lcMode.name+lcMode.num+"启停控制"; - Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},(int)(outValue*1000)+2000).OnSource(()->{ - try { - Thread.sleep(500); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - WaitDialog.Dismiss(); - - activity.runOnUiThread(()->{ - float resultWeight = (float) (ExecuteTheRecipe.ReadShort(PLCName.称当前重量)/10.0); - tv_discharge_result.setText(resultWeight+"g"); - }); - }).OnFailed(msg->{WaitDialog.TimeOut("等待出料完成超时,请退出后重试!");}); + try { + Thread.sleep((int)(outValue*1000)+500); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + WaitDialog.getInstance().Dismiss(); TTrig.Remove(name); }); - }).OnFailed((msg)->{WaitDialog.TimeOut("等待清零超时,请退出后重试!");}); + }).OnFailed((msg)->{WaitDialog.getInstance().TimeOut("等待清零超时,请退出后重试!");}); }else{ DialogManager.showWarn(activity,"料仓参数未校准,请校准后再试!",AlertDialogButton.OK,null); } }catch(Exception e){ DialogManager.showError(activity,"模拟出料失败,"+e.getMessage(),AlertDialogButton.OK,null); } + }else { + WaitDialog.getInstance().Dismiss(); } })); break; diff --git a/app/src/main/res/layout/fragment_make_good.xml b/app/src/main/res/layout/fragment_make_good.xml index 1bdc158b..79689e9c 100644 --- a/app/src/main/res/layout/fragment_make_good.xml +++ b/app/src/main/res/layout/fragment_make_good.xml @@ -148,6 +148,7 @@ android:layout_height="wrap_content" android:layout_margin="5dp" android:text="水箱:" + android:visibility="gone" android:textSize="@dimen/TitleSize" /> diff --git a/app/src/main/res/layout/fragment_she_zhi.xml b/app/src/main/res/layout/fragment_she_zhi.xml index 16e80bc8..6ba95f1f 100644 --- a/app/src/main/res/layout/fragment_she_zhi.xml +++ b/app/src/main/res/layout/fragment_she_zhi.xml @@ -78,6 +78,7 @@ android:layout_height="match_parent" android:layout_margin="20dp" android:layout_weight="1" + android:visibility="gone" android:orientation="vertical"> + + + diff --git a/app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml b/app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml index 9ad54c98..8c0c1bb7 100644 --- a/app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml +++ b/app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools" android:clickable="true" android:focusable="true" android:background="@color/black"> @@ -38,7 +39,7 @@ android:id="@+id/current_weight" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="实际出料重量:" + tools:text="实际出料重量:" android:textSize="20sp"/> @@ -156,7 +157,7 @@ android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/edit_bord" - android:digits="0123456789" + android:digits="0123456789." android:hint="请输入" android:inputType="numberDecimal|number" android:maxLines="1" @@ -228,7 +229,7 @@ android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/edit_bord" - android:digits="0123456789" + android:digits="0123456789." android:hint="请输入" android:inputType="numberDecimal|number" android:maxLines="1" @@ -296,12 +297,12 @@ android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/edit_bord" - android:digits="0123456789" + android:digits="0123456789." android:hint="请输入" android:inputType="number|numberDecimal" android:maxLines="1" android:padding="3dp" - android:text="2" + android:text="10" android:textSize="20sp"/> @@ -318,32 +319,7 @@ - - - - - - - - - diff --git a/app/src/main/res/layout/item/layout/wdsz_item.xml b/app/src/main/res/layout/item/layout/wdsz_item.xml index d5ec11f3..c405bc53 100644 --- a/app/src/main/res/layout/item/layout/wdsz_item.xml +++ b/app/src/main/res/layout/item/layout/wdsz_item.xml @@ -2,6 +2,7 @@ diff --git a/build.gradle b/build.gradle index d33ce3df..bb47f2fb 100644 --- a/build.gradle +++ b/build.gradle @@ -35,8 +35,8 @@ task clean(type: Delete) { ext { // 统一版本入口 //App版本号 - versionCode = 1 - versionName = "1.0.0" + versionCode = 12 + versionName = "1.2.0" // 支持Android版本 buildToolsVersion = "33.0.0" diff --git a/gradle.properties b/gradle.properties index 5cd40bd4..3fabf948 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m +org.gradle.jvmargs=-Xmx2048m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects