selfconference / selfconf

0 stars 1 forks source link

Return sponsors in sorted order #9

Closed macklinu closed 8 years ago

macklinu commented 8 years ago

Here is a class from the Android app:

final class SponsorComparator implements Comparator<Sponsor> {
  @Override public int compare(Sponsor lhs, Sponsor rhs) {
    SponsorLevel lhsMin = Collections.min(lhs.getSponsorLevels());
    SponsorLevel rhsMin = Collections.min(rhs.getSponsorLevels());
    int result = ComparisonChain.start() //
        .compare(lhsMin, rhsMin) //
        .result();
    if (result == 0) {
      return ComparisonChain.start() //
          .compare(lhs.getName(), rhs.getName()) //
          .result();
    }
    return result;
  }
}

This sorts sponsors by sponsor level sort order, where lowest sort order is displayed at the top of the list (so a Platinum sponsor is displayed higher in the list than a Bronze sponsor, for example).

We could remove the SponsorLevel object entirely from the mobile apps if it was the responsibility of the API to return a sorted array instead of the mobile app's responsibility.

What do you think?

macklinu commented 8 years ago

Closing this for now - not looking into exploring these changes for 2016.