示例#1
0
 @Override
 public View getView(int position, View view, ViewGroup arg2) {
   ViewHolder viewHolder;
   if (view == null) {
     viewHolder = new ViewHolder();
     view = getLayoutInflater().inflate(R.layout.item_traderesult, null);
     viewHolder.title = (TextView) view.findViewById(R.id.product_title);
     viewHolder.time = (TextView) view.findViewById(R.id.product_time);
     viewHolder.status = (TextView) view.findViewById(R.id.product_status);
     viewHolder.product_status = (TextView) view.findViewById(R.id.product_trade_status);
     viewHolder.money = (TextView) view.findViewById(R.id.product_money);
     view.setTag(viewHolder);
   } else {
     viewHolder = (ViewHolder) view.getTag();
   }
   JSONObject item = getItem(position);
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   viewHolder.time.setText(sdf.format(item.optLong("tradeTime")));
   if (item.optString("tradeStatus").equals("0")) {
     viewHolder.status.setText("交易中");
   } else if (item.optString("tradeStatus").equals("1")) {
     viewHolder.status.setText("成功");
   } else {
     viewHolder.status.setText("失败");
   }
   viewHolder.product_status.setText(item.optString("tradeType"));
   viewHolder.title.setText(item.optString("proName"));
   viewHolder.money.setText(
       Html.fromHtml("<font color=#ff0000>" + item.optString("tradeMoney") + "</font>" + "元"));
   return view;
 }
示例#2
0
    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
      View view = LayoutInflater.from(context).inflate(R.layout.user_row, null);
      ViewHolder holder = new ViewHolder();
      holder.avatar = (ImageView) view.findViewById(R.id.avatar);
      holder.avatarIndex = cursor.getColumnIndex(AVATAR);
      holder.nick = (TextView) view.findViewById(R.id.nick);
      holder.nickIndex = cursor.getColumnIndex(NICK);
      holder.status = (TextView) view.findViewById(R.id.status);
      holder.statusIndex = cursor.getColumnIndex(STATUS);

      view.setTag(holder);
      return view;
    }
    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
      LayoutInflater li =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      ViewHolder vh = new ViewHolder();
      View view = li.inflate(R.layout.xbl_friend_of_friend_list_item, parent, false);
      view.setTag(vh);

      vh.gamertag = (TextView) view.findViewById(R.id.friend_gamertag);
      vh.gamerscore = (TextView) view.findViewById(R.id.friend_gp);
      vh.avatarIcon = (ImageView) view.findViewById(R.id.friend_avatar_icon);
      vh.status = (TextView) view.findViewById(R.id.friend_status);
      vh.titleIcon = (ImageView) view.findViewById(R.id.friend_title);

      return view;
    }
    public View getView(int position, View convertView, ViewGroup parent) {

      View sv = null;

      // get data
      connectionInfo item = data.get(position);

      // prepare view
      if (convertView == null) {

        sv = (View) itemInflater.inflate(R.layout.ui_connection_item, parent, false);

        holder = new ViewHolder();
        holder.type = ((TextView) sv.findViewById(R.id.id_connection_type));
        holder.src = ((TextView) sv.findViewById(R.id.id_connection_src));
        holder.dst = ((TextView) sv.findViewById(R.id.id_connection_dst));
        holder.owner = ((TextView) sv.findViewById(R.id.id_connection_owner));
        holder.status = ((TextView) sv.findViewById(R.id.id_connection_status));

        sv.setTag(holder);
      } else {
        sv = (View) convertView;
        holder = (ViewHolder) sv.getTag();
      }

      // draw current color for each item
      if (position % 2 == 0)
        sv.setBackgroundColor(getResources().getColor(R.color.dkgrey_osmonitor));
      else sv.setBackgroundColor(getResources().getColor(R.color.black_osmonitor));

      // prepare main information
      switch (item.getType().getNumber()) {
        case connectionInfo.connectionType.TCPv4_VALUE:
          holder.type.setText("TCP4");
          break;
        case connectionInfo.connectionType.TCPv6_VALUE:
          holder.type.setText("TCP6");
          break;
        case connectionInfo.connectionType.UDPv4_VALUE:
          holder.type.setText("UDP4");
          break;
        case connectionInfo.connectionType.UDPv6_VALUE:
          holder.type.setText("UDP6");
          break;
        case connectionInfo.connectionType.RAWv4_VALUE:
          holder.type.setText("RAW4");
          break;
        case connectionInfo.connectionType.RAWv6_VALUE:
          holder.type.setText("RAW6");
          break;
      }

      holder.src.setText(convertFormat(item.getLocalIP(), item.getLocalPort()));
      holder.dst.setText(convertFormat(item.getRemoteIP(), item.getRemotePort()));

      switch (item.getStatus().getNumber()) {
        case connectionInfo.connectionStatus.CLOSE_VALUE:
          holder.status.setText("CLOSE");
          break;
        case connectionInfo.connectionStatus.CLOSE_WAIT_VALUE:
          holder.status.setText("CLOSE_WAIT");
          break;
        case connectionInfo.connectionStatus.CLOSING_VALUE:
          holder.status.setText("CLOSING");
          break;
        case connectionInfo.connectionStatus.ESTABLISHED_VALUE:
          holder.status.setText("ESTABLISHED");
          break;
        case connectionInfo.connectionStatus.FIN_WAIT1_VALUE:
          holder.status.setText("FIN_WAIT1");
          break;
        case connectionInfo.connectionStatus.FIN_WAIT2_VALUE:
          holder.status.setText("FIN_WAIT2");
          break;
        case connectionInfo.connectionStatus.LAST_ACK_VALUE:
          holder.status.setText("LAST_ACK");
          break;
        case connectionInfo.connectionStatus.LISTEN_VALUE:
          holder.status.setText("LISTEN");
          break;
        case connectionInfo.connectionStatus.SYN_RECV_VALUE:
          holder.status.setText("SYN_RECV");
          break;
        case connectionInfo.connectionStatus.SYN_SENT_VALUE:
          holder.status.setText("SYN_SENT");
          break;
        case connectionInfo.connectionStatus.TIME_WAIT_VALUE:
          holder.status.setText("TIME_WAIT");
          break;
        case connectionInfo.connectionStatus.UNKNOWN_VALUE:
          holder.status.setText("UNKNOWN");
          break;
      }

      if (item.getUid() == 0) holder.owner.setText("System");
      else if (map.containsKey(item.getUid())) holder.owner.setText(map.get(item.getUid()));
      else holder.owner.setText(item.getUid() + "(UID)");

      return sv;
    }
示例#5
0
  @Override
  public View getView(final int arg0, View arg1, ViewGroup arg2) {
    ViewHolder viewHolder;
    if (arg1 == null) {
      arg1 = inflater.inflate(R.layout.guess_list_item_view_new, null);
      viewHolder = new ViewHolder();
      viewHolder.status = (TextView) arg1.findViewById(R.id.status);
      viewHolder.statusImg = (ImageView) arg1.findViewById(R.id.img_guess_status_flag);
      viewHolder.allScore = (TextView) arg1.findViewById(R.id.allScore);
      viewHolder.title = (TextView) arg1.findViewById(R.id.guess_title);
      viewHolder.guessPartyTerm = (TextView) arg1.findViewById(R.id.guess_party_term);
      arg1.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) arg1.getTag();
    }
    if (ListItemRecord != null) {
      final WholeGuessItem newsListItem = ListItemRecord.get(arg0);
      if (newsListItem != null) {
        // changed by vincent
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (newsListItem.getStatus() == 3) {
          viewHolder.status.setText(getStatusText(newsListItem.getStatus()));
        } else {
          try {
            Date beginDate = format.parse(newsListItem.getDate());
            Date endDate = format.parse(newsListItem.getEndDate());
            Date nowDate = format.parse(newsListItem.getNowTime());
            long millis0 = beginDate.getTime() - nowDate.getTime();
            long millis1 = endDate.getTime() - nowDate.getTime();

            if (millis0 < 0 && millis1 > 0 || millis0 == 0) { // 进行中
              viewHolder.status.setText("剩:" + TimeUtils.getCountDownTime(millis1));
              viewHolder.status.setTextColor(context.getResources().getColor(R.color.dark_purple));
              viewHolder.statusImg.setImageResource(R.drawable.img_guess_flag_being);
              viewHolder.allScore.setTextColor(context.getResources().getColor(R.color.red_text));
            } else if (newsListItem.getStatus() == GuessParty.NO_OPEN_LOTTERY) { // 待公布
              viewHolder.status.setTextColor(context.getResources().getColor(R.color.dark_purple));
              viewHolder.status.setText(getStatusText(GuessParty.NO_OPEN_LOTTERY));
              viewHolder.statusImg.setImageResource(R.drawable.img_guess_flag_todeclare);
              viewHolder.allScore.setTextColor(
                  context.getResources().getColor(R.color.yellow_text));
            } else if (newsListItem.getStatus() == GuessParty.OPEN_LOTTERY) { // 已开奖
              viewHolder.status.setTextColor(context.getResources().getColor(R.color.light_purple));
              viewHolder.status.setText(getStatusText(GuessParty.OPEN_LOTTERY));
              viewHolder.statusImg.setImageResource(R.drawable.img_guess_flag_underline);
              viewHolder.allScore.setTextColor(
                  context.getResources().getColor(R.color.light_purple));
            } else if (newsListItem.getStatus() == GuessParty.INVALID_LOTTERY) { // 已截止
              viewHolder.status.setTextColor(context.getResources().getColor(R.color.light_purple));
              viewHolder.status.setText(getStatusText(GuessParty.INVALID_LOTTERY));
              viewHolder.statusImg.setImageResource(R.drawable.img_guess_flag_underline);
              viewHolder.allScore.setTextColor(
                  context.getResources().getColor(R.color.light_purple));
            } else {
              viewHolder.status.setTextColor(context.getResources().getColor(R.color.dark_purple));
              viewHolder.status.setText(getStatusText(GuessParty.NO_OPEN_LOTTERY)); // 待公布
              viewHolder.statusImg.setImageResource(R.drawable.img_guess_flag_todeclare);
              viewHolder.allScore.setTextColor(
                  context.getResources().getColor(R.color.yellow_text));
            }
          } catch (ParseException e) {
            e.printStackTrace();
          }
        }

        viewHolder.title.setTextSize(16);
        viewHolder.title.setText(newsListItem.getSchemaName());
        viewHolder.guessPartyTerm.setText(String.valueOf(newsListItem.getTerm()) + "期");
        viewHolder.allScore.setText(newsListItem.getAllScore());
      }
    }
    arg1.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            Bundle bundle = new Bundle();

            bundle.putInt("status", ListItemRecord.get(arg0).getStatus());
            bundle.putString("schema_name", ListItemRecord.get(arg0).getSchemaName());
            bundle.putString("schema_id", ListItemRecord.get(arg0).getSchemaId());
            bundle.putInt("listDataType", 0);
            intent.putExtras(bundle);
            intent.setClass(context, GuessParty.class);
            context.startActivity(intent);
          }
        });
    return arg1;
  }