Blame view

C5/app/src/main/java/com/sunvote/xpadapp/MainActivity.java 3.32 KB
fac86401   孙向锦   初始化C5 Vote
1
2
  package com.sunvote.xpadapp;
  
fac86401   孙向锦   初始化C5 Vote
3
4
5
  import android.app.Fragment;
  import android.app.FragmentManager;
  import android.app.FragmentTransaction;
fac86401   孙向锦   初始化C5 Vote
6
  import android.content.Intent;
fac86401   孙向锦   初始化C5 Vote
7
  import android.os.Bundle;
fac86401   孙向锦   初始化C5 Vote
8
  import android.os.Handler;
fac86401   孙向锦   初始化C5 Vote
9
  import android.widget.TextView;
fac86401   孙向锦   初始化C5 Vote
10
  
94237477   孙向锦   修改整个sdk
11
12
13
14
15
16
17
18
  import com.sunvote.xpadapi.service.XpadApiService;
  import com.sunvote.xpadapi.service.logic.XpadApiServiceInfoProxyManager;
  import com.sunvote.xpadapi.service.bean.BaseInfo;
  import com.sunvote.xpadapi.service.bean.BaseVoteInfo;
  import com.sunvote.xpadapi.service.bean.OnLineInfo;
  import com.sunvote.xpadapi.service.listener.BaseInfoChanageListener;
  import com.sunvote.xpadapi.service.listener.BaseVoteInfoChanageListener;
  import com.sunvote.xpadapi.service.listener.OnlineInfoChanageListener;
fac86401   孙向锦   初始化C5 Vote
19
  import com.sunvote.xpadapp.base.BaseActivity;
fac86401   孙向锦   初始化C5 Vote
20
  
94237477   孙向锦   修改整个sdk
21
  public class MainActivity extends BaseActivity {
fac86401   孙向锦   初始化C5 Vote
22
  
94237477   孙向锦   修改整个sdk
23
      private Handler handler;
fac86401   孙向锦   初始化C5 Vote
24
      private TextView terminalId;
94237477   孙向锦   修改整个sdk
25
      private Fragment fragment;
fac86401   孙向锦   初始化C5 Vote
26
27
28
29
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
94237477   孙向锦   修改整个sdk
30
31
          Intent intent = new Intent(this, XpadApiService.class);
          startService(intent);
fac86401   孙向锦   初始化C5 Vote
32
33
          setContentView(R.layout.activity_main);
          terminalId = findViewById(R.id.terminal_id);
94237477   孙向锦   修改整个sdk
34
35
36
37
          handler = new Handler();
          XpadApiServiceInfoProxyManager.getInstance().setOnlineInfoChanageListener(onlineInfoChanageListener);
          XpadApiServiceInfoProxyManager.getInstance().setBaseInfoListener(onBaseInfoListener);
          XpadApiServiceInfoProxyManager.getInstance().setBaseVoteInfoListener(baseVoteInfoChanageListener);
3e1796db   孙向锦   管理员界面修改
38
39
      }
  
94237477   孙向锦   修改整个sdk
40
      private BaseVoteInfoChanageListener baseVoteInfoChanageListener = new BaseVoteInfoChanageListener() {
fac86401   孙向锦   初始化C5 Vote
41
          @Override
94237477   孙向锦   修改整个sdk
42
          public void onBaseVoteInfoListener(BaseVoteInfo newBaseVoteInfo) {
fac86401   孙向锦   初始化C5 Vote
43
  
fac86401   孙向锦   初始化C5 Vote
44
45
46
          }
      };
  
94237477   孙向锦   修改整个sdk
47
      private BaseInfoChanageListener onBaseInfoListener = new BaseInfoChanageListener() {
fac86401   孙向锦   初始化C5 Vote
48
  
fac86401   孙向锦   初始化C5 Vote
49
          @Override
94237477   孙向锦   修改整个sdk
50
          public void onBaseInfoChange(BaseInfo newBaseInfo) {
fac86401   孙向锦   初始化C5 Vote
51
  
fac86401   孙向锦   初始化C5 Vote
52
53
54
          }
      };
  
94237477   孙向锦   修改整个sdk
55
      private OnlineInfoChanageListener onlineInfoChanageListener = new OnlineInfoChanageListener() {
fac86401   孙向锦   初始化C5 Vote
56
  
fac86401   孙向锦   初始化C5 Vote
57
          @Override
94237477   孙向锦   修改整个sdk
58
59
          public void onOnlineInfoChanage(OnLineInfo newOnlineInfo) {
              showEvent();
fac86401   孙向锦   初始化C5 Vote
60
61
62
          }
      };
  
94237477   孙向锦   修改整个sdk
63
64
65
66
67
68
69
70
71
      private void showEvent(){
          if (XpadApiServiceInfoProxyManager.getInstance().getOnLineInfo().getOnLine() == 2) {
              // 离线界面
          } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseVoteInfo().getMode() > 0) {
              // 显示对应的投票界面
          } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseInfo() != null) {// 修改
              // 自由浏览
          } else if (XpadApiServiceInfoProxyManager.getInstance().getBaseInfo() != null) {//修改
              // 欢迎界面
fac86401   孙向锦   初始化C5 Vote
72
          } else {
94237477   孙向锦   修改整个sdk
73
              // 在线界面
fac86401   孙向锦   初始化C5 Vote
74
          }
fac86401   孙向锦   初始化C5 Vote
75
76
      }
  
94237477   孙向锦   修改整个sdk
77
78
79
      private void showFragment(Fragment frag){
          if(!(frag != null && fragment != null && frag.getClass().getSimpleName().equals(fragment.getClass().getSimpleName()))){
              fragment = frag;
fac86401   孙向锦   初始化C5 Vote
80
              FragmentManager fm = getFragmentManager();
94237477   孙向锦   修改整个sdk
81
82
83
84
              FragmentTransaction transaction = fm.beginTransaction();
              transaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
              transaction.replace(R.id.frame_content, fragment);
              transaction.commitAllowingStateLoss();
fac86401   孙向锦   初始化C5 Vote
85
          }
fac86401   孙向锦   初始化C5 Vote
86
87
      }
  }