Created
August 30, 2009 05:42
-
-
Save dcbriccetti/177869 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class NameAndScreenName(val name: String, val screenName: String) extends Ordered[NameAndScreenName] { | |
override def toString = name + " (" + screenName + ")" | |
def compare(other: NameAndScreenName) = screenName compareToIgnoreCase other.screenName | |
def matches(search: String) = { | |
val slc = search.toLowerCase | |
search.length == 0 || name.toLowerCase.contains(slc) || screenName.toLowerCase.contains(slc) | |
} | |
} | |
title = "Send Message" | |
def users = { | |
val utm = session.windows.streams.usersTableModel | |
val matches = ((utm.friends ::: utm.followers).map(u => NameAndScreenName(u.name, u.screenName)). | |
filter(_.matches(searchText.text))).sort(_ < _).removeDuplicates | |
(matches.length match { | |
case 0 => "No matches were found" | |
case 1 => "Select the following item to insert a @screenname" | |
case _ => "Select one of these " + matches.length + " items to insert a @screenname" | |
}) :: matches | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment