コード例 #1
0
  private void addReviewsInView(LinearLayout llReviews) {
    LayoutInflater vi =
        (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    for (int i = 0; i < reviews.size(); i++) {
      Review review = reviews.get(i);

      View v = vi.inflate(R.layout.review_item, null);

      TextView tvReviewerName = (TextView) v.findViewById(R.id.tvReviewerName);
      tvReviewerName.setText(((SimpleUser) review.getReviewer()).getName());

      String PATTERN = "MMM yyyy";
      SimpleDateFormat dateFormat = new SimpleDateFormat();
      dateFormat.applyPattern(PATTERN);
      String date = dateFormat.format(review.getCreatedAt());
      TextView tvReviewDate = (TextView) v.findViewById(R.id.tvReviewDate);
      tvReviewDate.setText(date);

      TextView tvReviewText = (TextView) v.findViewById(R.id.tvReviewText);
      tvReviewText.setText(review.getReviewBody());

      llReviews.addView(
          v,
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    }
  }
コード例 #2
0
  private Trainer createFakeTrainer() {
    Trainer trainer = new Trainer();
    trainer.setId(1);
    trainer.setName("Brendon Miller");
    trainer.setAboutMe(
        "Whether you want to lose weight and keep it off, build lean muscle, or just look and feel better in the clothes you’re in, I'll help you get there.");

    ArrayList<String> educationAndCertifications = new ArrayList<>();
    educationAndCertifications.add(
        "MS in Nutrition and Food Science from San Jose State University");
    educationAndCertifications.add("Calorie Management System Certification");
    educationAndCertifications.add("CPR Certification");
    educationAndCertifications.add(
        "National Academy of Sports Medicine - Corrective Exercise Specialist");
    educationAndCertifications.add(
        "National Exercise and Sports Trainers Association - Personal Fitness Trainer");
    trainer.setEducationAndCertifications(educationAndCertifications);

    ArrayList<String> interestsAndAchievements = new ArrayList<>();
    interestsAndAchievements.add("Completed Silicon Valley Marathon in 2014");
    interestsAndAchievements.add("Completed San Francisco Marathon in 2013");
    interestsAndAchievements.add("Climbed Kilimanjaro in 2011");
    interestsAndAchievements.add("Working towards finishing a century ride");
    trainer.setInterestsAndAchievements(interestsAndAchievements);
    trainer.setPrice(20);

    trainer.setRating(4.5);

    trainer.setProfileImageUrl(
        "http://iptfitness.co.uk/wp-content/uploads/2015/03/Aimee-stevens-personal-trainer.jpg");

    ArrayList<String> images = new ArrayList<>();
    images.add("http://gumbofitness.com/wp-content/uploads/2014/11/header-photo1.jpg");
    images.add(
        "http://gumbofitness.com/wp-content/uploads/2014/11/Depositphotos_10679691_original.jpg");
    trainer.setImages(images);

    Address address = new Address();
    address = new Address();
    address.setAddressLine1("2550 W El Camino Real");
    address.setAddressLine2("");
    address.setCity("Mountain View");
    address.setState("CA");
    address.setZip("94040");

    Gym gym = new Gym();
    gym.setName("24 hour fitness");
    gym.setAddress(address);
    gym.setLocation(37.364511, -122.031336);
    trainer.setGym(gym);

    ArrayList<Review> reviews = new ArrayList<>();
    Review review1 = new Review();
    review1.setRating(4);
    //        review1.setReviewee("Bob");
    review1.setDate(strToDate("2015/03/18"));
    review1.setReviewText(
        "Brendon Miller is an awesome trainer. He helped me loose 40 lbs in 4 months.");
    reviews.add(review1);

    Review review2 = new Review();
    review2.setRating(5);
    //        review2.setReviewee("Alisha");
    review2.setDate(strToDate("2011/11/04"));
    review2.setReviewText(
        "I am working out with Brendon for the last 2 months. She is really friendly and knows how to help someone reach their fitness goals");
    reviews.add(review2);

    //        trainer.setReviews(reviews);

    return trainer;
  }