Blame view

Twear/Setting/VIew/ContactCell.swift 3.58 KB
75d24c15   yangbin   123
1
2
3
4
5
6
7
8
9
10
11
  //
  //  ContactCell.swift
  //  Twear
  //
  //  Created by yangbin on 2022/1/15.
  //
  
  import UIKit
  
  class ContactCell: UITableViewCell {
  
582f536d   yangbin   common:2022.1.28
12
      @IBOutlet weak var familyNameLabel: UILabel!
75d24c15   yangbin   123
13
14
      @IBOutlet weak var nameLabel: UILabel!
      @IBOutlet weak var numberLabel: UILabel!
582f536d   yangbin   common:2022.1.28
15
16
17
      @IBOutlet weak var selectedImageView: UIImageView!
      @IBOutlet weak var sosButton: UIButton!
      var sosClosure: (() -> ())?
75d24c15   yangbin   123
18
      
582f536d   yangbin   common:2022.1.28
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
      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)
              }
          }
      }
75d24c15   yangbin   123
38
39
40
41
42
43
      
      override func awakeFromNib() {
          super.awakeFromNib()
          // Initialization code
      }
  
582f536d   yangbin   common:2022.1.28
44
45
46
47
48
49
50
      @IBAction func clickSOS(_ sender: Any) {
          sosClosure?()
      }
  
      
      
      
75d24c15   yangbin   123
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
      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