1st version that works
This commit is contained in:
@ -0,0 +1,51 @@
|
||||
package com.safemobile.lib.radio;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class Zone {
|
||||
public int dbID;
|
||||
public int id;
|
||||
public String ZoneName="";
|
||||
|
||||
public ArrayList<Channel> channelList = new ArrayList<Channel>();
|
||||
public Zone()
|
||||
{
|
||||
channelList = new ArrayList<Channel>();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "zoneDbID: " + id +" |zoneID: " + dbID + " | ZoneName: " + ZoneName ;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort the list of channels based on their names
|
||||
*/
|
||||
public void sortChannelListByName() {
|
||||
//Sorting
|
||||
Collections.sort(channelList, new Comparator<Channel>() {
|
||||
@Override
|
||||
public int compare(Channel channel1, Channel channel2)
|
||||
{
|
||||
return channel1.chName.compareTo(channel2.chName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sort the list of channels based on their ids
|
||||
*/
|
||||
public void sortChannelListByChannelID() {
|
||||
//Sorting
|
||||
Collections.sort(channelList, new Comparator<Channel>() {
|
||||
@Override
|
||||
public int compare(Channel channel1, Channel channel2)
|
||||
{
|
||||
return (channel1.id < channel2.id ? 1 : 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user