|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Sorting
I've noticed that there is a Sort function that is used. I could not locate information about it in the API docs. So if anybody knows where it is at, please post the link.
Now.. If I have one of my own plugin functions returning a ArrayList, is it possible for SageTV to sort that list using the Sort function or another function? What would be ideal is if there is some way to have an ArrayList or other type of object that is sortable by another property that is specified. For example, I would have Name / Priority "Name 1", 10 "Name 3", 30 "Name 2", 20 Is there a function and object that I can pass that function that will sort all the items in the list by the priority? |
#2
|
||||
|
||||
Sort and SortLexical are part of the Database API in the API docs linked in the sticky at the top of this forum
http://download.sage.tv/api/sage/api...va.lang.Object, boolean, java.lang.Object) but these only tend to work with Sage objects (Airings/MediaFiles etc). What is actually in your ArrayList? If they are Sage objects, you can use the Sage Sort method with the approriate getter to sort by (GetShowTitle or whatever -- see inside the STV for examples) If it is a java class that implements the Comparable interface, or you can have a Comparator helper class available to compare the objects, you can convert the ArrayList to an Array (toArray() ) and then use the java array sorting methods (java.lang.Arrays.Sort()). Or you can choose a different Collection for your data that is already automatically sorted, eg a java.util.TreeSet
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
#3
|
|||
|
|||
If I create my own class that implements the Comparable interface that includes the ID of the item and the string of the item and compares them. Is it still possible to have it work with SageTV Table elements, or do SageTV Table elements only work with functions that return ArrayLists?
|
#4
|
||||
|
||||
Tables work with either java arrays of Objects (ie Object[])
or with any collection: lists/maps/sets etc You would have to return either an array of objects of your class, or a list of objects of your class. Your class would have to implement Comparable (for sorting), and would have to have getter/setter methods so that you can access the member data from with Studio. You would pass an Array or Collection of such class objects to the Table widget, and each table row would be an object from that array. Several of my plugins use Collections of objects of custom classes if you want pointers (eg rss news, autoaspect)
__________________
Check out my enhancements for Sage in the Sage Customisations and Sageplugins Wiki |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|