From 5a8f0a9ad893659424c1d55956117017c06a9662 Mon Sep 17 00:00:00 2001 From: fyf Date: Wed, 27 Sep 2023 18:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 30 +++ .../home/fragment/DingDanfragment.java | 9 +- .../modules/home/fragment/GuanLifragment.java | 13 +- .../home/fragment/JiaoYanFragment.java | 15 ++ .../modules/home/fragment/SheZhifragment.java | 13 +- .../from/DeviceInformationActivity.java | 118 ++++++++ .../fragment/from/ImageSourceActivity.java | 195 ++++++++++++++ .../home/fragment/from/LogActivity.java | 78 ++++++ .../home/fragment/from/OrderListActivity.java | 70 +++++ .../fragment/from/PlcControlActivity.java | 108 ++++++++ .../home/fragment/from/RealTimeActivity.java | 78 ++++++ .../from/SalesStatisticsActivity.java | 69 +++++ .../from/SystemParameterActivity.java | 247 +++++++++++++++++ .../from/fragment/PlcControl_kz_fragment.java | 116 ++++++++ .../from/fragment/PlcControl_pz_fragment.java | 142 ++++++++++ .../res/layout/activity_deviceinformation.xml | 254 ++++++++++++++++++ .../main/res/layout/activity_goodpeifang.xml | 3 +- .../main/res/layout/activity_imagesource.xml | 133 +++++++++ app/src/main/res/layout/activity_log.xml | 36 +++ .../main/res/layout/activity_orderlist.xml | 24 ++ .../main/res/layout/activity_plccontrol.xml | 36 +++ app/src/main/res/layout/activity_realtime.xml | 36 +++ .../res/layout/activity_salesstatistics.xml | 24 ++ .../res/layout/activity_systemparameter.xml | 190 +++++++++++++ app/src/main/res/layout/fragment_jiaoyan.xml | 35 ++- .../res/layout/fragment_plccontrol_kz.xml | 39 +++ .../res/layout/fragment_plccontrol_pz.xml | 55 ++++ 27 files changed, 2145 insertions(+), 21 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DeviceInformationActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_kz_fragment.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_pz_fragment.java create mode 100644 app/src/main/res/layout/activity_deviceinformation.xml create mode 100644 app/src/main/res/layout/activity_imagesource.xml create mode 100644 app/src/main/res/layout/activity_log.xml create mode 100644 app/src/main/res/layout/activity_orderlist.xml create mode 100644 app/src/main/res/layout/activity_plccontrol.xml create mode 100644 app/src/main/res/layout/activity_realtime.xml create mode 100644 app/src/main/res/layout/activity_salesstatistics.xml create mode 100644 app/src/main/res/layout/activity_systemparameter.xml create mode 100644 app/src/main/res/layout/fragment_plccontrol_kz.xml create mode 100644 app/src/main/res/layout/fragment_plccontrol_pz.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e9c387f6..aa0da5e4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,36 @@ tools:ignore="GoogleAppIndexingWarning" tools:node="merge" tools:replace="android:icon"> + + + + + + + + + + diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DingDanfragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DingDanfragment.java index f2e57eb0..8837a145 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DingDanfragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/DingDanfragment.java @@ -13,7 +13,11 @@ import android.view.View; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.from.JcsjglActivity; +import com.bonait.bnframework.modules.home.fragment.from.OrderListActivity; +import com.bonait.bnframework.modules.home.fragment.from.SalesStatisticsActivity; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.widget.QMUITopBarLayout; @@ -57,11 +61,10 @@ public class DingDanfragment extends BaseFragment { public void onViewClicked(View view) { switch (view.getId()) { case R.id.ddgl:// - ToastUtils.info("点击按钮:订单管理"); + ConfigName.getInstance().fragmentAdapter.replaceFragment(2,new OrderListActivity()); break; case R.id.xltj:// - //skipToActivity(DiyActivity.class); - ToastUtils.info("点击按钮:销量统计"); + ConfigName.getInstance().fragmentAdapter.replaceFragment(2,new SalesStatisticsActivity()); break; } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/GuanLifragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/GuanLifragment.java index 00bf25f9..a8738242 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/GuanLifragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/GuanLifragment.java @@ -12,7 +12,12 @@ import android.view.View; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.from.JcsjglActivity; +import com.bonait.bnframework.modules.home.fragment.from.LogActivity; +import com.bonait.bnframework.modules.home.fragment.from.PlcControlActivity; +import com.bonait.bnframework.modules.home.fragment.from.RealTimeActivity; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.widget.QMUITopBarLayout; @@ -53,15 +58,13 @@ public class GuanLifragment extends BaseFragment { public void onViewClicked(View view) { switch (view.getId()) { case R.id.plckz:// - ToastUtils.info("点击按钮:PLC数据管理"); + ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new PlcControlActivity()); break; case R.id.rzgl:// - //skipToActivity(DiyActivity.class); - ToastUtils.info("点击按钮:日志管理"); + ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new LogActivity()); break; case R.id.ssjk:// - ToastUtils.info("点击按钮:实时监控"); - //skipToActivity(CpActivity.class); + ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new RealTimeActivity()); break; } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java index 5800e0a7..a30007e5 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/JiaoYanFragment.java @@ -3,11 +3,13 @@ package com.bonait.bnframework.modules.home.fragment; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.RecyclerView; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; +import android.widget.LinearLayout; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; @@ -22,6 +24,13 @@ public class JiaoYanFragment extends BaseFragment { @BindView(R.id.topbar) QMUITopBarLayout mTopBar;//顶部标题 + + @BindView(R.id.rv_left) + RecyclerView rv_left;//左侧菜单 + + @BindView(R.id.child) + LinearLayout child;//右侧控件 + private Context context; public JiaoYanFragment() { @@ -39,6 +48,7 @@ public class JiaoYanFragment extends BaseFragment { super.onViewCreated(view, savedInstanceState); context = getContext(); initTopBar(); + initData(); } /** @@ -48,6 +58,11 @@ public class JiaoYanFragment extends BaseFragment { mTopBar.setTitle("设备校正"); } + public void initData() + { + + } + @Override public void onDestroy() { super.onDestroy(); 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 bb3344cd..cf17eaca 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 @@ -12,7 +12,12 @@ import android.view.View; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.from.DeviceInformationActivity; +import com.bonait.bnframework.modules.home.fragment.from.ImageSourceActivity; +import com.bonait.bnframework.modules.home.fragment.from.PlcControlActivity; +import com.bonait.bnframework.modules.home.fragment.from.SystemParameterActivity; import com.orhanobut.logger.Logger; import com.qmuiteam.qmui.widget.QMUITopBarLayout; @@ -55,15 +60,13 @@ public class SheZhifragment extends BaseFragment { public void onViewClicked(View view) { switch (view.getId()) { case R.id.xtcs:// - ToastUtils.info("点击按钮:系统参数"); + ConfigName.getInstance().fragmentAdapter.replaceFragment(5,new SystemParameterActivity()); break; case R.id.imagegl:// - //skipToActivity(DiyActivity.class); - ToastUtils.info("点击按钮:图片资源管理"); + ConfigName.getInstance().fragmentAdapter.replaceFragment(5,new ImageSourceActivity()); break; case R.id.shebeixinxi:// - ToastUtils.info("点击按钮:设备信息"); - //skipToActivity(CpActivity.class); + ConfigName.getInstance().fragmentAdapter.replaceFragment(5,new DeviceInformationActivity()); break; } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DeviceInformationActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DeviceInformationActivity.java new file mode 100644 index 00000000..490f8e2e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DeviceInformationActivity.java @@ -0,0 +1,118 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.EditText; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.modules.home.fragment.SheZhifragment; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class DeviceInformationActivity extends BaseFragment { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + private Context context; + + @BindView(R.id.edittext1) + EditText edittext1; + @BindView(R.id.edittext2) + EditText edittext2; + @BindView(R.id.edittext3) + EditText edittext3; + @BindView(R.id.edittext4) + EditText edittext4; + @BindView(R.id.edittext5) + EditText edittext5; + @BindView(R.id.edittext6) + EditText edittext6; + @BindView(R.id.edittext7) + EditText edittext7; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_deviceinformation, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + initdata(); + } + + private void initTopBar() { + mTopBar.setTitle("系统参数"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(5,new SheZhifragment()); + } + }); + } + + /** + * 初始化数据 + */ + public void initdata() + { + if(ConfigName.getInstance().organizeMode !=null && ConfigName.getInstance().deviceInformation!=null) + { + edittext1.setText(ConfigName.getInstance().deviceInformation.id); + edittext2.setText(ConfigName.getInstance().deviceInformation.deviceName); + edittext3.setText(ConfigName.getInstance().deviceInformation.deviceLoc); + edittext4.setText(ConfigName.getInstance().organizeMode.tel); + edittext5.setText(ConfigName.getInstance().deviceInformation.deviceAddr); + edittext6.setText(ConfigName.getInstance().organizeMode.id); + edittext7.setText(ConfigName.getInstance().organizeMode.store_Name); + +// if(ConfigName.getInstance().organizeMode.logo!=null) +// { +// new MyBitmapUtils().disPlay(image,ConfigName.getInstance().organizeMode.logo); +// } + }else + { + edittext1.setText(ConfigName.getInstance().DeviceId); + edittext2.setText(ConfigName.getInstance().versionSelectionEnum); + edittext3.setText("未知"); + edittext4.setText(""); + edittext5.setText("未知"); + edittext6.setText("未知"); + edittext7.setText("未知"); + } + } + + /** + * + * viewPager里添加fragment + */ + private void initFragment() { + + } + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java new file mode 100644 index 00000000..354b74a2 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/ImageSourceActivity.java @@ -0,0 +1,195 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.Bundle; +import android.os.Environment; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.Button; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.constant.Constants; +import com.bonait.bnframework.common.filepicker.PickerManager; +import com.bonait.bnframework.common.filepicker.adapter.FilePickerShowAdapter; +import com.bonait.bnframework.common.filepicker.adapter.OnFileItemClickListener; +import com.bonait.bnframework.common.filepicker.model.FileEntity; +import com.bonait.bnframework.common.filepicker.model.FileType; +import com.bonait.bnframework.common.image.utils.LocalCacheUtils; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.SheZhifragment; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class ImageSourceActivity extends BaseFragment { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + private Context context; + + @BindView(R.id.rl_file) + RecyclerView mRecyclerView; + @BindView(R.id.rl_yx_file) + RecyclerView rl_yx_file; + @BindView(R.id.baocunbendi) + Button baocunbendi; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_imagesource, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + FlushedImage(); + } + + private void initTopBar() { + mTopBar.setTitle("系统参数"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(5,new SheZhifragment()); + } + }); + } + /** + * viewPager里添加fragment + */ + private void initFragment() { + + } + + @OnClick({R.id.xuanzhewenjian, R.id.baocunbendi}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.xuanzhewenjian://保存按钮 + Intent intent = new Intent(context, FileActivity.class); + startActivityForResult(intent, Constants.REQ_CODE); + break; + case R.id.baocunbendi://保存按钮 + BitmapFactory.Options options = new BitmapFactory.Options(); + options.inSampleSize = 2;//宽高压缩为原来的1/2 + for (FileEntity item : PickerManager.getInstance().files) { + File file = item.getFile(); + try { + Bitmap bitmap1 = BitmapFactory.decodeStream(new FileInputStream(file)); + new LocalCacheUtils().setBitmapToLocal(file.getName(), bitmap1); + } catch (Exception e) { + } + } + ToastUtils.info("添加成功!"); + break; + } + } + + ArrayList yx_files = new ArrayList<>(); + private static final String CACHE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/hblchayingdb/WebImage"; + + public void FlushedImage() { + File path = new File(CACHE_PATH);// 获得路径 + File[] files = path.listFiles();// 读取文件 + yx_files.clear(); + for (File f : files) { + String absolutePath = f.getAbsolutePath(); + FileEntity e; + if (checkExits(absolutePath)) { + e = new FileEntity(absolutePath, f, true); + } else { + e = new FileEntity(absolutePath, f, false); + } + if (f.isFile()) { + String[] imgs = {"png", "jpg", "jpeg", "gif"}; + e.setFileType(new FileType("IMG", imgs, 0)); + yx_files.add(e); + } + } + rl_yx_file.setLayoutManager(new LinearLayoutManager(context)); + FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files); + rl_yx_file.setAdapter(adapter); + adapter.setOnItemClickListener(new OnFileItemClickListener() { + @Override + public void click(int position) { + +// String path=yx_files.get(position).getPath(); +// Bitmap bitmap =BitmapFactory.decodeFile("file://" + path); +// MyImageDialog myImageDialog = new MyImageDialog(getActivity(),R.style.dialogWindowAnim,0,0,bitmap); +// myImageDialog.show(); + + //打开系统相册浏览照片 +// Intent intent = new Intent(); +// intent.setAction(Intent.ACTION_VIEW); +// intent.setDataAndType(Uri.parse("file://" + path), "image/*"); +// startActivity(intent); + } + }); + } + + private static boolean checkExits(String path) { + for (FileEntity entity : PickerManager.getInstance().files) { + if (entity.getPath().equals(path)) { + return true; + } + } + return false; + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == Constants.REQ_CODE) { + mRecyclerView.setLayoutManager(new LinearLayoutManager(context)); + FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, PickerManager.getInstance().files); + mRecyclerView.setAdapter(adapter); + + String res = "(" + PickerManager.getInstance().files.size() + "/" + PickerManager.getInstance().maxCount + ")"; + baocunbendi.setText(getString(R.string.file_select_res1, res)); + adapter.setOnItemClickListener(new OnFileItemClickListener() { + @Override + public void click(int position) { + +// String path=PickerManager.getInstance().files.get(position).getPath(); +// Intent intent = new Intent(); +// intent.setAction(Intent.ACTION_VIEW); +// intent.setDataAndType(Uri.parse("file://" + path), "image/*"); +// startActivity(intent); + } + }); + } + } + + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java new file mode 100644 index 00000000..578edefd --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/LogActivity.java @@ -0,0 +1,78 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.modules.home.fragment.GuanLifragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_sxgl_fragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_wl_fragment; +import com.qmuiteam.qmui.arch.QMUIFragment; +import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; +import com.qmuiteam.qmui.widget.QMUIViewPager; +import com.qmuiteam.qmui.widget.tab.QMUITabSegment; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class LogActivity extends BaseFragment { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + @BindView(R.id.tabs) + QMUITabSegment tabs; + @BindView(R.id.viewpager_wl) + QMUIViewPager viewpager_wl; + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_log, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + } + + private void initTopBar() { + mTopBar.setTitle("日志管理"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new GuanLifragment()); + } + }); + } + /** + * viewPager里添加fragment + */ + private void initFragment() { + + } + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java new file mode 100644 index 00000000..1e508d85 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/OrderListActivity.java @@ -0,0 +1,70 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.modules.home.fragment.DingDanfragment; +import com.bonait.bnframework.modules.home.fragment.GuanLifragment; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class OrderListActivity extends BaseFragment { + + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_orderlist, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + } + + private void initTopBar() { + mTopBar.setTitle("订单列表"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(2,new DingDanfragment()); + } + }); + } + /** + * viewPager里添加fragment + */ + private void initFragment() { + + } + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java new file mode 100644 index 00000000..0c5f0142 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/PlcControlActivity.java @@ -0,0 +1,108 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.modules.home.fragment.GongnengFragment; +import com.bonait.bnframework.modules.home.fragment.GuanLifragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_sxgl_fragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_wl_fragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.PlcControl_kz_fragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.PlcControl_pz_fragment; +import com.qmuiteam.qmui.arch.QMUIFragment; +import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; +import com.qmuiteam.qmui.widget.QMUIViewPager; +import com.qmuiteam.qmui.widget.tab.QMUITabSegment; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class PlcControlActivity extends BaseFragment { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + @BindView(R.id.tabs) + QMUITabSegment tabs; + @BindView(R.id.viewpager_wl) + QMUIViewPager viewpager_wl; + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_plccontrol, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + } + + private void initTopBar() { + mTopBar.setTitle("PLC地址配置与控制"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new GuanLifragment()); + } + }); + } + /** + * viewPager里添加fragment + */ + private void initFragment() { + QMUIFragmentPagerAdapter adapter=new QMUIFragmentPagerAdapter(getChildFragmentManager()) { + @Override + public int getCount() { + return 2; + } + @Override + public QMUIFragment createFragment(int position) { + switch (position) { + case 0: + return new PlcControl_pz_fragment(); + case 1: + default: + return new PlcControl_kz_fragment(); + } + } + @Override + public CharSequence getPageTitle(int position) { + switch (position) { + case 0: + return "PLC#地址"; + case 1: + default: + return "控制#监控"; + } + } + }; + viewpager_wl.setAdapter(adapter); + tabs.setupWithViewPager(viewpager_wl,true); + } + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java new file mode 100644 index 00000000..7036b9b9 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java @@ -0,0 +1,78 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.modules.home.fragment.GuanLifragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_sxgl_fragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_wl_fragment; +import com.qmuiteam.qmui.arch.QMUIFragment; +import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; +import com.qmuiteam.qmui.widget.QMUIViewPager; +import com.qmuiteam.qmui.widget.tab.QMUITabSegment; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class RealTimeActivity extends BaseFragment { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + @BindView(R.id.tabs) + QMUITabSegment tabs; + @BindView(R.id.viewpager_wl) + QMUIViewPager viewpager_wl; + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_realtime, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + } + + private void initTopBar() { + mTopBar.setTitle("实时监控管理"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(4,new GuanLifragment()); + } + }); + } + /** + * viewPager里添加fragment + */ + private void initFragment() { + + } + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java new file mode 100644 index 00000000..09d11183 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SalesStatisticsActivity.java @@ -0,0 +1,69 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.modules.home.fragment.DingDanfragment; +import com.bonait.bnframework.modules.home.fragment.GuanLifragment; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class SalesStatisticsActivity extends BaseFragment { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_salesstatistics, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + } + + private void initTopBar() { + mTopBar.setTitle("销售统计"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(2,new DingDanfragment()); + } + }); + } + /** + * viewPager里添加fragment + */ + private void initFragment() { + + } + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java new file mode 100644 index 00000000..bf66482d --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SystemParameterActivity.java @@ -0,0 +1,247 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.Spinner; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_SYSTEMSET; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.GuanLifragment; +import com.bonait.bnframework.modules.home.fragment.SheZhifragment; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; +import com.qmuiteam.qmui.widget.QMUIViewPager; +import com.qmuiteam.qmui.widget.tab.QMUITabSegment; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class SystemParameterActivity extends BaseFragment { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + private Context context; + + @BindView(R.id.edittext1) + EditText edittext1; + @BindView(R.id.edittext2) + EditText edittext2; + @BindView(R.id.edittext3) + EditText edittext3; + @BindView(R.id.edittext4) + EditText edittext4; + @BindView(R.id.environment) + Spinner environment; + + @BindView(R.id.versionselection) + Spinner versionselection; + + @BindView(R.id.HuoLi) + Spinner HuoLi; + + + ArrayList editTextLists = new ArrayList<>(); + Map material_map = new LinkedHashMap<>(); + Map material_map_vis = new LinkedHashMap<>(); + + /** + * 系统设置参数 + */ + ArrayList bpa_systemsets = new ArrayList<>(); + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.activity_systemparameter, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + context = getContext(); + initTopBar(); + initFragment(); + initData(); + initSelect(); + } + + private void initTopBar() { + mTopBar.setTitle("系统参数"); + mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + ConfigName.getInstance().fragmentAdapter.replaceFragment(5,new SheZhifragment()); + } + }); + } + /** + * viewPager里添加fragment + */ + private void initFragment() { + + } + + private void initData() { + editTextLists.add(edittext1); + editTextLists.add(edittext2); + editTextLists.add(edittext3); + editTextLists.add(edittext4); + + material_map.put("开发环境", 0); + material_map.put("测试环境", 1); + material_map.put("正式环境", 2); + + for (int i = 0; i < ConfigName.getInstance().versionSelectionValues.length; i++) { + material_map_vis.put(ConfigName.getInstance().versionSelectionValues[i], i); + } + + + ArrayAdapter adapter = new ArrayAdapter<>(context, R.layout.spinner_text_item, new ArrayList<>(material_map.keySet())); + adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + environment.setAdapter(adapter); + + ArrayAdapter adapter1 = new ArrayAdapter<>(context, R.layout.spinner_text_item, new ArrayList<>(material_map_vis.keySet())); + adapter1.setDropDownViewResource(R.layout.spinner_dropdown_item); + versionselection.setAdapter(adapter1); + + + ArrayAdapter adapter2 = new ArrayAdapter<>(context, R.layout.spinner_text_item, new ArrayList<>(ConfigName.getInstance().HeatingGearL.keySet())); + adapter2.setDropDownViewResource(R.layout.spinner_dropdown_item); + HuoLi.setAdapter(adapter2); + HuoLi.setSelection(ConfigName.getInstance().HeatingGearL.get(ConfigName.getInstance().HuoLi)); + + bpa_systemsets = QueryDB.GetSystemsetALL(); + for (BPA_SYSTEMSET item : bpa_systemsets) { + switch (item.type) { + case -100: + ConfigName.getInstance().versionSelectionEnum = item.value; + versionselection.setSelection(material_map_vis.get(item.value)); + break; + case -99: + ConfigName.getInstance().Environment = item.value; + environment.setSelection(material_map.get(item.value)); + break; + case 1: + ConfigName.getInstance().Address = item.value; + edittext1.setText(item.value); + break; + case 2: + ConfigName.getInstance().Post = Integer.parseInt(item.value); + edittext2.setText(item.value); + break; + case 3: + ConfigName.getInstance().ClientAutoKey = item.value; + edittext3.setText(item.value); + break; + case 4: + ConfigName.getInstance().DeviceAutoKey = item.value; + edittext4.setText(item.value); + break; + + } + } + } + + /** + * 初始化选中 + */ + public void initSelect() { + HuoLi.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { + @Override + /*public void onItemSelected(AdapterView parent, View view, int position, long id) { + + }*/ + public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { + ConfigName.getInstance().HuoLi=HuoLi.getSelectedItem().toString(); + ConfigData.getInstance().SavePZ(); + } + + @Override + public void onNothingSelected(AdapterView parent) { + + } + }); + + } + + @OnClick({R.id.StartButton}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.StartButton://保存按钮 + ConfigName.getInstance().Address = edittext1.getText().toString(); + ConfigName.getInstance().Post = Integer.parseInt(edittext2.getText().toString()); + ConfigName.getInstance().ClientAutoKey = edittext3.getText().toString(); + ConfigName.getInstance().DeviceAutoKey = edittext4.getText().toString(); + + ConfigName.getInstance().Environment = environment.getSelectedItem().toString(); + + boolean isgb = false; + if (!ConfigName.getInstance().versionSelectionEnum.equals(versionselection.getSelectedItem().toString())) { + ConfigName.getInstance().versionSelectionEnum = versionselection.getSelectedItem().toString(); + isgb = true; + } + + for (BPA_SYSTEMSET item : bpa_systemsets) { + QueryDB.DeleteSystemset(item.id); + } + + for (int i = 0; i < editTextLists.size(); i++) { + BPA_SYSTEMSET set = new BPA_SYSTEMSET(); + set.type = i + 1; + set.value = editTextLists.get(i).getText().toString(); + set.deviceID = ConfigName.getInstance().DeviceId; + set.userID = ConfigName.getInstance().user.userID; + QueryDB.AddSystemset(set); + } + BPA_SYSTEMSET set = new BPA_SYSTEMSET(); + set.type = -99; + set.value = environment.getSelectedItem().toString(); + set.deviceID = ConfigName.getInstance().DeviceId; + set.userID = ConfigName.getInstance().user.userID; + QueryDB.AddSystemset(set); + + BPA_SYSTEMSET set_vis = new BPA_SYSTEMSET(); + set_vis.type = -100; + set_vis.value = versionselection.getSelectedItem().toString(); + set_vis.deviceID = ConfigName.getInstance().DeviceId; + set_vis.userID = ConfigName.getInstance().user.userID; + QueryDB.AddSystemset(set_vis); + if (isgb) { + ConfigData.getInstance().RevertPLCProcess(); + } + ToastUtils.info("保存成功"); + break; + + } + } + //-------------------------配置viewPager与fragment关联----------------------------// + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_kz_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_kz_fragment.java new file mode 100644 index 00000000..367ff196 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_kz_fragment.java @@ -0,0 +1,116 @@ +package com.bonait.bnframework.modules.home.fragment.from.fragment; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.app.Activity; +import android.content.Context; +import android.content.ContextWrapper; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; +import com.bonait.bnframework.modules.home.fragment.mode.fragment_plc_control; +import com.orhanobut.logger.Logger; +import com.qmuiteam.qmui.widget.QMUILoadingView; + +import java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class PlcControl_kz_fragment extends BaseFragment { + + @BindView(R.id.plcview) + LinearLayout plcview;//工序子集 + + @BindView(R.id.load_view) + QMUILoadingView load_view;//工序子集 + + private Context context; + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_plccontrol_kz, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + Logger.d("我的fragment创建"); + context = getContext(); + Init(); + } + + /** + * 初始化 + */ + public void Init() { + load_view.setVisibility(View.VISIBLE); + plcview.removeAllViews(); + ArrayList arrayList = QueryDB.GetPlcaddressALL(); + new Thread(new Runnable() { + @Override + public void run() { + try { + Activity activity = findActivity(context); + if (activity != null) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + for (BPA_PLCADDRESS item : arrayList) { + fragment_plc_control gongxu = new fragment_plc_control(context, null, item); + plcview.addView(gongxu); + } + } catch (Exception e) { + }finally { + load_view.setVisibility(View.INVISIBLE); + } + } + }); + } + } catch (Exception e) { + + } + } + }).start(); + + } + + private Activity findActivity(@NonNull Context context) { + if (context instanceof Activity) { + return (Activity) context; + } else if (context instanceof ContextWrapper) { + return findActivity(((ContextWrapper) context).getBaseContext()); + } else { + return null; + } + } + @Override + public void onDestroy() { + super.onDestroy(); + Logger.d("我的fragment销毁"); + } + + /** + * 当在activity设置viewPager + BottomNavigation + fragment时, + * 为防止viewPager左滑动切换界面,与fragment左滑返回上一界面冲突引起闪退问题, + * 必须加上此方法,禁止fragment左滑返回上一界面。 + * + * 切记!切记!切记!否则会闪退! + * + * 当在fragment设置viewPager + BottomNavigation + fragment时,则不会出现这个问题。 + */ + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_pz_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_pz_fragment.java new file mode 100644 index 00000000..1dcb78c0 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/PlcControl_pz_fragment.java @@ -0,0 +1,142 @@ +package com.bonait.bnframework.modules.home.fragment.from.fragment; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.app.Activity; +import android.content.Context; +import android.content.ContextWrapper; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; +import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.mode.fragment_plc; +import com.orhanobut.logger.Logger; +import com.qmuiteam.qmui.widget.QMUILoadingView; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; + +import java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class PlcControl_pz_fragment extends BaseFragment { + + @BindView(R.id.plcview) + LinearLayout plcview;//工序子集 + @BindView(R.id.load_view) + QMUILoadingView load_view;//工序子集 + private Context context; + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_plccontrol_pz, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + Logger.d("我的fragment创建"); + context = getContext(); + Init(); + } + + + /** + * 初始化 + */ + public void Init() { + load_view.setVisibility(View.VISIBLE); + new Thread(new Runnable() { + @Override + public void run() { + try { + Activity activity = findActivity(context); + if (activity != null) { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + ArrayList arrayList = QueryDB.GetPlcaddressALL(); + for (BPA_PLCADDRESS item : arrayList) { + fragment_plc gongxu = new fragment_plc(context, null, item); + plcview.addView(gongxu); + } + } catch (Exception e) { + }finally { + load_view.setVisibility(View.INVISIBLE); + } + } + }); + } + } catch (Exception e) { + + } + } + }).start(); + + } + + private Activity findActivity(@NonNull Context context) { + if (context instanceof Activity) { + return (Activity) context; + } else if (context instanceof ContextWrapper) { + return findActivity(((ContextWrapper) context).getBaseContext()); + } else { + return null; + } + } + + @OnClick({R.id.chushihua}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.chushihua: + String title = "温馨提示!"; + String message = "客官确定要初始化PLC地址吗,小菠萝温馨提示你,此操作将会影响到实际运行哦?"; + AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + load_view.setVisibility(View.VISIBLE); + ConfigData.getInstance().RevertPLCProcess(); + Init(); + ToastUtils.info("初始化成功!"); + dialog.dismiss(); + } + }); + break; + + } + } + + @Override + public void onDestroy() { + super.onDestroy(); + Logger.d("我的fragment销毁"); + } + + /** + * 当在activity设置viewPager + BottomNavigation + fragment时, + * 为防止viewPager左滑动切换界面,与fragment左滑返回上一界面冲突引起闪退问题, + * 必须加上此方法,禁止fragment左滑返回上一界面。 + *

+ * 切记!切记!切记!否则会闪退! + *

+ * 当在fragment设置viewPager + BottomNavigation + fragment时,则不会出现这个问题。 + */ + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_deviceinformation.xml b/app/src/main/res/layout/activity_deviceinformation.xml new file mode 100644 index 00000000..338e72ac --- /dev/null +++ b/app/src/main/res/layout/activity_deviceinformation.xml @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_goodpeifang.xml b/app/src/main/res/layout/activity_goodpeifang.xml index 2f1894f3..cc83a906 100644 --- a/app/src/main/res/layout/activity_goodpeifang.xml +++ b/app/src/main/res/layout/activity_goodpeifang.xml @@ -104,7 +104,8 @@ + android:layout_height="match_parent" + android:visibility="gone"/> diff --git a/app/src/main/res/layout/activity_imagesource.xml b/app/src/main/res/layout/activity_imagesource.xml new file mode 100644 index 00000000..a738e315 --- /dev/null +++ b/app/src/main/res/layout/activity_imagesource.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +