private View getHalfTheAudienceAgainstListItemView( final HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation, final int index) { View itemView = LayoutInflater.from(context).inflate(R.layout.buy_jc_main_listview_item_others, null); /** add by yejc 20130823 start */ final LinearLayout layout = (LinearLayout) itemView.findViewById(R.id.jc_play_detail_layout); View divider = (View) itemView.findViewById(R.id.jc_main_divider_up); if (index == 0) { divider.setVisibility(View.VISIBLE); } else { divider.setVisibility(View.GONE); } /** add by yejc 20130823 end */ // 联赛名称 TextView leagueTextView = (TextView) itemView.findViewById(R.id.game_name); leagueTextView.setText(halfTheAudienceAgainstInformation.getLeague()); // 比赛时间 TextView gameDateTextView = (TextView) itemView.findViewById(R.id.game_date); StringBuffer gameDate = new StringBuffer(); gameDate .append("编号:") .append(halfTheAudienceAgainstInformation.getTeamId()) .append("\n") .append(PublicMethod.getEndTime(halfTheAudienceAgainstInformation.getEndTime())) .append("(截)"); gameDateTextView.setText(gameDate); // 主队 TextView homeTeamTextView = (TextView) itemView.findViewById(R.id.home_team_name); homeTeamTextView.setText(halfTheAudienceAgainstInformation.getHomeTeam()); // VS TextView vsTextView = (TextView) itemView.findViewById(R.id.game_vs); // 客队 TextView guestTeamTextView = (TextView) itemView.findViewById(R.id.guest_team_name); guestTeamTextView.setText(halfTheAudienceAgainstInformation.getGuestTeam()); // 胆 final Button danTextButton = (Button) itemView.findViewById(R.id.game_dan); if (halfTheAudienceAgainstInformation.isDan()) { danTextButton.setBackgroundResource(R.drawable.jc_btn_b); danTextButton.setTextColor(white); } else { danTextButton.setBackgroundResource(android.R.color.transparent); danTextButton.setTextColor(black); } danTextButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (halfTheAudienceAgainstInformation.isDan()) { halfTheAudienceAgainstInformation.setDan(false); danTextButton.setBackgroundResource(android.R.color.transparent); danTextButton.setTextColor(black); } else { if (isSelectDanLegal()) { halfTheAudienceAgainstInformation.setDan(true); danTextButton.setBackgroundResource(R.drawable.jc_btn_b); danTextButton.setTextColor(white); } } ((BeiJingSingleGameActivity) context).refreshSelectNumAndDanNum(); } private boolean isSelectDanLegal() { if (halfTheAudienceAgainstInformation.getClickNum() > 0) { int selectDanNum = getSelectDanNum(); if (selectDanNum < MAX_DAN) { int selectedTeamNum = getSelectedTeamNum(); if (selectedTeamNum < 3) { Toast.makeText(context, "请您至少选择3场比赛,才能设胆", Toast.LENGTH_SHORT).show(); return false; } else if (selectDanNum < (selectedTeamNum - 2)) { return true; } else { Toast.makeText( context, "胆码不能超过" + (selectedTeamNum - 2) + "个", Toast.LENGTH_SHORT) .show(); return false; } } else { Toast.makeText(context, "您最多可以选择" + MAX_DAN + "场比赛进行设胆!", Toast.LENGTH_SHORT) .show(); return false; } } else { return false; } } private int getSelectedTeamNum() { int selectTeamNum = 0; for (int list_i = 0; list_i < halfTheAudienceAgainstInformationList.size(); list_i++) { List<HalfTheAudienceAgainstInformation> halfTheAudienceAgainstInformations = halfTheAudienceAgainstInformationList.get(list_i); for (int list_j = 0; list_j < halfTheAudienceAgainstInformations.size(); list_j++) { HalfTheAudienceAgainstInformation hahalfTheAudienceAgainstInformation = halfTheAudienceAgainstInformations.get(list_j); if (hahalfTheAudienceAgainstInformation.getClickNum() > 0) { selectTeamNum++; } } } return selectTeamNum; } private int getSelectDanNum() { int selectDanNum = 0; for (int list_i = 0; list_i < halfTheAudienceAgainstInformationList.size(); list_i++) { List<HalfTheAudienceAgainstInformation> halfTheAudienceAgainstInformations = halfTheAudienceAgainstInformationList.get(list_i); for (int list_j = 0; list_j < halfTheAudienceAgainstInformations.size(); list_j++) { HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation = halfTheAudienceAgainstInformations.get(list_j); if (halfTheAudienceAgainstInformation.isDan()) { selectDanNum++; } } } return selectDanNum; } }); // 投注按钮 Button bettingButton = (Button) itemView.findViewById(R.id.jc_main_list_item_button); bettingButton.setTag(halfTheAudienceAgainstInformation); bettingButton.setEllipsize(TextUtils.TruncateAt.END); StringBuilder selectedString = new StringBuilder(); boolean[] isClicks = halfTheAudienceAgainstInformation.getIsClicks(); for (int button_i = 0; button_i < SELECT_BUTTON_NUM; button_i++) { if (isClicks[button_i] == true) { selectedString.append(selectButtonTitles[button_i]).append(" "); } } if (selectedString.length() != 0) { bettingButton.setText(selectedString.toString()); } else { bettingButton.setText(""); } bettingButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (((BeiJingSingleGameActivity) context).isSelectedEventNumLegal() || halfTheAudienceAgainstInformation.isSelected()) { createHalfTheAudienceSelectDialog(v, layout, index); } else { Toast.makeText(context, "您最多可以选择10场比赛进行投注!", Toast.LENGTH_SHORT).show(); } } }); // 析 TextView analysisTextView = (TextView) itemView.findViewById(R.id.game_analysis); analysisTextView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { trunExplain(getEvent(halfTheAudienceAgainstInformation)); } }); return itemView; }
private View getHalfTheAudienceAgainstListItemView( final HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation) { View itemView = LayoutInflater.from(context).inflate(R.layout.buy_jc_main_listview_item_others, null); // 联赛名称 TextView leagueTextView = (TextView) itemView.findViewById(R.id.game_name); leagueTextView.setText(halfTheAudienceAgainstInformation.getLeague()); // 比赛时间 TextView gameDateTextView = (TextView) itemView.findViewById(R.id.game_date); StringBuffer gameDate = new StringBuffer(); gameDate .append("编号:") .append(halfTheAudienceAgainstInformation.getTeamId()) .append("\n") .append(halfTheAudienceAgainstInformation.getEndTime()) .append("(截)"); gameDateTextView.setText(gameDate); // 主队 TextView homeTeamTextView = (TextView) itemView.findViewById(R.id.home_team_name); homeTeamTextView.setText(halfTheAudienceAgainstInformation.getHomeTeam()); // VS TextView vsTextView = (TextView) itemView.findViewById(R.id.game_vs); // 客队 TextView guestTeamTextView = (TextView) itemView.findViewById(R.id.guest_team_name); guestTeamTextView.setText(halfTheAudienceAgainstInformation.getGuestTeam()); // 投注按钮 Button bettingButton = (Button) itemView.findViewById(R.id.jc_main_list_item_button); bettingButton.setTag(halfTheAudienceAgainstInformation); bettingButton.setEllipsize(TextUtils.TruncateAt.END); StringBuilder selectedString = new StringBuilder(); boolean[] isClicks = halfTheAudienceAgainstInformation.getIsClicks(); for (int button_i = 0; button_i < SELECT_BUTTON_NUM; button_i++) { if (isClicks[button_i] == true) { selectedString.append(selectButtonTitles[button_i]).append(" "); } } if (selectedString.length() != 0) { bettingButton.setText(selectedString.toString()); } else { bettingButton.setText(""); } bettingButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (((BeiJingSingleGameActivity) context).isSelectedEventNumLegal() || halfTheAudienceAgainstInformation.isSelected()) { createHalfTheAudienceSelectDialog(v); } else { Toast.makeText(context, "您最多可以选择10场比赛进行投注!", Toast.LENGTH_SHORT).show(); } } }); /** close by yejc 20130514 start */ // // 析 // TextView analysisTextView = (TextView) itemView // .findViewById(R.id.game_analysis); // analysisTextView.setVisibility(View.GONE); // // 胆 // Button danTextButton = (Button) itemView.findViewById(R.id.game_dan); // danTextButton.setVisibility(View.GONE); /** close by yejc 20130514 end */ /** add by yejc 20130514 start */ LinearLayout analysisAndDanLayout = (LinearLayout) itemView.findViewById(R.id.linearLayout3); analysisAndDanLayout.setVisibility(View.GONE); /** add by yejc 20130514 end */ return itemView; }