Blame view

C5/testproject/src/main/java/com/sunvote/udptest/ModifyMachCode.java 1.63 KB
fac86401   孙向锦   初始化C5 Vote
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
  package com.sunvote.udptest;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  import com.sunvote.sunvotesdk.BaseStationManager;
  
  public class ModifyMachCode extends AppCompatActivity {
  
      private Button modify;
      private EditText content;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.content_modify_mach_code);
  
          BaseStationManager.getInstance().connectSer();
          content = (EditText) findViewById(R.id.content);
          modify = (Button)findViewById(R.id.modify);
          modify.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  String machcode = content.getText().toString();
                  if(machcode != null && machcode.length() == 8){
                      if(BaseStationManager.getInstance().getBaseStationInfo().isConnected()) {
                          BaseStationManager.getInstance().writeMatchCode(machcode);
                          Toast.makeText(ModifyMachCode.this,"修改成功",Toast.LENGTH_LONG).show();
                      }else{
                          Toast.makeText(ModifyMachCode.this,"修改失败",Toast.LENGTH_LONG).show();
                          BaseStationManager.getInstance().connectSer();
                      }
  
                  }else{
                      Toast.makeText(ModifyMachCode.this,"配对码输入不正确",Toast.LENGTH_LONG).show();
                  }
              }
          });
      }
  
  }