@Override public void handleMessage(Message message) { if (message.what == 1) { // 更新头像 mAdapter.notifyDataSetChanged(); } else if (message.what == 2) { // 更新图片 HLog.out(TAG, "message.what:" + message.what); mAdapter.notifyDataSetChanged(); } else if (message.what == 10) { // 更新评论 Bundle bundle = message.getData(); Comment xComment = new Comment(); xComment.setR_id(bundle.getInt("nid")); xComment.setUser_id(mUser.getUid()); xComment.setText(bundle.getString("comment")); xComment.setAdd_Time(Integer.parseInt(bundle.getString("time"))); xComment.setNickname(mUser.getNickname()); xComment.setHead_pic(bundle.getString("head_pic")); ArrayList<Comment> cm = data.get(bundle.getInt("position")).getBcomment(); if (cm == null) { cm = new ArrayList<Comment>(); } cm.add(xComment); data.get(bundle.getInt("position")).setBcomment(cm); data.get(bundle.getInt("position")).setI_comment(true); mAdapter.notifyDataSetChanged(); Utils.Toast(mActivity, "温馨提示:", "评论成功!"); } else if (message.what == 1002) { mAdapter.notifyDataSetChanged(); } }
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.find_sqqz_list); ViewUtils.inject(this); mActivity = this; data = new ArrayList<NoticeItem>(); mBitmapUtils = new BitmapUtils(mActivity); data = new ArrayList<NoticeItem>(); mUser = DbOperation.getUser(mActivity); if (mUser == null) { Utils.Toast(mActivity, "温馨提示:", "登录已过期,请重新登录!"); Utils.goToUserLogin(mActivity); } if (data.size() == 0) { myProgressDialog = new MyProgressDialog(mActivity, "加载数据中...", false); myProgressDialog.show(); loadingData(); // 加载数据 } mPullRefreshListView.setMode(Mode.PULL_UP_TO_REFRESH); mPullRefreshListView.setOnRefreshListener( new OnRefreshListener<ListView>() { @Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { String label = DateUtils.formatDateTime( mActivity, System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); if (mPullRefreshListView.isFooterShown()) { refreshView.getLoadingLayoutProxy().setLastUpdatedLabel("加载更多"); loadingData(); } } }); ListView actualListView = mPullRefreshListView.getRefreshableView(); registerForContextMenu(actualListView); mAdapter = new MyAdapter(); actualListView.setAdapter(mAdapter); }
@Override public View getView(final int position, View convertView, ViewGroup parent) { image.clear(); final NoticeVolhead volhead; if (convertView == null) { convertView = LayoutInflater.from(mActivity).inflate(R.layout.find_sqqz_list_item, null); volhead = new NoticeVolhead(); volhead.linerlayout = (LinearLayout) convertView.findViewById(R.id.my_center_notice_linerlayout); volhead.img = (CircleImageView) convertView.findViewById(R.id.img); volhead.label = (TextView) convertView.findViewById(R.id.label); volhead.Show_nike = (TextView) convertView.findViewById(R.id.Show_nike); volhead.content = (TextView) convertView.findViewById(R.id.content); volhead.iLayout = (LinearLayout) convertView.findViewById(R.id.index_show_img_list); volhead.nei_image_list = (MyGridView) convertView.findViewById(R.id.my_center_notice_detail_image_list); volhead.nei_praise_image = (ImageView) convertView.findViewById(R.id.nei_praise_image); volhead.nei_praise_text = (TextView) convertView.findViewById(R.id.nei_praise_text); volhead.nei_praise_list = (TextView) convertView.findViewById(R.id.nei_praise_list); volhead.nei_comment_text = (TextView) convertView.findViewById(R.id.nei_comment_text); volhead.nei_comment_image = (ImageView) convertView.findViewById(R.id.nei_comment_image); volhead.nei_comment_list = (ListView) convertView.findViewById(R.id.nei_comment_list); volhead.delete = (TextView) convertView.findViewById(R.id.delete); convertView.setTag(volhead); } else { volhead = (NoticeVolhead) convertView.getTag(); } volhead.linerlayout.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub NoticeItem item = new NoticeItem(); item = data.get(position); Intent intent = new Intent(); intent.setClass(mActivity, FindSqhdListDetails.class); Bundle bundle = new Bundle(); bundle.putSerializable("NoticeItem", item); intent.putExtras(bundle); HView.gotoActivity(mActivity, intent); } }); if (data.get(position).getImg() != null && !"".equals(data.get(position).getImg())) { // 头像缓存到本地 HHttp.getImage( mActivity, data.get(position).getImg(), data.get(position).getUser_Id(), handler_head); volhead.img.setImageURI( Uri.parse( Constant.ROOTPATH + Constant.HEADIMG + "H_" + data.get(position).getUser_Id() + ".jpg")); } else { volhead.img.setImageDrawable(getResources().getDrawable(R.drawable.app_logo)); } String time = data.get(position).getAddtime() + "000"; volhead.label.setText( data.get(position).getLabel() + " " + Utils.getFormatDateTime(Long.parseLong(time), "yyyy.MM.dd")); volhead.Show_nike.setText( data.get(position).getShow_nike().length() > 6 ? data.get(position).getShow_nike().substring(0, 6) + "*" : data.get(position).getShow_nike()); // 设置 内容, volhead.content.setText(data.get(position).getContent()); neiImageAdapter = new NeiImageAdapter(); volhead.nei_image_list.setAdapter(neiImageAdapter); image = new ArrayList<String>(); // 设置图片列表显示 if (data.get(position).getImage() != null) { for (String s : data.get(position).getImage()) { image.add(s); } } neiImageAdapter.notifyDataSetChanged(); volhead.nei_image_list.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { ArrayList<String> PushImg = new ArrayList<String>(); for (String s : data.get(position).getImage()) { PushImg.add(s); } Intent i = new Intent(mActivity, ShowBigPhotoList.class); i.putStringArrayListExtra("ImgData", (ArrayList<String>) PushImg); i.putExtra("index", arg2); HView.gotoActivity(mActivity, i); } }); mPraise = data.get(position).getPraise(); // 设置点赞数 /*if (mPraise != null) { if (data.get(position).getI_Praise()) { volhead.nei_praise_image.setImageDrawable(getResources() .getDrawable(R.drawable.praise_on)); } int len = mPraise.size(); volhead.nei_praise_text.setText(len + ""); } else { volhead.nei_praise_text.setText("0"); volhead.nei_praise_image.setImageDrawable(getResources() .getDrawable(R.drawable.praise)); }*/ // mComment = data.get(position).getBcomment(); // 设置评论数 /*if (mComment != null) { if (data.get(position).getI_comment()) { volhead.nei_comment_image.setImageDrawable(getResources() .getDrawable(R.drawable.comment_on)); } int len = mComment.size(); volhead.nei_comment_text.setText(len + ""); } else { volhead.nei_comment_image.setImageDrawable(getResources() .getDrawable(R.drawable.comment)); volhead.nei_comment_text.setText("0"); } */ volhead.delete.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub DELETEPOSITION = position; DELETEID = data.get(position).getId(); delDialog = new ShowConfirmDelDialog(mActivity, data.get(position).getId(), listener); delDialog.show(); } }); return convertView; }