左晓为主开发手持机充值管理机
zuojincheng
2025-03-26 1bc1acff2127d61b359800096ad5b904370d9176
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package com.dayu.henanlibrary.tools;
 
import android.app.Activity;
import android.content.Intent;
 
import com.dayu.baselibrary.tools.nfc.BaseNfcReadHelper;
import com.dayu.baselibrary.tools.nfc.NfcReadAdapter;
import com.dayu.henanlibrary.card.UserCardHN;
 
/**
 * @author zx
 * @date 2018/4/23 14:31
 * email 1058083107@qq.com
 * description nfc读取工具类
 */
public class NfcReadHelper extends HNBaseHelper {
 
    //    private NFCCallback callback;
    private static NfcReadHelper helper;
    private NfcReadAdapter adapter;
 
 
    public NfcReadHelper(Intent intent, Activity activity) {
        super(activity);
        adapter=new NfcReadAdapter(intent,activity);
    }
 
 
    /**
     * 单例初始化
     *
     * @param intent
     * @return
     */
    public static NfcReadHelper getInstence(Intent intent, Activity activity) {
        if (helper == null) {
            helper = new NfcReadHelper(intent, activity);
        }
        helper.adapter.setIntent(intent);
        return helper;
    }
 
    /**
     * 获取用户卡信息
     *
     * @return
     */
    public UserCardHN getUserCardData() {
        try {
            return (UserCardHN) adapter.getUserCardData(new UserCardHN());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    public String getCradType() {
        try {
            return adapter.getCradType();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
 
    /**
     * 读取NFC卡的全部信息
     *
     * @param callback
     */
    public void getAllData(final BaseNfcReadHelper.NFCCallMapback callback) {
        try {
            adapter.getAllData(callback);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    /**
     * 获取1扇区信息
     *
     * @param callback
     */
    public void getOneSectorData(BaseNfcReadHelper.NFCCallListback callback) {
        try {
            adapter.getOneSectorData(callback);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
 
    /**
     * 读取NFC卡的特定扇区信息
     *
     * @param a        扇区
     * @param b        块
     * @param callback
     */
    public void getData(final int a, final int b, final BaseNfcReadHelper.NFCCallByteback callback) {
        try {
            adapter.getData(a, b, callback);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
 
 
}