liup 3 weeks ago
parent
commit
8c4755f921
19 changed files with 553 additions and 170 deletions
  1. +2
    -1
      app/src/main/java/com/jdzh/jdzhandroid/Business/TaskControl.java
  2. +39
    -39
      app/src/main/java/com/jdzh/jdzhandroid/Enum/SiloChannel.java
  3. +3
    -2
      app/src/main/java/com/jdzh/jdzhandroid/MainActivity.java
  4. +1
    -1
      app/src/main/java/com/jdzh/jdzhandroid/MainApplication.java
  5. +1
    -1
      app/src/main/java/com/jdzh/jdzhandroid/UI/fragment/MaterialSiloFragment.java
  6. +1
    -1
      app/src/main/java/com/jdzh/jdzhandroid/UI/fragment/PowderSiloFragment.java
  7. +219
    -113
      app/src/main/java/com/jdzh/jdzhandroid/util/Dialog/DialogManager.java
  8. +57
    -12
      app/src/main/java/com/jdzh/jdzhandroid/util/Dialog/DialogView.java
  9. +1
    -0
      app/src/main/java/com/jdzh/jdzhandroid/viewmodel/DebugViewModel.java
  10. +5
    -0
      app/src/main/res/drawable/selector_bottle_bg.xml
  11. +5
    -0
      app/src/main/res/drawable/selector_bottle_textcolor.xml
  12. +5
    -0
      app/src/main/res/drawable/selector_cassette_bg.xml
  13. +4
    -0
      app/src/main/res/drawable/selector_null.xml
  14. +19
    -0
      app/src/main/res/layout/item/layout/item_silo.xml
  15. +191
    -0
      app/src/main/res/layout/layout/silo_select_dialog_layout.xml
  16. BIN
     
  17. BIN
     
  18. BIN
     
  19. BIN
     

+ 2
- 1
app/src/main/java/com/jdzh/jdzhandroid/Business/TaskControl.java View File

@@ -73,7 +73,8 @@ public class TaskControl {
BPA_Batching batching = SqliteHelper.get().queryByBuilderEntity(BPA_Batching.class,
BPA_BatchingDao.Properties.Id.eq(detail.getBatchingId()));
if(batching != null){
int num = SiloChannel.getChannelNum(batching.getSiloChannelNum());
// int num = SiloChannel.getChannelNum(batching.getSiloChannelNum());
int num= SiloChannel.formValue(batching.getSiloChannelNum()).Content.getValue();
if(num==0){
if(callBack!=null){
callBack.onError("【"+batching.getName()+"】未绑定通道!");


+ 39
- 39
app/src/main/java/com/jdzh/jdzhandroid/Enum/SiloChannel.java View File

@@ -18,14 +18,14 @@ public enum SiloChannel implements IntegerBaseEnum<RecipeType> {
粉料通道4(4),
粉料通道5(5),
粉料通道6(6),
液体通道1(10),
液体通道2(11),
液体通道3(12),
液体通道4(13),
液体通道5(14),
液体通道6(15);
液体通道1(7),
液体通道2(8),
液体通道3(9),
液体通道4(10),
液体通道5(11),
液体通道6(12);

int value;
int value=0;
SiloChannel(int mValue){this.value=mValue;}
public int getValue(){return this.value;}
public static OperateResultT<SiloChannel> formValue(int mValue){
@@ -45,37 +45,37 @@ public enum SiloChannel implements IntegerBaseEnum<RecipeType> {
return names;
}

public static int getChannelNum(String name){
switch (name){
case "未设置":
return 0;
case "粉料通道1":
return 1;
case "粉料通道2":
return 2;
case "粉料通道3":
return 3;
case "粉料通道4":
return 4;
case "粉料通道5":
return 5;
case "粉料通道6":
return 6;
case "液体通道1":
return 7;
case "液体通道2":
return 8;
case "液体通道3":
return 9;
case "液体通道4":
return 10;
case "液体通道5":
return 11;
case "液体通道6":
return 12;
default:
return 0;
}
}
// public static int getChannelNum(String name){
// switch (name){
// case "未设置":
// return 0;
// case "粉料通道1":
// return 1;
// case "粉料通道2":
// return 2;
// case "粉料通道3":
// return 3;
// case "粉料通道4":
// return 4;
// case "粉料通道5":
// return 5;
// case "粉料通道6":
// return 6;
// case "液体通道1":
// return 7;
// case "液体通道2":
// return 8;
// case "液体通道3":
// return 9;
// case "液体通道4":
// return 10;
// case "液体通道5":
// return 11;
// case "液体通道6":
// return 12;
// default:
// return 0;
// }
// }

}

+ 3
- 2
app/src/main/java/com/jdzh/jdzhandroid/MainActivity.java View File

@@ -110,8 +110,9 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus && GlobalContext.getActivity()==null || GlobalContext.getContext()==null ){
GlobalContext.init(this,this);
if(hasFocus && GlobalContext.getContext()==null ){
GlobalContext.setContext(this);
// GlobalContext.init(this,this);
}
}



+ 1
- 1
app/src/main/java/com/jdzh/jdzhandroid/MainApplication.java View File

@@ -48,7 +48,7 @@ public class MainApplication extends Application {
saveCrashLogToFile(throwable);
});
context = getApplicationContext();
GlobalContext.setContext(context);
// GlobalContext.setContext(context);
GlobalContext.setResources(getResources());
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override


+ 1
- 1
app/src/main/java/com/jdzh/jdzhandroid/UI/fragment/MaterialSiloFragment.java View File

@@ -47,7 +47,7 @@ public class MaterialSiloFragment extends Fragment {
private void init(){
List<BPA_Batching> bpaBatchingList = SqliteHelper.get().queryAll(BPA_Batching.class);
for(BPA_Batching bean : bpaBatchingList){
updateSilo(SiloChannel.getChannelNum(bean.getSiloChannelNum()),bean.getName());
updateSilo(SiloChannel.formValue(bean.getSiloChannelNum()).Content.getValue(),bean.getName());
}
binding.silo1.postDelayed(new Runnable() {
@Override


+ 1
- 1
app/src/main/java/com/jdzh/jdzhandroid/UI/fragment/PowderSiloFragment.java View File

@@ -76,7 +76,7 @@ public class PowderSiloFragment extends Fragment {
private void init(){
List<BPA_Batching> bpaBatchingList = SqliteHelper.get().queryAll(BPA_Batching.class);
for(BPA_Batching bean : bpaBatchingList){
updateSilo(SiloChannel.getChannelNum(bean.getSiloChannelNum()),bean.getName());
updateSilo(SiloChannel.formValue(bean.getSiloChannelNum()).Content.getValue(),bean.getName());
}
}



+ 219
- 113
app/src/main/java/com/jdzh/jdzhandroid/util/Dialog/DialogManager.java View File

@@ -3,15 +3,20 @@ package com.jdzh.jdzhandroid.util.Dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.viewbinding.ViewBinding;

import com.jdzh.jdzhandroid.Enum.DialogButton;
import com.jdzh.jdzhandroid.Enum.SiloChannel;
import com.jdzh.jdzhandroid.Interface.IFuncT;
@@ -23,6 +28,7 @@ import com.jdzh.jdzhandroid.Sqlite.DAO.BPA_BatchingDao;
import com.jdzh.jdzhandroid.Sqlite.Model.BPA_Batching;
import com.jdzh.jdzhandroid.Sqlite.SqliteHelper;
import com.jdzh.jdzhandroid.databinding.MaterialEditDialogLayoutBinding;
import com.jdzh.jdzhandroid.databinding.SiloSelectDialogLayoutBinding;
import com.jdzh.jdzhandroid.util.AlertDialogUtil;
import com.jdzh.jdzhandroid.util.GlobalContext;
import com.jdzh.jdzhandroid.util.ToastUtil;
@@ -43,66 +49,128 @@ import java.util.concurrent.atomic.AtomicReference;
*/
public class DialogManager {

// private static Context DialogUtil.getContext();
//
// private static Activity DialogUtil.getActivity();
//
// public static void Init(Context context,Activity activity){
// DialogUtil.getContext() = context;
// DialogUtil.getActivity()=activity;
// }


public static void showDialog(BPA_Batching batching, IFuncT<OperateResultT<BPA_Batching>> action){
if(GlobalContext.getContext()==null) return;
try{
AtomicReference<DialogView>dview=new AtomicReference<>();
dview.set(new DialogView(GlobalContext.getContext(), R.layout.material_edit_dialog_layout , R.style.CustomDialog));
if(isDialogEmpty(dview.get())){
dview.set(new DialogView(GlobalContext.getActivity(), R.layout.material_edit_dialog_layout, R.style.CustomDialog));
}
if (dview != null) {
if (!dview.get().isShowing()) {

dview.get().setCanceledOnTouchOutside(false);//禁用触摸其它区域关闭弹框
TextView materialName = dview.get().findViewById(R.id.materialName);
Spinner channelNames = dview.get().findViewById(R.id.channelNames);
Button ok = (Button)dview.get().findViewById(R.id.btn_ok);
Button cancel = (Button)dview.get().findViewById(R.id.btn_cancel);
AtomicBoolean isEdit=new AtomicBoolean(false);
if(batching!=null){
public static void showDialog(){
DialogView.createDailog( R.layout.silo_select_dialog_layout,v->{
v.setCanceledOnTouchOutside(true);//禁用触摸其它区域关闭弹框
SiloSelectDialogLayoutBinding binding=SiloSelectDialogLayoutBinding.inflate(v.getLayoutInflater());
v.setContentView(binding.getRoot());
binding.liquidRb1.setText("123");
binding.liquidGroup.setOnCheckedChangeListener((group,id)->{
RadioButton rb = v.findViewById(id);
if( rb!=null && rb.isChecked()){
binding.powderGroup1.clearCheck();
binding.powderGroup2.clearCheck();
binding.powderGroup3.clearCheck();
}
});

binding.powderGroup1.setOnCheckedChangeListener((group,id)->{
RadioButton rb = v.findViewById(id);
if(rb!=null && rb.isChecked()){
binding.liquidGroup.clearCheck();
binding.powderGroup2.clearCheck();
binding.powderGroup3.clearCheck();
}
});

binding.powderGroup2.setOnCheckedChangeListener((group,id)->{
RadioButton rb = v.findViewById(id);
if(rb!=null && rb.isChecked()){
binding.powderGroup1.clearCheck();
binding.liquidGroup.clearCheck();
binding.powderGroup3.clearCheck();
}
});

binding.powderGroup3.setOnCheckedChangeListener((group,id)->{
RadioButton rb = v.findViewById(id);
if(rb!=null && rb.isChecked()){
binding.powderGroup1.clearCheck();
binding.powderGroup2.clearCheck();
binding.liquidGroup.clearCheck();
}
});

// String[] names = GlobalContext.getResources().getStringArray(R.array.siloChannel);
// List<String> names = Arrays.asList(GlobalContext.getResources().getStringArray(R.array.siloChannel));
List<String> names = SiloChannel.getNames();
int index = names.indexOf(batching.getSiloChannelNum());
if(index>=0){
channelNames.setSelection(index);
}
materialName.setText(batching.getName());
Object obj = channelNames.getSelectedItem();
isEdit.set(true);
}
ok.setOnClickListener(view->{
BPA_Batching batching1 = new BPA_Batching(materialName.getText().toString(),channelNames.getSelectedItem().toString());
if(action!=null){
if(action.Run(OperateResultT.CreateSuccess(batching1))) hide(dview.get());
}else hide(dview.get());
});
});
}

cancel.setOnClickListener(view->{
if(action!=null)action.Run(OperateResultT.CreateFailedT("取消当前操作"));
hide(dview.get());
});
dview.get().show();
public static void showDialog(BPA_Batching batching, IFuncT<OperateResultT<BPA_Batching>> action){
DialogView.createDailog(R.layout.material_edit_dialog_layout,v->{
v.setCanceledOnTouchOutside(false);//禁用触摸其它区域关闭弹框
MaterialEditDialogLayoutBinding binding = MaterialEditDialogLayoutBinding.inflate(v.getLayoutInflater());
v.setContentView(binding.getRoot());
AtomicBoolean isEdit=new AtomicBoolean(false);
if(batching!=null){
// List<String> names = Arrays.asList(GlobalContext.getResources().getStringArray(R.array.siloChannel));
List<String> names = SiloChannel.getNames();
int index = names.indexOf(batching.getSiloChannelNum());
if(index>=0){
binding.channelNames.setSelection(index);
}
binding.materialName.setText(batching.getName());
Object obj = binding.channelNames.getSelectedItem();
isEdit.set(true);
}
}catch(Exception e){
MessageLog.ShowError("打开弹框异常:"+e.toString());
}
binding.btnOk.setOnClickListener(view->{
BPA_Batching batching1 = new BPA_Batching(binding.materialName.getText().toString(),binding.channelNames.getSelectedItem().toString());
if(action!=null){
if(action.Run(OperateResultT.CreateSuccess(batching1))) v.hide();
}else v.hide();
});

binding.btnCancel.setOnClickListener(view->{
if(action!=null)action.Run(OperateResultT.CreateFailedT("取消当前操作"));
v.hide();
});
});


// if(GlobalContext.getContext()==null) return;
// try{
// AtomicReference<DialogView>dview=new AtomicReference<>();
// dview.set(new DialogView(GlobalContext.getContext(), R.layout.material_edit_dialog_layout , R.style.CustomDialog));
// if(isDialogEmpty(dview.get())){
// dview.set(new DialogView(GlobalContext.getActivity(), R.layout.material_edit_dialog_layout, R.style.CustomDialog));
// }
// if (dview != null) {
// if (!dview.get().isShowing()) {
//
// dview.get().setCanceledOnTouchOutside(false);//禁用触摸其它区域关闭弹框
// TextView materialName = dview.get().findViewById(R.id.materialName);
// Spinner channelNames = dview.get().findViewById(R.id.channelNames);
// Button ok = (Button)dview.get().findViewById(R.id.btn_ok);
// Button cancel = (Button)dview.get().findViewById(R.id.btn_cancel);
// AtomicBoolean isEdit=new AtomicBoolean(false);
// if(batching!=null){
// List<String> names = Arrays.asList(GlobalContext.getResources().getStringArray(R.array.siloChannel));
// int index = names.indexOf(batching.getSiloChannelNum());
// if(index>=0){
// channelNames.setSelection(index);
// }
// materialName.setText(batching.getName());
// Object obj = channelNames.getSelectedItem();
// isEdit.set(true);
// }
// ok.setOnClickListener(view->{
// BPA_Batching batching1 = new BPA_Batching(materialName.getText().toString(),channelNames.getSelectedItem().toString());
// if(action!=null){
// if(action.Run(OperateResultT.CreateSuccess(batching1))) hide(dview.get());
// }else hide(dview.get());
// });
//
// cancel.setOnClickListener(view->{
// if(action!=null)action.Run(OperateResultT.CreateFailedT("取消当前操作"));
// hide(dview.get());
// });
// dview.get().show();
// }
// }
// }catch(Exception e){
// MessageLog.ShowError("打开弹框异常:"+e.toString());
// }
}


/**
* 判断Dialog的窗口令牌是否为空
* @param dialog
@@ -120,55 +188,90 @@ public class DialogManager {
* 对话框,自定义按钮,非阻塞
* */
private static void showDialog(String message, DialogButton btn, DialogType dt, IRunT<Boolean> action) {
if(GlobalContext.getContext()==null) return;
try{
AtomicReference<DialogView>dview=new AtomicReference<>();
dview.set(new DialogView(GlobalContext.getContext(), R.layout.dialog_layout, R.style.CustomDialog));
if(isDialogEmpty(dview.get())){
dview.set(new DialogView(GlobalContext.getActivity(), R.layout.dialog_layout, R.style.CustomDialog));
}
if (dview != null) {
if (!dview.get().isShowing()) {

String btnName1="确定";
String btnName2="取消";
if(btn==DialogButton.YesNoCancel||btn==DialogButton.YesNo){
btnName1="是";
btnName2="否";
}

dview.get().setCanceledOnTouchOutside(false);//禁用触摸其它区域关闭弹框
RelativeLayout rlTitle = (RelativeLayout) dview.get().findViewById(R.id.rl_title);
if(dt== DialogType.提示)rlTitle.setBackgroundResource(R.drawable.dialog_info_title_back);
if(dt== DialogType.警告)rlTitle.setBackgroundResource(R.drawable.dialog_warn_title_back);
if(dt== DialogType.错误)rlTitle.setBackgroundResource(R.drawable.dialog_error_title_back);
TextView Tv=(TextView)dview.get().findViewById(R.id.tv_Title);
TextView Info=(TextView)dview.get().findViewById(R.id.tv_Info);
Button ok = (Button)dview.get().findViewById(R.id.btn_ok);
Button cancel = (Button)dview.get().findViewById(R.id.btn_cancel);

Tv.setText(dt.toString());
Info.setText(message);
ok.setText(btnName1);
cancel.setText(btnName2);

if(btn==DialogButton.OK)cancel.setVisibility(View.GONE);

ok.setOnClickListener(view->{
if(action!=null)action.Run(true);
hide(dview.get());
});

cancel.setOnClickListener(view->{
if(action!=null)action.Run(false);
hide(dview.get());
});
dview.get().show();
}
DialogView.createDailog(R.layout.dialog_layout,v->{
String btnName1="确定";
String btnName2="取消";
if(btn==DialogButton.YesNoCancel||btn==DialogButton.YesNo){
btnName1="是";
btnName2="否";
}
}catch(Exception e){
MessageLog.ShowError("打开弹框异常:"+e.toString());
}
v.setCanceledOnTouchOutside(false);//禁用触摸其它区域关闭弹框
RelativeLayout rlTitle = (RelativeLayout) v.findViewById(R.id.rl_title);
if(dt== DialogType.提示)rlTitle.setBackgroundResource(R.drawable.dialog_info_title_back);
if(dt== DialogType.警告)rlTitle.setBackgroundResource(R.drawable.dialog_warn_title_back);
if(dt== DialogType.错误)rlTitle.setBackgroundResource(R.drawable.dialog_error_title_back);
TextView Tv=(TextView)v.findViewById(R.id.tv_Title);
TextView Info=(TextView)v.findViewById(R.id.tv_Info);
Button ok = (Button)v.findViewById(R.id.btn_ok);
Button cancel = (Button)v.findViewById(R.id.btn_cancel);

Tv.setText(dt.toString());
Info.setText(message);
ok.setText(btnName1);
cancel.setText(btnName2);

if(btn==DialogButton.OK)cancel.setVisibility(View.GONE);

ok.setOnClickListener(view->{
if(action!=null)action.Run(true);
v.hide();
});

cancel.setOnClickListener(view->{
if(action!=null)action.Run(false);
v.hide();
});
});

// if(GlobalContext.getContext()==null) return;
// try{
// AtomicReference<DialogView>dview=new AtomicReference<>();
// dview.set(new DialogView(GlobalContext.getContext(), R.layout.dialog_layout, R.style.CustomDialog));
// if(isDialogEmpty(dview.get())){
// dview.set(new DialogView(GlobalContext.getActivity(), R.layout.dialog_layout, R.style.CustomDialog));
// }
// if (dview != null) {
// if (!dview.get().isShowing()) {
//
// String btnName1="确定";
// String btnName2="取消";
// if(btn==DialogButton.YesNoCancel||btn==DialogButton.YesNo){
// btnName1="是";
// btnName2="否";
// }
//
// dview.get().setCanceledOnTouchOutside(false);//禁用触摸其它区域关闭弹框
// RelativeLayout rlTitle = (RelativeLayout) dview.get().findViewById(R.id.rl_title);
// if(dt== DialogType.提示)rlTitle.setBackgroundResource(R.drawable.dialog_info_title_back);
// if(dt== DialogType.警告)rlTitle.setBackgroundResource(R.drawable.dialog_warn_title_back);
// if(dt== DialogType.错误)rlTitle.setBackgroundResource(R.drawable.dialog_error_title_back);
// TextView Tv=(TextView)dview.get().findViewById(R.id.tv_Title);
// TextView Info=(TextView)dview.get().findViewById(R.id.tv_Info);
// Button ok = (Button)dview.get().findViewById(R.id.btn_ok);
// Button cancel = (Button)dview.get().findViewById(R.id.btn_cancel);
//
// Tv.setText(dt.toString());
// Info.setText(message);
// ok.setText(btnName1);
// cancel.setText(btnName2);
//
// if(btn==DialogButton.OK)cancel.setVisibility(View.GONE);
//
// ok.setOnClickListener(view->{
// if(action!=null)action.Run(true);
// hide(dview.get());
// });
//
// cancel.setOnClickListener(view->{
// if(action!=null)action.Run(false);
// hide(dview.get());
// });
// dview.get().show();
// }
// }
// }catch(Exception e){
// MessageLog.ShowError("打开弹框异常:"+e.toString());
// }
}

/**
@@ -292,10 +395,11 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showInfo(String message, DialogButton btn, IRunT<Boolean> action) {
if(GlobalContext.getActivity()==null&&!Util.IsMainThread())return;
if(!Util.IsMainThread())
GlobalContext.getActivity().runOnUiThread(()->{showDialog(message,btn,DialogType.提示,action);});
else showDialog(message,btn,DialogType.提示,action);
// if(GlobalContext.getActivity()==null&&!Util.IsMainThread())return;
// if(!Util.IsMainThread())
// GlobalContext.getActivity().runOnUiThread(()->{showDialog(message,btn,DialogType.提示,action);});
// else showDialog(message,btn,DialogType.提示,action);
showDialog(message,btn,DialogType.提示,action);
}

/**
@@ -305,10 +409,11 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showWarn(String message, DialogButton btn, IRunT<Boolean> action) {
if(GlobalContext.getActivity()==null&&!Util.IsMainThread())return;
if(!Util.IsMainThread())
GlobalContext.getActivity().runOnUiThread(()->{showDialog(message,btn,DialogType.警告,action);});
else showDialog(message,btn,DialogType.警告,action);
// if(GlobalContext.getActivity()==null&&!Util.IsMainThread())return;
// if(!Util.IsMainThread())
// GlobalContext.getActivity().runOnUiThread(()->{showDialog(message,btn,DialogType.警告,action);});
// else showDialog(message,btn,DialogType.警告,action);
showDialog(message,btn,DialogType.警告,action);
}

/**
@@ -318,10 +423,11 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showError(String message, DialogButton btn, IRunT<Boolean> action) {
if(GlobalContext.getActivity()==null&&!Util.IsMainThread())return;
if(!Util.IsMainThread())
GlobalContext.getActivity().runOnUiThread(()->{showDialog(message,btn,DialogType.错误,action);});
else showDialog(message,btn,DialogType.错误,action);
// if(GlobalContext.getActivity()==null&&!Util.IsMainThread())return;
// if(!Util.IsMainThread())
// GlobalContext.getActivity().runOnUiThread(()->{showDialog(message,btn,DialogType.错误,action);});
// else showDialog(message,btn,DialogType.错误,action);
showDialog(message,btn,DialogType.错误,action);
}




+ 57
- 12
app/src/main/java/com/jdzh/jdzhandroid/util/Dialog/DialogView.java View File

@@ -3,12 +3,22 @@ package com.jdzh.jdzhandroid.util.Dialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import androidx.annotation.NonNull;
import androidx.viewbinding.ViewBinding;

import com.jdzh.jdzhandroid.Interface.IRunT;
import com.jdzh.jdzhandroid.Log.MessageLog;
import com.jdzh.jdzhandroid.R;
import com.jdzh.jdzhandroid.databinding.SiloSelectDialogLayoutBinding;
import com.jdzh.jdzhandroid.util.GlobalContext;
import com.jdzh.jdzhandroid.util.Util;

public class DialogView extends Dialog {

public DialogView(@NonNull Context context, int layout, int style, int gravity) {
@@ -20,23 +30,58 @@ public class DialogView extends Dialog {
public DialogView(@NonNull Context context, int layout, int style) {
super(context, style);
setContentView(layout);
Window mWindow = getWindow();
}

public DialogView(@NonNull Activity activity, int layout, int style) {
super(activity, style);
setContentView(layout);
Window mWindow = getWindow();
}

// public DialogView(@NonNull Activity activity, ViewBinding layout, int style) {
// super(activity, style);
// setContentView(layout.getRoot());
// Window mWindow = getWindow();
// }
// public DialogView(@NonNull Context context, ViewBinding layout, int style) {
// super(context, style);
// setContentView(layout.getRoot());
// Window mWindow = getWindow();
// }
public void hide() {
if (this.isShowing()) {
this.dismiss();
}
}

public boolean isDialogEmpty(){
if(getWindow()==null) return true;
View decorView=getWindow().getDecorView();
return decorView==null||!decorView.isAttachedToWindow();
}

public static void createDailog(int layout, IRunT<DialogView> callback) {
try{
if(Util.IsMainThread()){
if(GlobalContext.getContext()==null){
MessageLog.ShowError("打开弹框失败,Context");
return;
}
DialogView dv= new DialogView(GlobalContext.getContext(),layout, R.style.CustomDialog);
if(dv==null || dv.isDialogEmpty()){
dv= new DialogView(GlobalContext.getActivity(),layout, R.style.CustomDialog);
}

if(!dv.isShowing() && callback!=null){
callback.Run(dv);
dv.show();
}
}else{
if(GlobalContext.getActivity()==null){
MessageLog.ShowError("打开弹框失败,请设置活动的Activity");
return;
}else{
GlobalContext.getActivity().runOnUiThread(()->{
DialogView dv= new DialogView(GlobalContext.getActivity(),layout, R.style.CustomDialog);
if(dv!=null&& !dv.isShowing()&&callback!=null){
callback.Run(dv);
dv.show();
}
});
}
}
}catch (Exception e){
MessageLog.ShowError("打开弹框异常:"+e.toString());
}
}

}

+ 1
- 0
app/src/main/java/com/jdzh/jdzhandroid/viewmodel/DebugViewModel.java View File

@@ -51,6 +51,7 @@ public class DebugViewModel extends ViewModel {
* 通道校准
*/
public void calibration(){
// DialogManager.showDialog();
if(!PlcControl.get().IsConnected||!ElectoronicScales.get().IsConnected) {
DialogManager.showWarn("设备未连接!", DialogButton.OK,null);
return;


+ 5
- 0
app/src/main/res/drawable/selector_bottle_bg.xml View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/bottle_select" android:state_checked="true"/>
<item android:drawable="@mipmap/bottle_not_select" />
</selector>

+ 5
- 0
app/src/main/res/drawable/selector_bottle_textcolor.xml View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#E91E63" android:state_checked="true"/>
<item android:color="#FF6E40" />
</selector>

+ 5
- 0
app/src/main/res/drawable/selector_cassette_bg.xml View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/cassette_select" android:state_checked="true"/>
<item android:drawable="@mipmap/cassette_not_select" />
</selector>

+ 4
- 0
app/src/main/res/drawable/selector_null.xml View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>

+ 19
- 0
app/src/main/res/layout/item/layout/item_silo.xml View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/bottle_not_select"/>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="物料名称"/>

</LinearLayout>

+ 191
- 0
app/src/main/res/layout/layout/silo_select_dialog_layout.xml View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/dialog_back"
android:columnCount="1"
android:orientation="vertical"
android:padding="20dp">

<RadioGroup
android:id="@+id/liquidGroup"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">

<RadioButton
android:id="@+id/liquidRb1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:background="@drawable/selector_bottle_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/liquidRb2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_bottle_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/liquidRb3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:background="@drawable/selector_bottle_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/liquidRb4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_bottle_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/liquidRb5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:background="@drawable/selector_bottle_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/liquidRb6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:background="@drawable/selector_bottle_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />
</RadioGroup>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RadioGroup
android:id="@+id/powderGroup1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">

<RadioButton
android:id="@+id/powderRb1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_cassette_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/powderRb2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_cassette_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />
</RadioGroup>

<RadioGroup
android:id="@+id/powderGroup2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">

<RadioButton
android:id="@+id/powderRb3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_cassette_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/powderRb4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_cassette_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />
</RadioGroup>

<RadioGroup
android:id="@+id/powderGroup3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">

<RadioButton
android:id="@+id/powderRb5"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_cassette_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />

<RadioButton
android:id="@+id/powderRb6"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_cassette_bg"
android:button="@null"
android:gravity="bottom|center"
android:text="未配置"
android:textColor="@drawable/selector_bottle_textcolor" />
</RadioGroup>


</LinearLayout>

</LinearLayout>

BIN
View File


BIN
View File


BIN
View File


BIN
View File


Loading…
Cancel
Save