Blame view

HDFwear/Setting/VIew/ContactCell.swift 3.57 KB
f2cf74c7   yangbin   1.0.20(4)
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
  //
  //  ContactCell.swift
  //  Twear
  //
  //  Created by yangbin on 2022/1/15.
  //
  
  import UIKit
  
  class ContactCell: UITableViewCell {
  
      @IBOutlet weak var familyNameLabel: UILabel!
      @IBOutlet weak var nameLabel: UILabel!
      @IBOutlet weak var numberLabel: UILabel!
      @IBOutlet weak var selectedImageView: UIImageView!
      @IBOutlet weak var sosButton: UIButton!
      var sosClosure: (() -> ())?
      
      var isPhone: Bool = false
      
      var contact: ContactModel = ContactModel() {
          didSet {
              familyNameLabel.text = contact.name.substring(toIndex: 1)
              nameLabel.text = contact.name
              numberLabel.text = "\(contact.number)"
              
              if isPhone {
                  selectedImageView.isHidden = !contact.isSelected
                  sosButton.isHidden = true
              } else {
                  selectedImageView.isHidden = true
                  sosButton.isHidden = false
                  sosButton.setImage(UIImage(named: contact.isSOS ? "sos_selected" : "sos_not_selected"), for: .normal)
              }
          }
      }
      
      override func awakeFromNib() {
          super.awakeFromNib()
          // Initialization code
      }
  
      @IBAction func clickSOS(_ sender: Any) {
          sosClosure?()
      }
  
      
      
      
      override func setSelected(_ selected: Bool, animated: Bool) {
          super.setSelected(selected, animated: animated)
  
          // Configure the view for the selected state
      }
      
  }
  //public static byte[] setContact(String[] name,String[] number,int[] sos){
  //
  //    int length=name.length;
  //    int startIndex;
  //    int nameLength,numberLength;
  //    Log.e("setContact","setContact name.length="+name.length);
  //    byte[] l2KeyValue;
  //    if(length!=0) {
  //       l2KeyValue = new byte[length * 54];
  //    }else{
  //        l2KeyValue=null;
  //    }
  //    for(int i=0;i<length;i++){
  //        byte[] byteName;
  //        byte[] sendByteName = new byte[20];
  //        byte[] byteNumber;
  //        byte[] sendByteNumber = new byte[30];
  //        startIndex=54*i;
  //        try {
  //            Log.e("setContact","setContact name="+name[i]+"number="+number[i]+"sos="+sos[i]);
  //            byteName = name[i].getBytes("UnicodeLittleUnmarked");//string转uicode编码 小端在前
  //            byteNumber=number[i].getBytes("UnicodeLittleUnmarked");//string转uicode编码 小端在前
  //            Log.e("setContact","byteName data= "+ BitUtil.parseByte2HexStr(byteName));
  //            Log.e("setContact","byteNumber data= "+ BitUtil.parseByte2HexStr(byteNumber));
  //            System.arraycopy(byteNumber, 0, sendByteNumber, 0, byteNumber.length);//从paramArray拷贝字节
  //            System.arraycopy(byteName, 0, sendByteName, 0, byteName.length);//从paramArray拷贝字节
  //            Log.e("setContact","sendByteName data= "+ BitUtil.parseByte2HexStr(sendByteName));
  //            Log.e("setContact","sendByteNumber data= "+ BitUtil.parseByte2HexStr(sendByteNumber));
  //            System.arraycopy(sendByteNumber, 0, l2KeyValue, startIndex, sendByteNumber.length);//从paramArray拷贝字节
  //            System.arraycopy(sendByteName, 0, l2KeyValue, startIndex+30, sendByteName.length);//从paramArray拷贝字节
  //
  //            nameLength=name[i].length();
  //            numberLength=number[i].length();
  //            l2KeyValue[startIndex+50]=(byte)numberLength;
  //            l2KeyValue[startIndex+51]=(byte)nameLength;
  //            l2KeyValue[startIndex+52]=(byte)(i+1);
  //            l2KeyValue[startIndex+53]=(byte)(sos[i]);
  //            Log.e("setContact","numberLength="+numberLength+"nameLength= "+ nameLength+"sos="+sos[i]);
  //
  //        } catch