@Override protected boolean parseXml(String xml) throws XmlPullParserException, IOException { if (!StringUtil.isEmpty(xml)) { MyLog.i("xml1=" + xml); MyLog.i("xml2=" + xml); errorCode = StringUtil.getXmlValueByLabel(xml, "isSuccess"); if (errorCode != null || errorCode.equalsIgnoreCase("1")) { errorInfo = StringUtil.getXmlValueByLabel(xml, "message"); if (errorInfo.trim().equals("")) { errorInfo = "服务器访问异常,稍后请重试!"; } } } else { errorInfo = "返回值为空"; } return true; }
@Override protected boolean parseXml(String xml) throws XmlPullParserException, IOException { Log.d(this.getClass().getName(), xml); String status = StringUtil.getXmlValueByLabel(xml, "status"); if (!TextUtils.isEmpty(status) && status.equals("1")) { isSuccess = true; } else { isSuccess = false; } return true; }
@Override protected boolean parseXml(String xml) { if (!StringUtil.isEmpty(xml)) { errorCode = StringUtil.getXmlValueByLabel(xml, "isSuccess"); // 返回xml中无isSuccess标签,即errorCode为null // if (errorCode == null) { // return false; // } if (errorCode != null) { errorCode = errorCode.replace("<![CDATA[", "").replaceAll("]]>", ""); } if (errorCode != null && errorCode.equalsIgnoreCase("1")) { errorInfo = StringUtil.getXmlValueByLabel(xml, "message"); // 成功 try { TribeAttentionBean MenuType_List_Son = null; XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(new StringReader(xml)); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_DOCUMENT: break; case XmlPullParser.START_TAG: String tag = parser.getName(); if (tag.equalsIgnoreCase("List")) { list = new ArrayList<TribeAttentionBean>(); } else if (tag.equalsIgnoreCase("MenuType_List_Son")) { MenuType_List_Son = new TribeAttentionBean(); } else if (tag.equalsIgnoreCase("IsAttention")) { MenuType_List_Son.setIsAttention(parser.nextText()); } else if (tag.equalsIgnoreCase("TodayTopic")) { MenuType_List_Son.setTodayTopic(parser.nextText()); } else if (tag.equalsIgnoreCase("ID")) { MenuType_List_Son.setID(parser.nextText()); } else if (tag.equalsIgnoreCase("GuidStr")) { MenuType_List_Son.setGuidStr(parser.nextText()); } else if (tag.equalsIgnoreCase("FatherGuidStr")) { MenuType_List_Son.setFatherGuidStr(parser.nextText()); } else if (tag.equalsIgnoreCase("ImagePath")) { MenuType_List_Son.setImagePath(parser.nextText()); } else if (tag.equalsIgnoreCase("ImagePath_ico")) { MenuType_List_Son.setImagePath_ico(parser.nextText()); } else if (tag.equalsIgnoreCase("ImagePath_x")) { MenuType_List_Son.setImagePath_x(parser.nextText()); } else if (tag.equalsIgnoreCase("TypeName")) { MenuType_List_Son.setTypeName(parser.nextText()); } else if (tag.equalsIgnoreCase("Explanation")) { MenuType_List_Son.setExplanation(parser.nextText()); } else if (tag.equalsIgnoreCase("AttentionCount")) { MenuType_List_Son.setAttentionCount(parser.nextText()); } else if (tag.equalsIgnoreCase("AddTime")) { MenuType_List_Son.setAddTime(parser.nextText()); } else if (tag.equalsIgnoreCase("IsDelete")) { MenuType_List_Son.setIsDelete(parser.nextText()); } else if (tag.equalsIgnoreCase("DeleteCnvcAccount")) { MenuType_List_Son.setDeleteCnvcAccount(parser.nextText()); } else if (tag.equalsIgnoreCase("DeleteTime")) { MenuType_List_Son.setDeleteTime(parser.nextText()); } else if (tag.equalsIgnoreCase("DeleteContent")) { MenuType_List_Son.setDeleteContent(parser.nextText()); } else if (tag.equalsIgnoreCase("Sorting")) { MenuType_List_Son.setSorting(parser.nextText()); } else if (tag.equalsIgnoreCase("cnvcAccount")) { MenuType_List_Son.setCnvcAccount(parser.nextText()); } break; case XmlPullParser.END_TAG: String tagEnd = parser.getName(); if (tagEnd.equalsIgnoreCase("MenuType_List_Son")) { list.add(MenuType_List_Son); } break; } eventType = parser.next(); } } catch (Exception e) { e.printStackTrace(); } } else { errorInfo = StringUtil.getXmlValueByLabel(xml, "message"); errorInfo = errorInfo.replace("<![CDATA[", "").replaceAll("]]>", ""); if (errorInfo.trim().equals("")) { errorInfo = "服务器访问异常,稍后请重试!"; } } } else { errorInfo = "返回值为空"; } return true; }
@Override public View getView(final int pos, View convertView, ViewGroup viewgroup) { ViewHolder vh = null; if (convertView == null) { vh = new ViewHolder(); convertView = mInflater.inflate(R.layout.me_item_newfriend, null); vh.addMsg_textview = (TextView) convertView.findViewById(R.id.me_textview_addfriend); vh.icon_imageView = (ImageView) convertView.findViewById(R.id.me_imageview_headicon); vh.icon_imageView_add = (ImageView) convertView.findViewById(R.id.me_imageview_headgo); vh.level_textview = (TextView) convertView.findViewById(R.id.me_textview_mycompany); vh.name_textview = (TextView) convertView.findViewById(R.id.me_textview_myname); vh.me_linearlayout_addfriend = (LinearLayout) convertView.findViewById(R.id.me_linearlayout_addfriend); vh.text_msg_phone = (TextView) convertView.findViewById(R.id.text_msg_phone); vh.text_msg_chat = (TextView) convertView.findViewById(R.id.text_msg_chat); vh.selected_check = (CheckBox) convertView.findViewById(R.id.selected_check); if (isSelected) { vh.selected_check.setVisibility(View.VISIBLE); vh.me_linearlayout_addfriend.setVisibility(View.GONE); } else { vh.selected_check.setVisibility(View.GONE); vh.me_linearlayout_addfriend.setVisibility(View.VISIBLE); } convertView.setTag(vh); } else { vh = (ViewHolder) convertView.getTag(); } ConteactMode mode = friendList.get(pos); vh.icon_imageView.setTag(mode); vh.addMsg_textview.setTag(mode); vh.text_msg_phone.setTag(mode); vh.text_msg_chat.setTag(mode); vh.selected_check.setChecked(mode.selectedState); // vh.name_textview.setText(mode.getName()); vh.addMsg_textview.setVisibility(View.GONE); vh.text_msg_phone.setVisibility(View.GONE); vh.text_msg_chat.setVisibility(View.GONE); vh.icon_imageView_add.setVisibility(View.GONE); String name = mode.getName(); if (mode.getInstall().equalsIgnoreCase("1")) { // name = name + "(已安装)"; // 已安装的用户 // vh.me_linearlayout_addfriend // .setOnClickListener(new MySendMsgClickListener(mode)); if (!mode.Account.equals(ConstantPool.getInstance().USER_ACCOUNT)) { vh.text_msg_chat.setVisibility(View.VISIBLE); vh.text_msg_chat.setOnClickListener(new MySendMsgClickListener(mode)); // vh.addMsg_textview.setText("发消息"); // // vh.addMsg_textview.setTextColor(mContext.getResources().getColor( // R.color.me_addfriend)); // 是自己,隐藏发消息的按钮 // vh.addMsg_textview.setVisibility(View.GONE); } } else { name = name + "(未安装)"; vh.addMsg_textview.setVisibility(View.VISIBLE); vh.addMsg_textview.setText("邀请"); vh.addMsg_textview.setTextColor(mContext.getResources().getColor(R.color.me_addfriend)); // String sms_body = "您好," // + mode.name // + // ",我在使用“海航通”交流工作,和同事发文字、语音、图片,方便极了。你也一起来吧,下载地址:http://mobilehnasis.hnair.com/apps/jjrs.html#mp.weixin.qq.com,记得安装后加我:" // + ConstantPool.getInstance().USER_ACCOUNT_NAME; // String sms_body = mContext.getResources().getString(R.string.me_invite_content) // + ConstantPool.getInstance().USER_ACCOUNT_NAME; String sms_body = String.format( mContext.getResources().getString(R.string.me_invite_content), ConstantPool.getInstance().USER_ACCOUNT_NAME); vh.addMsg_textview.setOnClickListener( new MyInviteClickListener(mode.Account, mode.phoneNumber, sms_body)); } if (!TextUtils.isEmpty(mode.getPhoneNumber()) && !mode.Account.equals(ConstantPool.getInstance().USER_ACCOUNT)) { vh.text_msg_phone.setVisibility(View.VISIBLE); vh.text_msg_phone.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { Object object = v.getTag(); if (object != null && object instanceof ConteactMode) { ConteactMode conteactMode = (ConteactMode) object; // Intent intent = // IntentUtil.getPhoneDialIntent(conteactMode.getPhoneNumber()); // mContext.startActivity(intent); ProjectUtil.selectCall(mContext, conteactMode.getPhoneNumber(), false); } } }); } if (!StringUtil.isEmpty(name)) { vh.name_textview.setText(name); } vh.level_textview.setText(mode.getDepartment() + " " + mode.getLevel()); // 现在的版本搜索界面只判断是否安装 /* * String state = mode.getState(); if (!StringUtil.isEmpty(state)) { // * 我发起的请求信息 if (state.equals("添加")) { // 点击添加好友 * vh.icon_imageView_add.setVisibility(View.VISIBLE); * vh.addMsg_textview.setText(mContext.getResources().getString( * R.string.me_add_text)); * vh.addMsg_textview.setTextColor(mContext.getResources() * .getColor(R.color.me_addfriend)); vh.me_linearlayout_addfriend * .setOnClickListener(new MyClickListener( vh.addMsg_textview, * vh.icon_imageView_add, mode)); } else if (state.equals("验证")) { // * 别人发的添加信息 vh.addMsg_textview.setText("通过验证"); * vh.icon_imageView_add.setVisibility(View.GONE); * vh.addMsg_textview.setTextColor(mContext.getResources() * .getColor(R.color.me_addfriend)); // 通过 vh.me_linearlayout_addfriend * .setOnClickListener(new MyPassClickListener(friendList, mode, "通过", * pos)); // // //拒绝 // * vh.me_textview_addfriend_pass.setOnClickListener(new // * OnClickListener() { // // @Override // public void onClick(View v) { * // ConteactMode mode = (ConteactMode) v.getTag(); // * AddValidation(mode.Userid,"拒绝"); // } // }); } else if * (state.equals("等待验证")) { vh.addMsg_textview.setText("验证中"); * vh.addMsg_textview.setTextColor(mContext.getResources() * .getColor(R.color.color_lightgrey)); * vh.icon_imageView_add.setVisibility(View.GONE); } else if * (state.equals("已添加")) { vh.addMsg_textview.setText("已添加"); * vh.addMsg_textview.setTextColor(mContext.getResources() * .getColor(R.color.color_lightgrey)); * vh.icon_imageView_add.setVisibility(View.GONE); } } */ // 下载图片 String midUrl = ProjectUtil.getBigPic(mode.image); ImageLoader.loadHeadImage((BaseActivity) mContext, vh.icon_imageView, midUrl); return convertView; }