左晓为主开发手持机充值管理机
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
package com.dayu.qiheonlinelibrary.tools;
 
import android.app.Activity;
import android.content.Intent;
import android.nfc.tech.MifareClassic;
 
import com.dayu.baselibrary.tools.nfc.NfcWriteAdapter;
import com.dayu.qiheonlinelibrary.card.UserCard;
 
/**
 * @author zx
 * @date 2018/4/25 8:08
 * email 1058083107@qq.com
 * description
 */
public class NFCWriteHelper extends QHBaseNFCHelper {
 
 
    private static NFCWriteHelper helper;
    private NfcWriteAdapter adapter;
 
 
    public NFCWriteHelper(Intent intent, Activity activity) {
        super(activity);
        adapter = new NfcWriteAdapter(intent, activity);
    }
 
    /**
     * 单例初始化
     *
     * @param intent
     * @return
     */
    public static NFCWriteHelper getInstence(Intent intent, Activity activity) {
        if (helper == null) {
            helper = new NFCWriteHelper(intent, activity);
        }
        helper.adapter.setIntent(intent);
        return helper;
    }
 
 
    /**
     * 写卡
     *
     * @param userCard 用户卡内容
     * @param
     */
    public boolean writeUserData(UserCard userCard) {
        try {
            return adapter.writeUserData(userCard,1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
 
 
    /**
     * 写卡
     *
     * @param str 书写内容,16个字节
     * @param a   书写的扇区 (从0开始数)
     * @param b   书写的块(从0开始数)
     * @param
     */
    public boolean writeData(byte[] str, int a, int b) {
        try {
            return adapter.writeData(str, a, b);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
 
 
    /**
     * 修改密码
     *
     * @param a 书写的扇区
     *          //     * @param callback 返回监听
     */
    public boolean changePasword(int a, MifareClassic mfc) {
        try {
            return adapter.changePasword(a, mfc);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
 
    /**
     * 初始化卡
     *
     * @return
     */
    public boolean initCard() {
        try {
            return adapter.initCard();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
 
 
}