@SuppressWarnings("unchecked") @Override protected Object doInBackground(Ajax... ajaxs) { Object data = null; final Ajax ajax = mAjax; if (ajax == null) return null; HttpRequest mHttpRequest = ajax.getHttpRequest(); if (ajax.getOnProgressListener() != null) { mHttpRequest.setOnProgressListener(this); } if (mAjax.getParser() == null && ajax.getOnSuccessListener() == null) { mHttpRequest.setIsNeedResponse(false); } isError = !mHttpRequest.send(); if (!isError && !isCanceled && ajax.getOnSuccessListener() != null && mHttpRequest.getHttpStatus() == HttpStatus.SC_OK) { @SuppressWarnings("rawtypes") final Parser parser = mAjax.getParser(); try { if (parser == null) { Log.e(LOG_TAG, "you have set onSuccessListener, but the parser is null"); } else { data = parser.parse(mHttpRequest.getResponseData(), mHttpRequest.getCharset()); } } catch (Exception ex) { if (null != parser && TextUtils.isEmpty(parser.getErrMsg())) { parser.setErrMsg(IcsonApplication.app.getString(R.string.parser_error_msg)); } isError = true; if (Config.DEBUG) { Log.e(LOG_TAG, ToolUtil.getStackTraceString(ex)); } } } return data; }
@Override public void onClick(View v) { int rid = v.getId(); switch (rid) { case R.id.mycity_message: ToolUtil.checkLoginOrRedirect(this, MsgCenterActivity.class); break; // case R.id.mycity_selectgame_button: case R.id.mycity_select_game: ToolUtil.checkLoginOrRedirect(this, SelectGameActivity.class); break; case R.id.mycity_role: ToolUtil.checkLoginOrRedirect(this, MyRoleActivity.class); break; case R.id.mycity_warehouse: ToolUtil.checkLoginOrRedirect(this, MyWarehouseActivity.class); break; case R.id.mycity_order: ToolUtil.checkLoginOrRedirect(this, MyOrderListActivity.class); break; case R.id.mycity_settings: Intent aIntent = new Intent(this, SettingActivity.class); this.startActivity(aIntent); break; case R.id.button_logout: UiUtils.showDialog( this, R.string.caption_hint, R.string.message_logout, R.string.btn_ok, R.string.btn_cancel, new AppDialog.OnClickListener() { @Override public void onDialogClick(int nButtonId) { if (nButtonId == AppDialog.BUTTON_POSITIVE) { ILogin.clearAccount(); Preference.getInstance().clearGameInfo(); // // Clear QQ account information. // ReloginWatcher.getInstance(MoreActivity.this).clearAccountInfo(); // Intent pIntent = new Intent(MyCityActivity.this,LoginActivity.class); // MyCityActivity.this.startActivity(pIntent); MainActivity.logout(MyCityActivity.this); // MainActivity.startActivity(MyCityActivity.this, MainActivity.TAB_MY); } } }); break; case R.id.navigationbar_drawable_left: case R.id.message: Intent pIntent = new Intent(this, MsgCenterActivity.class); this.startActivity(pIntent); break; } }