コード例 #1
0
 /** 描述:返回. */
 @Override
 public void onBackPressed() {
   if (menu.isMenuShowing()) {
     menu.showContent();
   } else {
     if (mMainContentFragment.canBack()) {
       if (isExit == false) {
         isExit = true;
         AbToastUtil.showToast(MainActivity.this, "再按一次退出程序");
       } else {
         super.onBackPressed();
       }
     }
   }
 }
コード例 #2
0
    @Override
    public void onClick(View v) {
      mStr_name = userName.getText().toString().trim();
      mStr_email = email.getText().toString().trim();
      if (TextUtils.isEmpty(mStr_name)) {
        AbToastUtil.showToast(FindPwdActivity.this, R.string.error_name);
        userName.setFocusable(true);
        userName.requestFocus();
        return;
      }

      if (!AbStrUtil.isNumberLetter(mStr_name)) {
        AbToastUtil.showToast(FindPwdActivity.this, R.string.error_name_expr);
        userName.setFocusable(true);
        userName.requestFocus();
        return;
      }

      if (AbStrUtil.strLength(mStr_name) < 3) {
        AbToastUtil.showToast(FindPwdActivity.this, R.string.error_name_length1);
        userName.setFocusable(true);
        userName.requestFocus();
        return;
      }

      if (AbStrUtil.strLength(mStr_name) > 20) {
        AbToastUtil.showToast(FindPwdActivity.this, R.string.error_name_length2);
        userName.setFocusable(true);
        userName.requestFocus();
        return;
      }

      if (!TextUtils.isEmpty(mStr_email)) {
        if (!AbStrUtil.isEmail(mStr_email)) {
          AbToastUtil.showToast(FindPwdActivity.this, R.string.error_email_expr);
          email.setFocusable(true);
          email.requestFocus();
          return;
        }
      } else {
        AbToastUtil.showToast(FindPwdActivity.this, R.string.error_email);
        email.setFocusable(true);
        email.requestFocus();
      }

      AbDialogUtil.showProgressDialog(
          FindPwdActivity.this, R.drawable.progress_circular, "正在找回...");
      final AbTaskItem item = new AbTaskItem();
      item.setListener(
          new AbTaskObjectListener() {

            @Override
            public void update(Object obj) {
              AbDialogUtil.removeDialog(FindPwdActivity.this);
              AbResult mAbResult = (AbResult) obj;
              if (mAbResult != null) {
                AbToastUtil.showToast(FindPwdActivity.this, mAbResult.getResultMessage());
                if (mAbResult.getResultCode() == AbResult.RESULR_OK) {
                  finish();
                }
              }
            }

            @Override
            public Object getObject() {
              AbResult mAbResult = null;
              try {
                mAbResult = new AbResult();
                mAbResult.setResultMessage("ok");

              } catch (Exception e) {
                AbToastUtil.showToastInThread(FindPwdActivity.this, e.getMessage());
              }
              return mAbResult;
            };
          });
      mAbTaskPool.execute(item);
    }
コード例 #3
0
ファイル: DialogActivity.java プロジェクト: jeasonxia/andbase
  public void btnClick(View v) {
    View mView = null;
    switch (v.getId()) {
      case R.id.button2:
        mView = mInflater.inflate(R.layout.dialog_custom_view, null);
        AbDialogUtil.showDialog(
            mView,
            new DialogInterface.OnCancelListener() {

              @Override
              public void onCancel(DialogInterface dialog) {
                AbToastUtil.showToast(DialogActivity.this, "弹出框被取消");
              }
            });
        break;
      case R.id.button3:
        mView = mInflater.inflate(R.layout.dialog_custom_view, null);
        AbDialogUtil.showDialog(
            mView,
            AbDialogUtil.ThemeLightPanel,
            new DialogInterface.OnCancelListener() {

              @Override
              public void onCancel(DialogInterface dialog) {
                AbToastUtil.showToast(DialogActivity.this, "弹出框被取消");
              }
            });
        break;
      case R.id.button4:
        // 显示有背景层的加载的弹出框
        showLoadDialog();
        break;
      case R.id.button5:
        // 显示无背景层的加载的弹出框
        showLoadPanel();
        break;
      case R.id.button6:
        // 显示有背景层的刷新的弹出框
        showRefreshDialog();
        break;
      case R.id.button7:
        // 显示无背景层的刷新的弹出框
        showRefreshPanel();
        break;
      case R.id.button8:
        AbDialogUtil.showAlertDialog(
            DialogActivity.this,
            R.drawable.ic_alert,
            "这里是标题",
            "这里写一些描述",
            new AbDialogOnClickListener() {

              @Override
              public void onPositiveClick() {
                AbToastUtil.showToast(DialogActivity.this, "点击了确认");
              }

              @Override
              public void onNegativeClick() {
                AbToastUtil.showToast(DialogActivity.this, "点击了取消");
              }
            });
        break;
      case R.id.button9:
        AbDialogUtil.showAlertDialog(
            DialogActivity.this, R.drawable.ic_alert, "这里是标题", "这里写一些描述", null);
        break;
      case R.id.button10:
        mView = mInflater.inflate(R.layout.dialog_custom_view, null);
        AbDialogUtil.showAlertDialog(mView);
        break;
      case R.id.button11:
        // 无按钮+动画
        mView = mInflater.inflate(R.layout.dialog_text, null);
        AbDialogUtil.showDialog(
            mView,
            R.animator.fragment_top_enter,
            R.animator.fragment_top_exit,
            R.animator.fragment_pop_top_enter,
            R.animator.fragment_pop_top_exit);
        break;
      case R.id.button12:
        // 按钮+列表
        mView = mInflater.inflate(R.layout.dialog_button_listview, null);
        AbDialogUtil.showDialog(
            mView,
            R.animator.fragment_top_enter,
            R.animator.fragment_top_exit,
            R.animator.fragment_pop_top_enter,
            R.animator.fragment_pop_top_exit);
        ListView listView = (ListView) mView.findViewById(R.id.list);
        String[] mStrings = {"对话框选项item1", "对话框选项item2", "对话框选项item3", "对话框选项item4"};
        listView.setAdapter(new ArrayAdapter<String>(this, R.layout.dialog_list_item_1, mStrings));
        Button leftBtn = (Button) mView.findViewById(R.id.left_btn);
        Button rightBtn = (Button) mView.findViewById(R.id.right_btn);
        leftBtn.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                AbDialogUtil.removeDialog(DialogActivity.this);
              }
            });

        rightBtn.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                AbDialogUtil.removeDialog(DialogActivity.this);
              }
            });

        break;
      case R.id.button13:
        // 按钮+文本
        // 动画未生效
        mView = mInflater.inflate(R.layout.dialog_text_button, null);
        AbDialogUtil.showDialog(
            mView,
            R.animator.fragment_top_enter,
            R.animator.fragment_top_exit,
            R.animator.fragment_pop_top_enter,
            R.animator.fragment_pop_top_exit);
        Button leftBtn1 = (Button) mView.findViewById(R.id.left_btn);
        Button rightBtn1 = (Button) mView.findViewById(R.id.right_btn);
        leftBtn1.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                AbDialogUtil.removeDialog(DialogActivity.this);
              }
            });

        rightBtn1.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                AbDialogUtil.removeDialog(DialogActivity.this);
              }
            });
        break;

      case R.id.button14:
        // 上
        mView = mInflater.inflate(R.layout.dialog_custom_view, null);
        AbDialogUtil.showDialog(mView, Gravity.TOP);
        break;
      case R.id.button15:
        // 中
        mView = mInflater.inflate(R.layout.dialog_custom_view, null);
        AbDialogUtil.showDialog(mView, Gravity.CENTER);
        break;
      case R.id.button16:
        // 下
        mView = mInflater.inflate(R.layout.dialog_custom_view, null);
        AbDialogUtil.showDialog(mView, Gravity.BOTTOM);
        break;
      case R.id.button17:
        // 全屏
        mView = mInflater.inflate(R.layout.dialog_custom_view, null);
        AbDialogUtil.showFullScreenDialog(mView);
        break;
      case R.id.button18:
        AbDialogUtil.showProgressDialog(DialogActivity.this, 0, "查询中...");
        new Handler()
            .postDelayed(
                new Runnable() {

                  @Override
                  public void run() {
                    AbDialogUtil.removeDialog(DialogActivity.this);
                  }
                },
                2000);
        break;
      case R.id.button19:
        AbToastUtil.showToast(DialogActivity.this, "Toast提示框");
        break;
      default:
        break;
    }
  }