@Override protected Boolean doInBackground(String... params) { boolean result = false; try { InqChangePasswordRequest inqChangePasswordRequest = new InqChangePasswordRequest(); String s = HttpClientUtil.getObjectMapper(ctx).writeValueAsString(inqChangePasswordRequest); s = CipherUtil.encryptTripleDES(s, CipherUtil.PASSWORD); Log.d(TAG, "Request: " + s); StringEntity entity = new StringEntity(s); HttpPost post = new HttpPost(HttpClientUtil.URL_BASE + HttpClientUtil.URL_REFRESHING_LIST_MALL); post.setHeader(HttpClientUtil.CONTENT_TYPE, HttpClientUtil.JSON); post.setEntity(entity); // Execute HTTP request Log.d(TAG, "Executing request: " + post.getURI()); HttpResponse response = client.execute(post); HttpEntity respEntity = response.getEntity(); respString = EntityUtils.toString(respEntity); result = true; } catch (ClientProtocolException e) { Log.e(TAG, "ClientProtocolException : " + e); respString = ctx.getResources().getString(R.string.message_unexpected_error_message_server); cancel(true); } catch (IOException e) { Log.e(TAG, "IOException : " + e); respString = ctx.getResources().getString(R.string.message_no_internet_connection); cancel(true); } catch (Exception e) { Log.e(TAG, "Exception : " + e); respString = ctx.getResources().getString(R.string.message_unexpected_error_message_server); cancel(true); } return result; }
@Override protected void onPostExecute(final Boolean success) { reqRefreshListMallTask = null; if (success) { if (!respString.isEmpty()) { try { String respons = CipherUtil.decryptTripleDES(respString, CipherUtil.PASSWORD); final MessageVO messageVO = HttpClientUtil.getObjectMapper(ctx).readValue(respons, MessageVO.class); if (messageVO.getRc() == 0) { MessageUtils messageUtils = new MessageUtils(ctx); messageUtils.snackBarMessage(getActivity(), messageVO.getOtherMessage()); } else { MessageUtils messageUtils = new MessageUtils(ctx); messageUtils.snackBarMessage(getActivity(), messageVO.getMessageRc()); new Timer() .schedule( new TimerTask() { @Override public void run() { if (messageVO.getRc() == Constants.SESSION_EXPIRED || messageVO.getRc() == Constants.SESSION_DIFFERENT || messageVO.getRc() == Constants.USER_NOT_LOGIN) { RedirectUtils redirectUtils = new RedirectUtils(ctx, getActivity()); redirectUtils.redirectToLogin(); } } }, Constants.REDIRECT_DELAY_LOGIN); } } catch (Exception e) { MessageUtils messageUtils = new MessageUtils(ctx); messageUtils.snackBarMessage( getActivity(), ctx.getResources().getString(R.string.message_unexpected_error_message_server)); } } else { MessageUtils messageUtils = new MessageUtils(ctx); messageUtils.snackBarMessage( getActivity(), ctx.getResources().getString(R.string.message_unexpected_error_server)); } } else { MessageUtils messageUtils = new MessageUtils(ctx); messageUtils.snackBarMessage( getActivity(), ctx.getResources().getString(R.string.message_unexpected_error_server)); } if (progressDialog.isShowing()) { progressDialog.dismiss(); } }