예제 #1
0
  @Override
  protected void handleUiMessage(Message msg) {
    // TODO Auto-generated method stub
    super.handleUiMessage(msg);
    // 收起菊花
    hideProgressDialog();
    RequestBaseResponse obj = (RequestBaseResponse) msg.obj;
    switch (RequestFlag.values()[msg.what]) {
      case REQUEST_VERSIONCHECK_SUCCESS:
        {
          // 版本检测成功
          mOtherVersionCheckItem = (OtherVersionCheckItem) obj.body;

          ReloadData();

          if (mOtherVersionCheckItem != null
              && mOtherVersionCheckItem.verCode > QpidApplication.versionCode) {
            // 有更新
            mUpdateDialog.setTitle(mContext.getString(R.string.upgrade_title));
            mUpdateDialog.setMessage(mOtherVersionCheckItem.verDesc);
            mUpdateDialog.removeAllButton();
            mUpdateDialog.addButton(
                mUpdateDialog.createButton(
                    getString(R.string.common_btn_go),
                    new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        Uri uri = Uri.parse(mOtherVersionCheckItem.storeUrl);
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_VIEW);
                        intent.setData(uri);
                        startActivity(intent);
                      }
                    }));
            mUpdateDialog.addButton(
                mUpdateDialog.createButton(getString(R.string.common_btn_cancel), null));
            mUpdateDialog.show();

          } else {
            // 无更新
            MaterialDialogAlert alert = new MaterialDialogAlert(mContext);
            alert.setMessage("You are the latest version!");
            alert.addButton(alert.createButton(getString(R.string.common_btn_ok), null));
            alert.show();
          }
        }
        break;
      case REQUEST_FAIL:
        {
          // 请求失败
          Toast.makeText(mContext, obj.errmsg, Toast.LENGTH_LONG).show();
        }
        break;
      default:
        break;
    }
  }
예제 #2
0
  /**
   * 点击CleanCache
   *
   * @param v
   */
  public void onClickCache(View v) {
    MaterialDialogAlert dialog = new MaterialDialogAlert(mContext);
    dialog.setMessage(getString(R.string.myprofile_sure_clean_cache));
    dialog.addButton(
        dialog.createButton(
            getString(R.string.common_btn_ok),
            new OnClickListener() {
              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                FileCacheManager.getInstance().ClearCache();

                MaterialDialogAlert alert = new MaterialDialogAlert(mContext);
                alert.setMessage("All cache has been clean!");
                alert.addButton(alert.createButton(getString(R.string.common_btn_ok), null));
                alert.show();
              }
            }));
    dialog.addButton(dialog.createButton(getString(R.string.common_btn_cancel), null));
    dialog.show();
  }