@Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, getIntent().getType() + "" + getIntent());
    setContentView(R.layout.activity_mnemonic);
    final CircularProgressButton okButton =
        (CircularProgressButton) findViewById(R.id.mnemonicOkButton);
    okButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(final View view) {
            MnemonicActivity.this.login();
          }
        });

    final TextView scanIcon = (TextView) findViewById(R.id.mnemonicScanIcon);
    scanIcon.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(final View view) {
            final Intent scanner = new Intent(MnemonicActivity.this, ScanActivity.class);
            startActivityForResult(scanner, 0);
          }
        });

    final EditText edit = (EditText) findViewById(R.id.mnemonicText);

    edit.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(
              final TextView v, final int actionId, final KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
              login();
              return true;
            }
            return false;
          }
        });

    NFCIntentMnemonicLogin();
  }
Example #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    btnSignIn = (Button) findViewById(R.id.btn_sign_in);
    //        btnSignOut = (Button) findViewById(R.id.btn_sign_out);
    //        btnRevokeAccess = (Button) findViewById(R.id.btn_revoke_access);
    imgProfilePic = (ImageView) findViewById(R.id.imgProfilePic);
    g_icon = (ImageView) findViewById(R.id.google_icon);
    txtName = (TextView) findViewById(R.id.txtName);
    txtEmail = (TextView) findViewById(R.id.txtEmail);
    title = (TextView) findViewById(R.id.title_text);
    llProfileLayout = (LinearLayout) findViewById(R.id.llProfile);
    llWelcome = (LinearLayout) findViewById(R.id.llWelcomeIC);
    llField = (LinearLayout) findViewById(R.id.llField);
    etPhone = (EditText) findViewById(R.id.etPhone);
    etName = (EditText) findViewById(R.id.etName_login);
    //        buttonContainer = (LinearLayout) findViewById(R.id.button_container);
    btEnter = (CircularProgressButton) findViewById(R.id.btn_enter);
    btEnter.setIndeterminateProgressMode(true);

    // Button click listeners
    btnSignIn.setOnClickListener(this);

    GoogleSignInOptions gso =
        new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();

    mGoogleApiClient =
        new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
    // [END build_client]

  }
Example #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up);

    // 设定状态栏的颜色,当版本大于4.4时起作用
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      SystemBarTintManager tintManager = new SystemBarTintManager(this);
      tintManager.setStatusBarTintEnabled(true);
      // 此处可以重新指定状态栏颜色
      tintManager.setStatusBarTintResource(R.color.material_blue);
    }

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle("用户注册"); // 标题的文字需在setSupportActionBar之前,不然会无效
    mToolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    etUserName = (MaterialEditText) findViewById(R.id.etUserName);
    etPassword = (MaterialEditText) findViewById(R.id.etPassword);
    etEmail = (MaterialEditText) findViewById(R.id.etEmail);

    cpbtnSignUp = (CircularProgressButton) findViewById(R.id.cpbtnSignUp);
    cpbtnSignUp.setIndeterminateProgressMode(true);
    cpbtnSignUp.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            cpbtnSignUp.setProgress(0);
            cpbtnSignUp.setProgress(50); // 注册按钮开始显示进度

            user = new StudentUser();
            user.setUsername(etUserName.getText().toString());
            user.setPassword(etPassword.getText().toString());
            user.setEmail(etEmail.getText().toString());
            user.signUp(
                SignUpActivity.this,
                new SaveListener() {
                  @Override
                  public void onSuccess() {
                    cpbtnSignUp.setProgress(100);
                    // Toast.makeText(SignUpActivity.this, "注册成功!", Toast.LENGTH_SHORT).show();
                    final int activityFinishDelay = 2000;
                    new Handler()
                        .postDelayed(
                            new Runnable() {
                              @Override
                              public void run() {
                                SignUpActivity.this.finish();
                              }
                            },
                            activityFinishDelay);
                  }

                  @Override
                  public void onFailure(int i, String s) {

                    // Toast.makeText(SignUpActivity.this, "错误码:"+ i +"注册失败:" + s,
                    // Toast.LENGTH_SHORT).show();
                    switch (i) {
                      case 202:
                        cpbtnSignUp.setErrorText("注册失败,用户名已存在");
                        break;
                      case 203:
                        cpbtnSignUp.setErrorText("注册失败,邮箱已使用");
                        break;
                      case 305:
                        cpbtnSignUp.setErrorText("注册失败,用户名或密码为空");
                        break;
                      case 9016:
                        cpbtnSignUp.setErrorText("无网络连接,请检查您的手机网络");
                        break;
                      case 9010:
                        cpbtnSignUp.setErrorText("网络连接超时");
                        break;
                      default:
                        cpbtnSignUp.setErrorText("注册失败");
                        break;
                    }
                    cpbtnSignUp.setProgress(-1);
                  }
                });
          }
        });
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.zhenduanxinxi, container, false);

    init();
    shouShuRiQi = (EditText) rootView.findViewById(R.id.shoushuriqi);
    shouShuBianHao = (MaterialEditText) rootView.findViewById(R.id.shoushubianhao);
    shuZhe = (MaterialEditText) rootView.findViewById(R.id.shuzhe);
    shiSuLeiXing = (EditText) rootView.findViewById(R.id.shisuleixing);
    shiSuBingCheng = (EditText) rootView.findViewById(R.id.shisubingcheng);
    linChuangXinLvShiChangZhenDuan =
        (EditText) rootView.findViewById(R.id.linchuangxinlvshichangzhenduan);

    buWei = (EditText) rootView.findViewById(R.id.buwei);
    confirm = (CircularProgressButton) rootView.findViewById(R.id.confirm);

    Calendar cal = Calendar.getInstance();
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);
    int day = cal.get(Calendar.DATE);

    month++;
    Date date = new Date(year - 1900, month - 1, day);
    case1.setOperationData(date);
    shouShuRiQi.setText(year + "年" + month + "月" + day + "日");

    shouShuRiQi.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            final Calendar calendar = Calendar.getInstance();
            final DatePickerDialog datePickerDialog =
                DatePickerDialog.newInstance(
                    new ShouShuRiQiDatePickrDialogListener(),
                    calendar.get(Calendar.YEAR),
                    calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH),
                    false);
            datePickerDialog.setYearRange(1985, 2028);
            datePickerDialog.show(getActivity().getSupportFragmentManager(), DATEPICKER_TAG);
          }
        });

    linChuangXinLvShiChangZhenDuan.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            ArrayAdapter<String> arrayAdapter =
                new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1);
            for (int i = 0; i < zhenduan_types.length; i++) {
              arrayAdapter.add(zhenduan_types[i]);
            }
            ListView listView = new ListView(getActivity());
            float scale = getResources().getDisplayMetrics().density;
            int dpAsPixels = (int) (8 * scale + 0.5f);
            listView.setPadding(0, dpAsPixels, 0, dpAsPixels);
            listView.setDividerHeight(0);
            listView.setAdapter(arrayAdapter);
            final MaterialDialog alert =
                new MaterialDialog(getActivity()).setTitle("临床心率失常诊断").setContentView(listView);
            listView.setOnItemClickListener(
                new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(
                      AdapterView<?> adapterView, View view, int position, long l) {
                    linChuangXinLvShiChangZhenDuan.setText(zhenduan_types[position]);
                    alert.dismiss();
                  }
                });
            alert.show();
          }
        });

    buWei.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            youshitext = "";
            zuoshitext = "";
            liuchudaotext = "";
            xinjianbutext = "";
            jiangetext = "";
            qianbitext = "";
            houbitext = "";
            qitatext = "";

            View v = LayoutInflater.from(getActivity()).inflate(R.layout.buwei, null);
            final MaterialDialog alert =
                new MaterialDialog(getActivity()).setTitle("部位").setContentView(v);
            alert.show();
            final CheckBox youshi = (CheckBox) v.findViewById(R.id.youshi);
            CheckBox zuoshi = (CheckBox) v.findViewById(R.id.zuoshi);
            CheckBox liuchudao = (CheckBox) v.findViewById(R.id.liuchudao);
            CheckBox xinjianbu = (CheckBox) v.findViewById(R.id.xinjianbu);
            CheckBox jiange = (CheckBox) v.findViewById(R.id.jiange);
            CheckBox qianbi = (CheckBox) v.findViewById(R.id.qianbi);
            CheckBox houbi = (CheckBox) v.findViewById(R.id.houbi);

            final MaterialEditText qita = (MaterialEditText) v.findViewById(R.id.qita);
            CircularProgressButton confirm = (CircularProgressButton) v.findViewById(R.id.confirm);

            youshi.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    if (b) {
                      youshitext = "右室";
                    } else {
                      youshitext = "";
                    }
                  }
                });

            zuoshi.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    if (b) {
                      zuoshitext = "左室";
                    } else {
                      zuoshitext = "";
                    }
                  }
                });

            liuchudao.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    if (b) {
                      liuchudaotext = "流出道";
                    } else {
                      liuchudaotext = "";
                    }
                  }
                });

            xinjianbu.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    if (b) {
                      xinjianbutext = "心尖部";
                    } else {
                      xinjianbutext = "";
                    }
                  }
                });

            jiange.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    if (b) {
                      jiangetext = "间隔";
                    } else {
                      jiangetext = "";
                    }
                  }
                });

            qianbi.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    if (b) {
                      qianbitext = "前壁";
                    } else {
                      qianbitext = "";
                    }
                  }
                });

            houbi.setOnCheckedChangeListener(
                new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    if (b) {
                      houbitext = "后壁";
                    } else {
                      houbitext = "";
                    }
                  }
                });

            confirm.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    buweitext = "";
                    qitatext = qita.getText().toString();
                    buweitext =
                        youshitext
                            + " "
                            + zuoshitext
                            + " "
                            + liuchudaotext
                            + " "
                            + xinjianbutext
                            + " "
                            + jiangetext
                            + " "
                            + qianbitext
                            + " "
                            + houbitext
                            + " "
                            + qitatext;
                    buWei.setText("部位:" + buweitext);
                    alert.dismiss();
                  }
                });
          }
        });

    shiSuLeiXing.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View view) {
            final View v = LayoutInflater.from(getActivity()).inflate(R.layout.shisuleixing, null);
            final MaterialDialog alert =
                new MaterialDialog(getActivity()).setTitle("室速类型").setContentView(v);
            alert.show();
            final Spinner spinner = (Spinner) v.findViewById(R.id.leixing);
            final EditText zaobofuhe = (EditText) v.findViewById(R.id.zaobofuhe);
            final EditText pindu = (EditText) v.findViewById(R.id.pindu);
            final EditText meicifazuochixushijian =
                (EditText) v.findViewById(R.id.meicifazuochixushijian);
            final EditText zuijinfazuochixushijian =
                (EditText) v.findViewById(R.id.zuijinfazuochixushijian);
            final LinearLayout pindu_aera = (LinearLayout) v.findViewById(R.id.pindu_aera);
            final LinearLayout zaobofuhe_aera = (LinearLayout) v.findViewById(R.id.zaobofuhe_aera);
            final LinearLayout meicifazuochixushijian_aera =
                (LinearLayout) v.findViewById(R.id.meicifazuochixushijian_aera);
            final LinearLayout zuijinfazuochixushijian_aera =
                (LinearLayout) v.findViewById(R.id.zuijinfazuochixushijian_aera);
            ArrayAdapter<String> arrayAdapter =
                new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1);
            for (int i = 0; i < types.length; i++) {
              arrayAdapter.add(types[i]);
            }
            spinner.setAdapter(arrayAdapter);
            spinner.setOnItemSelectedListener(
                new AdapterView.OnItemSelectedListener() {
                  @Override
                  public void onItemSelected(
                      AdapterView<?> adapterView, View view, int position, long l) {
                    spinnertext = types[position];
                    if (position == 1) {
                      zaobofuhe_aera.setVisibility(View.VISIBLE);
                      pindu_aera.setVisibility(View.GONE);
                      meicifazuochixushijian_aera.setVisibility(View.GONE);
                      zuijinfazuochixushijian_aera.setVisibility(View.GONE);
                    } else {
                      zaobofuhe_aera.setVisibility(View.GONE);
                      pindu_aera.setVisibility(View.VISIBLE);
                      meicifazuochixushijian_aera.setVisibility(View.VISIBLE);
                      zuijinfazuochixushijian_aera.setVisibility(View.VISIBLE);
                    }
                  }

                  @Override
                  public void onNothingSelected(AdapterView<?> adapterView) {
                    spinnertext = types[0];
                  }
                });

            zaobofuhe.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    NumberPickerBuilder numberPickerBuilder =
                        new NumberPickerBuilder()
                            .setFragmentManager(getFragmentManager())
                            .setStyleResId(R.style.BetterPickersDialogFragment_Light);
                    numberPickerBuilder.show();
                    numberPickerBuilder.addNumberPickerDialogHandler(
                        new NumberPickerDialogFragment.NumberPickerDialogHandler() {
                          @Override
                          public void onDialogNumberSet(
                              int reference,
                              int number,
                              double decimal,
                              boolean isNegative,
                              double fullNumber) {
                            zaobofuhetext = String.valueOf(number);
                            zaobofuhe.setText(zaobofuhetext);
                          }
                        });
                  }
                });

            pindu.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    HmsPickerBuilder hmsPickerBuilder =
                        new HmsPickerBuilder()
                            .setFragmentManager(getFragmentManager())
                            .setStyleResId(R.style.BetterPickersDialogFragment_Light);
                    hmsPickerBuilder.show();
                    hmsPickerBuilder.addHmsPickerDialogHandler(
                        new HmsPickerDialogFragment.HmsPickerDialogHandler() {
                          @Override
                          public void onDialogHmsSet(
                              int reference, int hours, int minutes, int seconds) {
                            String temp = hours + "小时" + minutes + "分钟" + seconds + "秒";
                            pindu.setText(temp);
                            pindutext = temp;
                          }
                        });
                  }
                });

            meicifazuochixushijian.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    HmsPickerBuilder hmsPickerBuilder =
                        new HmsPickerBuilder()
                            .setFragmentManager(getFragmentManager())
                            .setStyleResId(R.style.BetterPickersDialogFragment_Light);
                    hmsPickerBuilder.show();
                    hmsPickerBuilder.addHmsPickerDialogHandler(
                        new HmsPickerDialogFragment.HmsPickerDialogHandler() {
                          @Override
                          public void onDialogHmsSet(
                              int reference, int hours, int minutes, int seconds) {
                            String temp = hours + "小时" + minutes + "分钟" + seconds + "秒";
                            meicifazuochixushijian.setText(temp);
                            meicifazuochixushijiantext = temp;
                          }
                        });
                  }
                });

            zuijinfazuochixushijian.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    HmsPickerBuilder hmsPickerBuilder =
                        new HmsPickerBuilder()
                            .setFragmentManager(getFragmentManager())
                            .setStyleResId(R.style.BetterPickersDialogFragment_Light);
                    hmsPickerBuilder.show();
                    hmsPickerBuilder.addHmsPickerDialogHandler(
                        new HmsPickerDialogFragment.HmsPickerDialogHandler() {
                          @Override
                          public void onDialogHmsSet(
                              int reference, int hours, int minutes, int seconds) {
                            String temp = hours + "小时" + minutes + "分钟" + seconds + "秒";
                            zuijinfazuochixushijian.setText(temp);
                            zuijinfazuochixushijiantext = temp;
                          }
                        });
                  }
                });
            //                final MaterialEditText cengyongzhuanfufangfa = (MaterialEditText)
            // v.findViewById(R.id.cengyongzhuanfufangfa);
            //                final MaterialEditText zhuanlvyongyao = (MaterialEditText)
            // v.findViewById(R.id.zhuanlvyongyao);

            CircularProgressButton sure = (CircularProgressButton) v.findViewById(R.id.confirm);
            sure.setOnClickListener(
                new View.OnClickListener() {

                  @Override
                  public void onClick(View view) {
                    //                        cengyongzhuanfufangfatext =
                    // cengyongzhuanfufangfa.getText().toString();
                    //                        zhuanlvyongyaotext =
                    // zhuanlvyongyao.getText().toString();

                    if (spinnertext.equals("持续性")) {
                      shiSuLeiXing.setText(
                          "类型:" + spinnertext + "\n\n" + "早搏负荷:" + zaobofuhetext
                          //                        + "曾用转复方法:" + cengyongzhuanfufangfatext + "\n\n"
                          //                        + "转律用药:" + zhuanlvyongyaotext
                          );
                    } else {
                      shiSuLeiXing.setText(
                          "类型:"
                              + spinnertext
                              + "\n\n"
                              + "频度:"
                              + pindutext
                              + "\n\n"
                              + "每次发作持续时间:"
                              + meicifazuochixushijiantext
                              + "\n\n"
                              + "最近发作持续时间:"
                              + zuijinfazuochixushijiantext
                              + "\n\n"
                          //                        + "曾用转复方法:" + cengyongzhuanfufangfatext + "\n\n"
                          //                        + "转律用药:" + zhuanlvyongyaotext
                          );
                    }
                    alert.dismiss();
                  }
                });
          }
        });

    shiSuBingCheng.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            niantext = "";
            yuetext = "";
            final View v =
                LayoutInflater.from(getActivity()).inflate(R.layout.shisubingcheng, null);
            final MaterialDialog alert =
                new MaterialDialog(getActivity()).setTitle("室速病程").setContentView(v);
            alert.show();
            final EditText nian = (EditText) v.findViewById(R.id.nian);
            final EditText yue = (EditText) v.findViewById(R.id.yue);

            CircularProgressButton confirm = (CircularProgressButton) v.findViewById(R.id.confirm);

            nian.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    NumberPickerBuilder numberPickerBuilder =
                        new NumberPickerBuilder()
                            .setFragmentManager(getFragmentManager())
                            .setStyleResId(R.style.BetterPickersDialogFragment_Light);
                    numberPickerBuilder.show();
                    numberPickerBuilder.addNumberPickerDialogHandler(
                        new NumberPickerDialogFragment.NumberPickerDialogHandler() {
                          @Override
                          public void onDialogNumberSet(
                              int reference,
                              int number,
                              double decimal,
                              boolean isNegative,
                              double fullNumber) {
                            if (number > 50 || number < 1) {
                              ToastUtils.showLong("年份长度为1-50年");
                            } else {
                              niantext = String.valueOf(number);
                              nian.setText(niantext + "年");
                            }
                          }
                        });
                  }
                });

            yue.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    NumberPickerBuilder numberPickerBuilder =
                        new NumberPickerBuilder()
                            .setFragmentManager(getFragmentManager())
                            .setStyleResId(R.style.BetterPickersDialogFragment_Light);
                    numberPickerBuilder.show();
                    numberPickerBuilder.addNumberPickerDialogHandler(
                        new NumberPickerDialogFragment.NumberPickerDialogHandler() {
                          @Override
                          public void onDialogNumberSet(
                              int reference,
                              int number,
                              double decimal,
                              boolean isNegative,
                              double fullNumber) {
                            if (number > 12 || number < 1) {
                              ToastUtils.showLong("月份长度为1-12月");
                            } else {
                              yuetext = String.valueOf(number);
                              yue.setText(yuetext + "月");
                            }
                          }
                        });
                  }
                });

            confirm.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    shisubingchengtext = niantext + "年" + " " + yuetext + "月";
                    shiSuBingCheng.setText(shisubingchengtext);
                    alert.dismiss();
                  }
                });
          }
        });

    confirm.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            nextStepListner.OnNextStepClicked(1);
          }
        });
    return rootView;
  }
Example #5
0
 private void hidepDialog() {
   if (btEnter.getProgress() == 100) {
     btEnter.setProgress(0);
     btEnter.setVisibility(View.GONE);
   }
 }
Example #6
0
 private void showpDialog() {
   if (btEnter.getProgress() == 0) {
     btEnter.setVisibility(View.VISIBLE);
     btEnter.setProgress(50);
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.lmzhenduanxinxi, container, false);
    init();
    shouShuRiQi = (EditText) rootView.findViewById(R.id.shoushuriqi);
    shouShuBianHao = (MaterialEditText) rootView.findViewById(R.id.shoushubianhao);
    shuZhe = (MaterialEditText) rootView.findViewById(R.id.shuzhe);
    shiSuLeiXing = (EditText) rootView.findViewById(R.id.shisuleixing);
    shiSuBingCheng = (EditText) rootView.findViewById(R.id.shisubingcheng);
    linChuangXinLvShiChangZhenDuan =
        (MaterialEditText) rootView.findViewById(R.id.linchuangxinlvshichangzhenduan);
    dianShengLiJianChaZhenDuan =
        (MaterialEditText) rootView.findViewById(R.id.dianshenglijianchazhenduan);
    shuHouZhenDuan = (MaterialEditText) rootView.findViewById(R.id.shuhouzhenduan);

    confirm = (CircularProgressButton) rootView.findViewById(R.id.confirm);

    DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    if (case3.getOperationData() != 0) {
      shouShuRiQi.setText(dateFormat.format(new Date(case3.getOperationData())));
    }
    if (case3.getOperationNumber() != null) {
      shouShuBianHao.setText(case3.getOperationNumber());
    }
    if (case3.getOperatorName() != null) {
      shuZhe.setText(case3.getOperatorName());
    }
    if (case3.getAfType() != null && !case3.getAfType().equals("")) {
      shiSuLeiXing.setText(
          "类型:"
              + case3.getAfType()
              + "\n\n"
              + "频度:"
              + case3.getAfFrequency()
              + "\n\n"
              + "每次发作持续时间:"
              + case3.getAfEveryAttackTime()
              + "\n\n"
              + "最近发作持续时间:"
              + case3.getAfLastAttackTime()
              + "\n\n"
              + "曾用转复方法:"
              + case3.getCardioversionMethod()
              + "\n\n"
              + "转律用药:"
              + case3.getCardioversionMedication());
    }
    if (case3.getAfCourseDisease() != null) {
      shiSuBingCheng.setText(case3.getAfCourseDisease());
    }
    if (case3.getArrhythmiaDiagnose() != null) {
      linChuangXinLvShiChangZhenDuan.setText(case3.getArrhythmiaDiagnose());
    }
    if (case3.getElectrophysiologyDiagnose() != null) {
      dianShengLiJianChaZhenDuan.setText(case3.getElectrophysiologyDiagnose());
    }
    if (case3.getPostoperationDiagnose() != null) {
      shuHouZhenDuan.setText(case3.getPostoperationDiagnose());
    }

    confirm.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            nextStepListner.OnNextStepClicked(1);
          }
        });
    return rootView;
  }
  private void loginAfterServiceConnected() {
    final GaService gaService = getGAService();

    if (getGAApp().getConnectionObservable().getState() == ConnectivityObservable.State.LOGGEDIN) {
      Toast.makeText(
              MnemonicActivity.this, "You must first logout before signing in.", Toast.LENGTH_LONG)
          .show();
      return;
    }

    if (getGAApp().getConnectionObservable().getState() != ConnectivityObservable.State.CONNECTED) {
      Toast.makeText(MnemonicActivity.this, "Not connected", Toast.LENGTH_LONG).show();
      return;
    }
    final EditText edit = (EditText) findViewById(R.id.mnemonicText);
    final CircularProgressButton okButton =
        (CircularProgressButton) findViewById(R.id.mnemonicOkButton);

    if (!validateMnemonic(edit.getText().toString())) {
      return;
    }

    okButton.setIndeterminateProgressMode(true);
    runOnUiThread(
        new Runnable() {
          @Override
          public void run() {
            // This larger function is somehow being called in another
            // non-main thread when cold-start NFC mnemonics login is
            // prompted, causing this to fail.
            okButton.setProgress(50);
          }
        });

    final AsyncFunction<Void, LoginData> connectToLogin =
        new AsyncFunction<Void, LoginData>() {
          @Override
          public ListenableFuture<LoginData> apply(final Void input) {
            if (edit.getText().toString().trim().split(" ").length == 27) {
              // encrypted mnemonic
              return Futures.transform(
                  askForPassphrase(),
                  new AsyncFunction<String, LoginData>() {
                    @Nullable
                    @Override
                    public ListenableFuture<LoginData> apply(@Nullable String passphrase) {
                      try {
                        byte[] entropy =
                            gaService
                                .getMnemonicCode()
                                .toEntropy(
                                    Arrays.asList(edit.getText().toString().trim().split(" ")));
                        String normalizedPassphrase =
                            Normalizer.normalize(passphrase, Normalizer.Form.NFC);
                        byte[] decrypted = decryptMnemonic(entropy, normalizedPassphrase);
                        return gaService.login(
                            Joiner.on(" ").join(gaService.getMnemonicCode().toMnemonic(decrypted)));
                      } catch (IOException | GeneralSecurityException | MnemonicException e) {
                        throw new RuntimeException(e);
                      }
                    }
                  });
            } else {
              return gaService.login(edit.getText().toString().trim());
            }
          }
        };

    final ListenableFuture<LoginData> loginFuture =
        Futures.transform(gaService.onConnected, connectToLogin, gaService.es);

    Futures.addCallback(
        loginFuture,
        new FutureCallback<LoginData>() {
          @Override
          public void onSuccess(@Nullable final LoginData result) {
            if (getCallingActivity() == null) {
              final Intent pinSaveActivity =
                  new Intent(MnemonicActivity.this, PinSaveActivity.class);
              pinSaveActivity.putExtra(
                  "com.greenaddress.greenbits.NewPinMnemonic", gaService.getMnemonics());
              startActivity(pinSaveActivity);
            } else {
              setResult(RESULT_OK);
            }
            MnemonicActivity.this.finish();
          }

          @Override
          public void onFailure(final Throwable t) {
            final boolean accountDoesntExist = t instanceof ClassCastException;
            final String message = accountDoesntExist ? "Account doesn't exist" : "Login failed";
            t.printStackTrace();
            MnemonicActivity.this.runOnUiThread(
                new Runnable() {
                  @Override
                  public void run() {
                    Toast.makeText(MnemonicActivity.this, message, Toast.LENGTH_LONG).show();
                    okButton.setProgress(0);
                  }
                });
          }
        },
        gaService.es);
  }