From 99b11059aedf616df4ed3b74300fa59417568bc3 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期二, 08 四月 2025 16:37:38 +0800
Subject: [PATCH] feat: 添加单选按钮文本颜色资源文件

---
 henanlibrary/src/main/java/com/dayu/henanlibrary/activity/NFCWreatActivity.java |  204 +++++++++++++++++++++++++++++---------------------
 1 files changed, 117 insertions(+), 87 deletions(-)

diff --git a/henanlibrary/src/main/java/com/dayu/henanlibrary/activity/NFCWreatActivity.java b/henanlibrary/src/main/java/com/dayu/henanlibrary/activity/NFCWreatActivity.java
index b409ef6..13418a8 100644
--- a/henanlibrary/src/main/java/com/dayu/henanlibrary/activity/NFCWreatActivity.java
+++ b/henanlibrary/src/main/java/com/dayu/henanlibrary/activity/NFCWreatActivity.java
@@ -11,22 +11,24 @@
 import android.widget.Toast;
 
 import com.dayu.baselibrary.tools.BcdUtil;
-import com.dayu.baselibrary.utils.AidlUtil;
+import com.dayu.baselibrary.tools.print.PrintAdater;
+import com.dayu.baselibrary.tools.print.ShangMiAidlUtil;
+import com.dayu.baselibrary.utils.BaseCommon;
 import com.dayu.baselibrary.utils.CRC8;
 import com.dayu.baselibrary.utils.DateUtil;
 import com.dayu.baselibrary.utils.MornyUtil;
 import com.dayu.baselibrary.utils.TipUtil;
 import com.dayu.baselibrary.view.ConfirmDialog;
 import com.dayu.baselibrary.view.TitleBar;
-import com.dayu.henanlibrary.card.CleanCard;
-import com.dayu.henanlibrary.card.CleanUserCard;
-import com.dayu.henanlibrary.card.ConfigurationPowerCard;
+import com.dayu.henanlibrary.card.CleanCardHN;
+import com.dayu.henanlibrary.card.CleanUserCardHN;
+import com.dayu.henanlibrary.card.ConfigurationPowerCardHN;
 import com.dayu.henanlibrary.card.ConfigureDeviceRegistrationCrad;
 import com.dayu.henanlibrary.card.DomainCard;
-import com.dayu.henanlibrary.card.ManageCard;
-import com.dayu.henanlibrary.card.RegisteredCard;
-import com.dayu.henanlibrary.card.TestCard;
-import com.dayu.henanlibrary.card.UserCard;
+import com.dayu.henanlibrary.card.ManageCardHN;
+import com.dayu.henanlibrary.card.RegisteredCardHN;
+import com.dayu.henanlibrary.card.TestCardHN;
+import com.dayu.henanlibrary.card.UserCardHN;
 import com.dayu.henanlibrary.databinding.ActivityWriteTextHnBinding;
 import com.dayu.henanlibrary.dbBean.AdminDataBean;
 import com.dayu.henanlibrary.dbBean.ElectricPriceBean;
@@ -46,8 +48,10 @@
 import com.dayu.henanlibrary.view.ProgressDialog;
 import com.tencent.bugly.crashreport.CrashReport;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
+import java.util.List;
 
 /**
  * Copyright (C), 2023,
@@ -55,7 +59,7 @@
  * Date: 2023-11-08 21:19
  * Description: nfc鍐欏崱鐣岄潰
  */
-public class NFCWreatActivity extends BaseNfcActivity {
+public class NFCWreatActivity extends HNBaseNfcActivity {
     public static String TAG = "NFCWreatActivity";
 
     boolean cleanFlag = false;
@@ -87,16 +91,16 @@
     Intent intent;
 
 
-    RegisteredCard registeredCard;
-    CleanUserCard cleanUserCard;
-    ManageCard manageCard;
+    RegisteredCardHN registeredCard;
+    CleanUserCardHN cleanUserCard;
+    ManageCardHN manageCard;
     DomainCard domainCard;
 
-    CleanCard cleanCard;
+    CleanCardHN cleanCard;
     ConfigureDeviceRegistrationCrad configureDeviceRegistrationCrad;
-    TestCard testCard;
+    TestCardHN testCard;
 
-    ConfigurationPowerCard configurationPowerCard;
+    ConfigurationPowerCardHN configurationPowerCard;
     //鎵撳嵃
 
     public static NFCWreatActivity nfcWreatActivity;
@@ -113,6 +117,30 @@
     ConfirmDialog confirmDialog;
 
     @Override
+    public void onNfcBack(Intent intent) {
+        try {
+            this.intent = intent;
+            startAnim();
+            Log.i("NFCWreatActivity", "isUser:" + isUser);
+            if (isUser) {
+                checkHasUser();
+            } else if (isRecharge) {
+                if (rechargeIsOk) {
+                    rechargeWrratCard();
+                } else {
+                    Toast.makeText(this, "姝e湪閫氫俊璇风◢鍚�", Toast.LENGTH_SHORT).show();
+                }
+
+            } else {
+                saveData();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            CrashReport.postCatchedException(e);
+        }
+    }
+
+    @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         try {
@@ -120,6 +148,7 @@
             setContentView(binding.getRoot());
             nfcWreatActivity = this;
             setData();
+            titleBack();
             getData();
         } catch (Exception e) {
             e.printStackTrace();
@@ -180,18 +209,18 @@
     private void getData() {
         try {
             if (this.getIntent().hasExtra("userCard")) {
-                userCard = (UserCard) this.getIntent().getSerializableExtra("userCard");
+                userCard = (UserCardHN) this.getIntent().getSerializableExtra("userCard");
             }
             if (this.getIntent().hasExtra("cleanCard")) {
-                cleanCard = (CleanCard) this.getIntent().getSerializableExtra("cleanCard");
+                cleanCard = (CleanCardHN) this.getIntent().getSerializableExtra("cleanCard");
                 binding.cardData.setText("鍒朵綔娓呴浂鍗�");
             }
             if (this.getIntent().hasExtra("manageCard")) {
-                manageCard = (ManageCard) this.getIntent().getSerializableExtra("manageCard");
+                manageCard = (ManageCardHN) this.getIntent().getSerializableExtra("manageCard");
                 binding.cardData.setText("鍒朵綔绠$悊鍗�");
             }
             if (this.getIntent().hasExtra("registeredCard")) {
-                registeredCard = (RegisteredCard) this.getIntent().getSerializableExtra("registeredCard");
+                registeredCard = (RegisteredCardHN) this.getIntent().getSerializableExtra("registeredCard");
                 binding.cardData.setText("鍒朵綔閲嶆柊娉ㄥ唽璁惧鍗�");
             }
             if (this.getIntent().hasExtra("dbUserCard")) {
@@ -199,15 +228,19 @@
                 isUser = true;
             }
             if (this.getIntent().hasExtra("cleanUserCard")) {
-                cleanUserCard = (CleanUserCard) this.getIntent().getSerializableExtra("cleanUserCard");
+                cleanUserCard = (CleanUserCardHN) this.getIntent().getSerializableExtra("cleanUserCard");
                 binding.cardData.setText("鍒朵綔鍒犻櫎鍏ㄩ儴鐢ㄦ埛鍗�");
             }
-            if (this.getIntent().hasExtra("domainCard")) {
-                domainCard = (DomainCard) this.getIntent().getSerializableExtra("domainCard");
-                binding.cardData.setText("鍒朵綔璁剧疆鍩熷悕鍗�");
+            if (this.getIntent().hasExtra("domainCard_xinxiang")) {
+                domainCard = (DomainCard) this.getIntent().getSerializableExtra("domainCard_xinxiang");
+                binding.cardData.setText("鍒朵綔璁剧疆鏂颁埂鍩熷悕鍗�");
+            }
+            if (this.getIntent().hasExtra("domainCard_luyi")) {
+                domainCard = (DomainCard) this.getIntent().getSerializableExtra("domainCard_luyi");
+                binding.cardData.setText("鍒朵綔璁剧疆楣块倯鍩熷悕鍗�");
             }
             if (this.getIntent().hasExtra("testCard")) {
-                testCard = (TestCard) this.getIntent().getSerializableExtra("testCard");
+                testCard = (TestCardHN) this.getIntent().getSerializableExtra("testCard");
                 binding.cardData.setText("鍒朵綔娴嬭瘯鍗�");
             }
             if (this.getIntent().hasExtra("configureDeviceRegistrationCrad")) {
@@ -215,7 +248,7 @@
                 binding.cardData.setText("鍒朵綔閰嶇疆璁惧娉ㄥ唽淇℃伅鍗�");
             }
             if (this.getIntent().hasExtra("configurationPowerCard")) {
-                configurationPowerCard = (ConfigurationPowerCard) this.getIntent().getSerializableExtra("configurationPowerCard");
+                configurationPowerCard = (ConfigurationPowerCardHN) this.getIntent().getSerializableExtra("configurationPowerCard");
                 binding.cardData.setText("鍒朵綔閰嶇疆姘存车鍔熺巼鍗�");
             }
             if (this.getIntent().hasExtra("morny")) {
@@ -253,10 +286,10 @@
         ) {
             binding.textView.setText("璇ュ崱宸茬粡鍐欏叆鐢ㄦ埛淇℃伅锛岃鏇存崲鍗$墖");
             binding.textView.setTextColor(getResources().getColor(com.dayu.baselibrary.R.color.red));
-        } else if (cardType.equals("-1")) {
+        } else if (cardType.equals(BaseCommon.CARD_TYPE_ERROR1)) {
             TipUtil.show(NFCWreatActivity.this, "璇峰嬁绉诲姩鍗$墖锛岃鍗″け璐ヨ閲嶈瘯锛侊紒");
-        } else if (cardType.equals("-2")) {
-            TipUtil.show(NFCWreatActivity.this, "璇诲崱澶辫触,璇锋鏌ュ崱鏄惁鏄敤鎴峰崱");
+        } else if (cardType.equals(BaseCommon.CARD_TYPE_ERROR2)) {
+            TipUtil.show(NFCWreatActivity.this, "锛屽崱鐗囨湭鑳借瘑鍒紝璇锋鏌ュ崱鐗囨槸鍚︽槸鏈叕鍙稿崱鐗�");
         } else {
             Log.i("NFCWreatActivity", "olduserCard!=null  saveData");
             saveData();
@@ -333,31 +366,6 @@
         }
     }
 
-    @Override
-    public void onNewIntent(Intent intent) {
-        super.onNewIntent(intent);
-        try {
-            this.intent = intent;
-            startAnim();
-            Log.i("NFCWreatActivity", "isUser:" + isUser);
-            if (isUser) {
-                checkHasUser();
-            } else if (isRecharge) {
-                if (rechargeIsOk) {
-                    rechargeWrratCard();
-                } else {
-                    Toast.makeText(this, "姝e湪閫氫俊璇风◢鍚�", Toast.LENGTH_SHORT).show();
-                }
-
-            } else {
-                saveData();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            CrashReport.postCatchedException(e);
-        }
-    }
-
 
     /**
      * 鎵撳嵃鏈虹浉鍏充俊鎭�
@@ -366,24 +374,21 @@
      */
     private void setPrinterData(RechargeBean rechargeBean) {
         try {
-            StringBuffer data = new StringBuffer();
+            List<String> data = new ArrayList<>();
             if (rechargeBean != null) {
-                data.append("*****************************" + "\n");
-                data.append(getResources().getString(com.dayu.baselibrary.R.string.login_title)).append("\n");
-                data.append("璁惧搴忓垪鍙凤細").append(rechargeBean.getSerial()).append("\n");
-                data.append("鐢ㄦ埛鍚嶏細").append(rechargeBean.getUserName()).append("\n");
-                //            data.append("鎴�  鍙凤細" + rechargeBean.getUserNum() + "\n");
-                data.append("鍏呭�奸噾棰濓細").append(rechargeBean.getMorny()).append("鍏�").append("\n");
-                data.append("鍗″唴浣欓锛�").append(rechargeBean.getBalance()).append("鍏�").append("\n");
-                data.append("鏃�  鏈燂細").append(DateUtil.dateToStamp(rechargeBean.getDate(), DateUtil.type2)).append("\n\n");
-                data.append("*****************************");
+
+                data.add("*****************************");
+                data.add("璁惧搴忓垪鍙凤細" + rechargeBean.getSerial());
+                data.add("鐢ㄦ埛鍚嶏細" + rechargeBean.getUserName());
+                data.add("鍏呭�奸噾棰濓細" + rechargeBean.getMorny() + "鍏�");
+                data.add("鍗″唴浣欓锛�" + rechargeBean.getBalance() + "鍏�");
+                data.add("鏃�  鏈燂細" + DateUtil.dateToStamp(rechargeBean.getDate(), DateUtil.type2));
+                data.add("*****************************");
             }
-
             float size = 26;
-
             try {
-                AidlUtil.getInstance().printText(data.toString(), size, true, false);
-                AidlUtil.getInstance().print3Line();
+                PrintAdater.getInstance().printText(data, size, true, false);
+                ShangMiAidlUtil.getInstance().print3Line();
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -496,7 +501,7 @@
 
     //寰�鍗″唴鍐欏厖鍊煎悗鐨勬暟鎹�
     private void rechargeWrratCard() {
-        UserCard userCardold = NfcReadHelper.getInstence(intent, this).getUserCardData();
+        UserCardHN userCardold = NfcReadHelper.getInstence(intent, this).getUserCardData();
         if (userCardold != null) {
             //鍒ゆ柇鏄惁鍏呭�肩殑鏄竴涓崱
             if (userCard.getInitPeasantCode().equals(userCardold.getInitPeasantCode()) || isAgainWrite) {
@@ -517,8 +522,12 @@
         stopAnim();
     }
 
-    private void setmanageCard(Intent intent, final ManageCard manageCard) {
-        manageCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(manageCard.toZeroByte(baseDao), 1, 0);
+    private void setmanageCard(Intent intent, final ManageCardHN manageCard) {
+        try {
+            manageCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(manageCard.toZeroByte(baseDao), 1, 0);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     /**
@@ -527,8 +536,12 @@
      * @param intent
      * @param clearOrInitCard
      */
-    private void setClean(Intent intent, final CleanCard clearOrInitCard) {
-        cleanFlag = NFCWriteHelper.getInstence(intent, this).writeData(clearOrInitCard.toByte(baseDao), 1, 0);
+    private void setClean(Intent intent, final CleanCardHN clearOrInitCard) {
+        try {
+            cleanFlag = NFCWriteHelper.getInstence(intent, this).writeData(clearOrInitCard.toByte(baseDao), 1, 0);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
 
@@ -538,8 +551,12 @@
      * @param intent
      * @param registeredCard
      */
-    private void setRegisteredCard(Intent intent, RegisteredCard registeredCard) {
-        registeredFlag = NFCWriteHelper.getInstence(intent, this).writeData(registeredCard.toByte(baseDao), 1, 0);
+    private void setRegisteredCard(Intent intent, RegisteredCardHN registeredCard) {
+        try {
+            registeredFlag = NFCWriteHelper.getInstence(intent, this).writeData(registeredCard.toByte(baseDao), 1, 0);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     /**
@@ -548,34 +565,38 @@
      * @param intent
      * @param cleanUserCard
      */
-    private void setCleanUserCard(Intent intent, CleanUserCard cleanUserCard) {
-        cleanUserCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(cleanUserCard.toByte(baseDao), 1, 0);
+    private void setCleanUserCard(Intent intent, CleanUserCardHN cleanUserCard) {
+        try {
+            cleanUserCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(cleanUserCard.toByte(baseDao), 1, 0);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     /**
      * 璁剧疆鍩熷悕鍗�
      *
      * @param intent
-     * @param domainCard
+     * @param domainXinXiangCard
      */
-    private void setDomainCard(Intent intent, DomainCard domainCard) {
+    private void setDomainCard(Intent intent, DomainCard domainXinXiangCard) {
         try {
-            domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainCard.getZeroByte(), 1, 0);
+            domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainXinXiangCard.getZeroByte(), 1, 0);
             if (!domainCrdFlag) {
                 return;
             }
-            domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainCard.getOneByte(), 1, 1);
+            domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainXinXiangCard.getOneByte(), 1, 1);
             if (!domainCrdFlag) {
                 return;
             }
-            domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainCard.getTwoByte(), 1, 2);
+            domainCrdFlag = NFCWriteHelper.getInstence(intent, this).writeData(domainXinXiangCard.getTwoByte(), 1, 2);
         } catch (Exception e) {
             domainCrdFlag = false;
-            throw new RuntimeException(e);
+            e.printStackTrace();
         }
     }
 
-    private void setTestCard(Intent intent, TestCard testCard) {
+    private void setTestCard(Intent intent, TestCardHN testCard) {
         testCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(testCard.toByte(baseDao), 1, 0);
     }
 
@@ -584,12 +605,12 @@
         configDeviceRegiestFlag = NFCWriteHelper.getInstence(intent, this).writeData(configureDeviceRegistrationCrad.toByte(baseDao), 1, 0);
     }
 
-    private void setConfigurationPower(Intent intent, ConfigurationPowerCard configurationPowerCard) {
+    private void setConfigurationPower(Intent intent, ConfigurationPowerCardHN configurationPowerCard) {
         try {
             configPowerFlag = NFCWriteHelper.getInstence(intent, this).writeData(configurationPowerCard.toByte(baseDao), 1, 0);
         } catch (Exception e) {
             configPowerFlag = false;
-            throw new RuntimeException(e);
+            e.printStackTrace();
         }
     }
 
@@ -631,7 +652,7 @@
                             stateText = new StringBuffer();
                             String state = BcdUtil.bcdToStr(readData.getBodyBytes()[2]);  //BCD鐮�00鍚敤 01绂佺敤 02闅跺睘淇℃伅涓嶇 03鏃犳鍗′俊鎭� 04鍏跺畠s
                             if (userCard == null) {
-                                userCard = new UserCard();
+                                userCard = new UserCardHN();
                                 userCard.setRechargeTimes(0);
                                 ElectricPriceBean electricPriceBean = baseDao.electricPriceDao().findFirst();
                                 if (electricPriceBean != null) {
@@ -640,7 +661,7 @@
                                     //榛樿鏄�1鍏�
                                     userCard.setElectricityPrice(1.000f);
                                 }
-                                userCard.setSwipeNumber((short) 0);
+                                userCard.setSwipeNumber(0);
                                 userCard.setState("00");
                                 userCard.setBalance(0);
                                 userCard.setAddressCode(adminData.getAddressCode());
@@ -715,4 +736,13 @@
         ProgressDialog.dismiss();
         nfcWreatActivity = null;
     }
+
+    private void titleBack() {
+        titleBar.setOnItemclickListner(TitleBar.ClickType_LEFT_IMAGE, new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                back();
+            }
+        });
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0