Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/backend/Route.java
Show All 12 Lines | BusTO (backend components) | ||||
GNU General Public License for more details. | GNU General Public License for more details. | ||||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino.backend; | package it.reyboz.bustorino.backend; | ||||
import android.util.Log; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Calendar; | import java.util.Calendar; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | public class Route implements Comparable<Route> { | ||||
* Constructor used by the FiveTAPIFetcher | * Constructor used by the FiveTAPIFetcher | ||||
* @param name stop Name | * @param name stop Name | ||||
* @param t optional type | * @param t optional type | ||||
* @param description line rough description | * @param description line rough description | ||||
*/ | */ | ||||
public Route(String name,Type t,String description){ | public Route(String name,Type t,String description){ | ||||
this(name,null,new ArrayList<>(),t,description); | this(name,null,new ArrayList<>(),t,description); | ||||
} | } | ||||
/** | |||||
* Constructor used by the FiveTAPIFetcher | |||||
* @param name stop Name | |||||
* @param t optional type | |||||
* @param description line rough description | |||||
*/ | |||||
public Route(String name,String destinazione, String description, Type t){ | |||||
this(name,destinazione,new ArrayList<>(),t,description); | |||||
} | |||||
/** | /** | ||||
* Exactly what it says on the tin. | * Exactly what it says on the tin. | ||||
* | * | ||||
* @return times from the timetable | * @return times from the timetable | ||||
*/ | */ | ||||
public List<Passaggio> getPassaggi() { | public List<Passaggio> getPassaggi() { | ||||
return this.passaggi; | return this.passaggi; | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | public String getPassaggiToString(int start_idx, int number, boolean sort){ | ||||
return sb.toString(); | return sb.toString(); | ||||
} | } | ||||
public int numPassaggi(){ | public int numPassaggi(){ | ||||
if (passaggi==null) | if (passaggi==null) | ||||
return 0; | return 0; | ||||
return passaggi.size(); | return passaggi.size(); | ||||
} | } | ||||
public Passaggio.Source getPassaggiSource(){ | |||||
Passaggio.Source mSource = null; | |||||
for(Passaggio pass: passaggi){ | |||||
if (mSource == null) { | |||||
mSource = pass.source; | |||||
} else if (mSource != pass.source){ | |||||
Log.w("BusTO-CheckPassaggi", | |||||
"Cannot determine the source for route "+this.name+", have got "+mSource +" so far, the next one is "+pass.source ); | |||||
mSource = Passaggio.Source.UNDETERMINED; | |||||
break; | |||||
} | |||||
} | |||||
if (mSource == null) mSource = Passaggio.Source.UNDETERMINED; | |||||
return mSource; | |||||
} | |||||
@Override | @Override | ||||
public int compareTo(@NonNull Route other) { | public int compareTo(@NonNull Route other) { | ||||
int res; | int res; | ||||
int thisAsInt, otherAsInt; | int thisAsInt, otherAsInt; | ||||
// sorting by numbers alone yields a far more "natural" result (36N goes before 2024, 95B next to 95, and the like) | // sorting by numbers alone yields a far more "natural" result (36N goes before 2024, 95B next to 95, and the like) | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register