示例#1
0
  void calculateGPA() {
    if (list == null) return;

    double total_credit_point = 0;
    double total_credit = 0;

    for (GoalModel g : (List<GoalModel>) list) {
      double credit = Double.parseDouble(g.getCredit());
      double grade_point = Double.parseDouble(g.getGrade_point());
      total_credit += credit;
      total_credit_point += (double) credit * grade_point;
    }

    // 一学期(学年)的平均绩点=该学期(学年)全部学分绩点之和÷该学期(学年)所修学分之和
    double gpa = (double) total_credit_point / total_credit;
    showGPAInformation(gpa, total_credit_point);
  }
示例#2
0
  @Override
  protected void convert(final BaseAdapterHelper baseAdapterHelper, GoalModel goalModel) {

    try {
      // check the lesson if restudy;
      int point = 0;
      if (goalModel.getFlag_restudy().trim().equals("")) {
        point = goalModel.getGoal() == null ? 0 : Integer.valueOf(goalModel.getGoal());
        baseAdapterHelper.setText(
            R.id.tv_lable_goal, context.getString(R.string.listitem_lable_goal));
      } else {
        point =
            goalModel.getGoal_restudy() == null ? 0 : Integer.valueOf(goalModel.getGoal_restudy());
        baseAdapterHelper.setText(
            R.id.tv_lable_goal, context.getString(R.string.listitem_lable_restudygoal));
      }

      // check the goal whether failed or not
      if (point < 60) {
        baseAdapterHelper
            .getView(R.id.tv_classname)
            .setBackgroundColor(context.getResources().getColor(R.color.goal_item_failed_color));
      } else {
        baseAdapterHelper
            .getView(R.id.tv_classname)
            .setBackgroundColor(context.getResources().getColor(R.color.goal_item_passed_color));
      }
    } catch (NumberFormatException e) {

    }

    baseAdapterHelper
        .setText(R.id.tv_classname, goalModel.getName())
        .setText(R.id.tv_goal, goalModel.getGoal())
        .setText(R.id.tv_year, goalModel.getYear())
        .setText(R.id.tv_team, goalModel.getTeam())
        .setText(R.id.tv_credit, goalModel.getCredit())
        .setText(R.id.tv_grade_point, goalModel.getGrade_point())
        .setText(R.id.tv_classify, goalModel.getClassify())
        .setText(R.id.tv_college_belong, goalModel.getCollege_belong())
        .setText(R.id.tv_classcode, goalModel.getCode())
        .setText(R.id.tv_college_hold, goalModel.getCollege_hold());

    // Transmit the view click to expand button
    baseAdapterHelper
        .getView()
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                if (view.getId() != R.id.expandable_toggle_button) {
                  baseAdapterHelper.getView(R.id.expandable_toggle_button).performClick();
                }
              }
            });
  }