コード例 #1
0
ファイル: SendNewMail.java プロジェクト: Jerry0523/Lily
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.reply_submit:
       if (title.getText() == null
           || title.getText().length() == 0
           || content.getText() == null
           || content.getText().length() == 0) {
         Toast.makeText(getApplicationContext(), "收件人和信件内容不能为空!", Toast.LENGTH_SHORT).show();
         return;
       }
       if (waitingDialog == null) {
         waitingDialog = IOSWaitingDialog.createDialog(this);
       }
       waitingDialog.show();
       new Thread(
               new Runnable() {
                 @Override
                 public void run() {
                   int result = 0;
                   try {
                     DocParser.sendMail(
                         title.getText().toString(),
                         content.getText().toString(),
                         SendNewMail.this);
                   } catch (IOException e) {
                     result = 1;
                   } finally {
                     mHandler.sendEmptyMessage(result);
                   }
                 }
               })
           .start();
       break;
     case R.id.reply_quit:
       onBackPressed();
       break;
     default:
       break;
   }
 }
コード例 #2
0
ファイル: SendNewMail.java プロジェクト: Jerry0523/Lily
 public void handleMessage(Message msg) {
   if (waitingDialog != null) {
     waitingDialog.dismiss();
   }
   switch (msg.what) {
     case 0:
       Toast.makeText(getApplicationContext(), "信件发送成功!", Toast.LENGTH_SHORT).show();
       onBackPressed();
       break;
     case 1:
       Toast.makeText(getApplicationContext(), "信件发送失败!", Toast.LENGTH_SHORT).show();
       break;
   }
 }