Пример #1
0
 /** Создаёт новую кнопку элемента меню */
 View newView(MenuEntry ent) {
   Button btn = new Button(st.c());
   int pad = (int) st.floatDp(10, st.c());
   if (st.kv().isDefaultDesign()) {
     btn.setBackgroundDrawable(st.kv().m_drwKeyBack.mutate());
   } else {
     try {
       RectShape clon = st.kv().m_curDesign.m_keyBackground.clone();
       btn.setBackgroundDrawable(((GradBack) clon).getStateDrawable());
     } catch (Throwable e) {
       // TODO: handle exception
     }
   }
   //        setButtonKeyboardBackground(btn);
   btn.setHeight(st.kv().m_KeyHeight);
   btn.setTextColor(st.paint().mainColor);
   if (st.has(m_state, STAT_TEMPLATES) || st.has(m_state, STAT_CLIPBOARD)) {
     btn.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
     btn.setLongClickable(true);
     btn.setOnLongClickListener(m_longListener);
   }
   btn.setMaxLines(1);
   btn.setEllipsize(TruncateAt.MARQUEE);
   btn.setPadding(pad, pad, pad, pad);
   btn.setTag(ent);
   btn.setText(ent.text);
   btn.setOnClickListener(m_listener);
   return btn;
 }
Пример #2
0
 private void generateButton(Object o, String name, String key) {
   if (name == null || name.length() < key.length()) {
     return;
   }
   String newStr = name.substring(0, key.length());
   if (!newStr.toUpperCase().equals(key.toUpperCase())) {
     return;
   }
   Button button = new Button(getContext());
   button.setEllipsize(TruncateAt.END);
   button.setText(name);
   LinearLayout.LayoutParams params =
       new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
   button.setLayoutParams(params);
   payees_layout.addView(button);
   button.setOnClickListener(this);
   button.setTag(o);
 }
  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;
  }