private void ConnectWebResult( HttpConnectionUtil connect, String geturl, HashMap<String, String> map) { Log.i(TAG, "connection url is : " + geturl); mwaittingBar = ProgressDialog.show(VoteViewActivity.this, null, null); connect.asyncConnect( geturl, map, HttpMethod.POST, new HttpConnectionCallback() { @Override public void execute(String response) { Log.i(TAG, "response === " + response); mwaittingBar.dismiss(); if ("success".equalsIgnoreCase(response)) { AlertDialog.Builder builder = new AlertDialog.Builder(VoteViewActivity.this); builder.setTitle(R.string.message_title_indicate); builder.setMessage(R.string.msg_vote_success); builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { VoteViewActivity.this.finish(); } }); builder.create().show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(VoteViewActivity.this); builder.setTitle(R.string.message_title_indicate); builder.setMessage(R.string.msg_vote_failed); builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { VoteViewActivity.this.finish(); } }); builder.create().show(); } } }); }
private void ConnectWeb(HttpConnectionUtil connect, String geturl) { Log.i(TAG, "connection url is : " + geturl); connect.asyncConnect( geturl, HttpMethod.GET, new HttpConnectionCallback() { @Override public void execute(String response) { mwaittingBar.dismiss(); if ((response == null) || (response.length() == 0) || response.equals(HttpConnectionUtil.CONNECT_FAILED) || HttpConnectionUtil.RETURN_FAILED.equalsIgnoreCase(response)) { Log.i(TAG, "request failed"); return; } InputStream stream = new ByteArrayInputStream(response.getBytes()); Log.i(TAG, "string" + response); mVoteitem = DomXMLReader.readXMLVote(mContext, stream); if (mVoteitem == null) { return; } if (mVoteitem.getmIsVoted()) { mVoteBtnView.setText(R.string.btn_result_text); } else { mVoteBtnView.setText(R.string.btn_vote_text); } mVoteTitleView.setText(mVoteitem.getmTitle()); if (mVoteitem.getmSummary().length() == 0) { mVoteSumView.setVisibility(View.GONE); } else { mVoteSumView.getBackground().setAlpha(100); mVoteSumView.setText(mVoteitem.getmSummary()); } mImageDownLoad.download( mVoteitem.getmIconLink(), mVoteImageView, R.drawable.vote_default_bg, mContext); } }); }
public void ConnectWeb(HttpConnectionUtil connect, String geturl) { Log.i(TAG, "the url is : " + geturl); connect.asyncConnect( geturl, HttpMethod.POST, new HttpConnectionCallback() { @Override public void execute(String response) { // mwaittingBar.setVisibility(View.GONE); if ((response == null) || (response.length() == 0) || response.equals(HttpConnectionUtil.CONNECT_FAILED) || HttpConnectionUtil.RETURN_FAILED.equalsIgnoreCase(response)) { Log.i(TAG, "request failed"); return; } try { InputStream stream = new ByteArrayInputStream(response.getBytes()); Log.i(TAG, "string = " + response); // SaveRssFile savefile = new SaveRssFile(mContext); // savefile.SaveFile(response.substring(nindex),"toutiao.xml"); ChannelInformation channelInfo = DomXMLReader.readXML(mContext, stream); if (channelInfo != null) { HashMap<String, Object> map = null; ArrayList<ChannelItem> channlelist = (ArrayList<ChannelItem>) channelInfo.getmChannelItemList(); // String ServerUrl = ReadConfigFile.getServerAddress(mContext); for (int i = 0; i < channlelist.size(); i++) { map = new HashMap<String, Object>(); Log.i(TAG, "the title is : " + channlelist.get(i).getmTitle()); Log.i(TAG, "the desc is : " + channlelist.get(i).getmDescription()); map.put("title", channlelist.get(i).getmTitle()); map.put( "desc", channlelist.get(i).getmDescription() + " " + channlelist.get(i).getmDate()); map.put("link", channlelist.get(i).getmLink()); map.put("icon", channlelist.get(i).getmIcon()); mListArrayList.add(map); } mListAdapter.notifyDataSetChanged(); mButton.setEnabled(true); if (channlelist.size() == 0) { if (mRequestType == REQUEST_TYPE_NEXT) { mpageIndex--; mButton.setText(getString(R.string.btn_lastpage)); mButton.setVisibility(View.VISIBLE); mButton.setOnClickListener(null); } else { mButton.setVisibility(View.GONE); } } if (channlelist.size() < PAGE_MAX_COUNT) { mButton.setText(getString(R.string.btn_lastpage)); mButton.setVisibility(View.VISIBLE); mButton.setOnClickListener(null); } else { mButton.setText(getString(R.string.btn_display_next_text)); mButton.setVisibility(View.VISIBLE); mButton.setOnClickListener(DisscusActivity.this); } } } catch (Exception e) { e.printStackTrace(); } } }); }