コード例 #1
0
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
          if (convertView == null) {
            convertView =
                mInflater.inflate(R.layout.fragment_message_user_list_item, parent, false);
            holder = new ViewHolder();
            holder.icon = (ImageView) convertView.findViewById(R.id.icon);
            holder.icon.setFocusable(false);
            holder.title = (TextView) convertView.findViewById(R.id.title);
            holder.content = (TextView) convertView.findViewById(R.id.comment);
            holder.time = (TextView) convertView.findViewById(R.id.time);
            holder.badge = (BadgeView) convertView.findViewById(R.id.badge);
            holder.badge.setFocusable(false);
            convertView.setTag(holder);
          } else {
            holder = (ViewHolder) convertView.getTag();
          }

          Message.MessageObject user = (Message.MessageObject) getItem(position);
          iconfromNetwork(holder.icon, user.friend.avatar);
          holder.title.setText(user.friend.name);
          holder.content.setText(
              Global.recentMessage(user.content, myImageGetter, Global.tagHandler));
          holder.time.setText(Global.dayToNow(user.created_at));

          if (user.unreadCount > 0) {
            UnreadNotify.displayNotify(holder.badge, Unread.countToString(user.unreadCount));
            holder.badge.setVisibility(View.VISIBLE);
          } else {
            holder.badge.setVisibility(View.INVISIBLE);
          }

          if (position == (mData.size() - 1)) {
            loadMore();
          }

          return convertView;
        }
コード例 #2
0
  @Override
  public void parseJson(int code, JSONObject respanse, String tag, int pos, Object data)
      throws JSONException {
    if (tag.equals(HOST_MESSAGE_USERS)) {
      setRefreshing(false);
      if (code == 0) {
        if (mUpdateAll) {
          mUpdateAll = false;
          mData.clear();
        }

        JSONArray jsonArray = respanse.getJSONObject("data").getJSONArray("list");
        for (int i = 0; i < jsonArray.length(); ++i) {
          Message.MessageObject messageObject =
              new Message.MessageObject(jsonArray.getJSONObject(i));
          mData.add(messageObject);
        }
        AccountInfo.saveMessageUsers(getActivity(), mData);

        adapter.notifyDataSetChanged();

        if (isLoadingFirstPage(tag)) {
          mFootUpdate.dismiss();
        } else {
          mFootUpdate.showLoading();
        }
        //                BlankViewDisplay.setBlank(mData.size(), UsersListFragment.this, true,
        // blankLayout);

      } else {
        showErrorMsg(code, respanse);
        if (mData.size() > 0) {
          mFootUpdate.showFail();
        } else {
          mFootUpdate.dismiss(); // 显示猴子照片
        }
        //                BlankViewDisplay.setBlank(mData.size(), UsersListFragment.this, false,
        // blankLayout, onClickRetry);
      }

      mUpdateAll = false;

    } else if (tag.equals(HOST_UNREAD_AT)) {
      if (code == 0) {
        int count = respanse.getInt("data");
        UnreadNotify.displayNotify(badgeAt, Unread.countToString(count));
      }

    } else if (tag.equals(HOST_UNREAD_COMMENT)) {
      if (code == 0) {
        int count = respanse.getInt("data");
        UnreadNotify.displayNotify(badgeComment, Unread.countToString(count));
      }

    } else if (tag.equals(HOST_UNREAD_SYSTEM)) {
      if (code == 0) {
        int count = respanse.getInt("data");
        UnreadNotify.displayNotify(badgeSystem, Unread.countToString(count));
      }

    } else if (tag.equals(HOST_MARK_AT)) {
      if (code == 0) {
        UnreadNotify.displayNotify(badgeAt, Unread.countToString(0));
        UnreadNotify.update(getActivity());
      }

    } else if (tag.equals(HOST_MARK_COMMENT)) {
      if (code == 0) {
        UnreadNotify.displayNotify(badgeComment, Unread.countToString(0));
        UnreadNotify.update(getActivity());
      }

    } else if (tag.equals(HOST_MARK_SYSTEM)) {
      if (code == 0) {
        UnreadNotify.displayNotify(badgeSystem, Unread.countToString(0));
        UnreadNotify.update(getActivity());
      }

    } else if (tag.equals(HOST_MARK_MESSAGE)) {
      if (code == 0) {
        mData.get(pos).unreadCount = 0;
        adapter.notifyDataSetChanged();
      }
    } else if (tag.equals(TAG_DELETE_MESSAGE)) {
      Message.MessageObject msg = (Message.MessageObject) data;
      if (code == 0) {
        deleteItem(msg);
      } else {
        showButtomToast("删除失败");
      }
    }
  }