3434import org .mtransit .android .commons .data .Schedule ;
3535import org .mtransit .android .commons .data .ServiceUpdate ;
3636import org .mtransit .android .commons .data .ServiceUpdateKtxKt ;
37+ import org .mtransit .android .commons .data .ServiceUpdates ;
3738import org .mtransit .android .commons .data .Stop ;
3839import org .mtransit .android .commons .helpers .MTDefaultHandler ;
3940import org .mtransit .android .commons .provider .agency .AgencyUtils ;
6667import java .net .HttpURLConnection ;
6768import java .net .SocketException ;
6869import java .net .UnknownHostException ;
69- import java .util .ArrayList ;
7070import java .util .Arrays ;
7171import java .util .Collection ;
7272import java .util .Collections ;
@@ -605,13 +605,13 @@ public String getServiceUpdateDbTableName() {
605605 }
606606
607607 @ Override
608- public void cacheServiceUpdates (@ NonNull List < ServiceUpdate > newServiceUpdates ) {
608+ public void cacheServiceUpdates (@ NonNull ServiceUpdates newServiceUpdates ) {
609609 ServiceUpdateProvider .cacheServiceUpdatesS (this , newServiceUpdates );
610610 }
611611
612612 @ Nullable
613613 @ Override
614- public List < ServiceUpdate > getCachedServiceUpdates (@ NonNull ServiceUpdateProviderContract .Filter serviceUpdateFilter ) {
614+ public ServiceUpdates getCachedServiceUpdates (@ NonNull ServiceUpdateProviderContract .Filter serviceUpdateFilter ) {
615615 final Context context = requireContextCompat ();
616616 if (serviceUpdateFilter .getPoi () instanceof RouteDirectionStop ) {
617617 return getCachedServiceUpdates (context , (RouteDirectionStop ) serviceUpdateFilter .getPoi ());
@@ -625,16 +625,16 @@ public List<ServiceUpdate> getCachedServiceUpdates(@NonNull ServiceUpdateProvide
625625 }
626626 }
627627
628- private List < ServiceUpdate > getCachedServiceUpdates (@ NonNull Context context , @ NonNull RouteDirectionStop rds ) {
628+ private ServiceUpdates getCachedServiceUpdates (@ NonNull Context context , @ NonNull RouteDirectionStop rds ) {
629629 final Map <String , String > targetUUIDs = getServiceUpdateTargetUUIDs (context , rds );
630- List < ServiceUpdate > cachedServiceUpdates = ServiceUpdateProviderExtKt .getCachedServiceUpdatesS (this , targetUUIDs .keySet ());
630+ ServiceUpdates cachedServiceUpdates = ServiceUpdateProviderExtKt .getCachedServiceUpdatesS (this , targetUUIDs .keySet ());
631631 enhanceRDServiceUpdateForStop (cachedServiceUpdates , targetUUIDs );
632632 return cachedServiceUpdates ;
633633 }
634634
635- private List < ServiceUpdate > getCachedServiceUpdates (@ NonNull Context context , @ NonNull RouteDirection rd ) {
635+ private ServiceUpdates getCachedServiceUpdates (@ NonNull Context context , @ NonNull RouteDirection rd ) {
636636 final Map <String , String > targetUUIDs = getServiceUpdateTargetUUIDs (context , rd );
637- List < ServiceUpdate > cachedServiceUpdates = ServiceUpdateProviderExtKt .getCachedServiceUpdatesS (this , targetUUIDs .keySet ());
637+ ServiceUpdates cachedServiceUpdates = ServiceUpdateProviderExtKt .getCachedServiceUpdatesS (this , targetUUIDs .keySet ());
638638 enhanceRDServiceUpdateForStop (cachedServiceUpdates , targetUUIDs );
639639 // if (org.mtransit.android.commons.Constants.DEBUG) {
640640 // MTLog.d(this, "getCachedServiceUpdates(%s) > %s", rd.getUUID(), cachedServiceUpdates == null ? null : cachedServiceUpdates.size());
@@ -647,9 +647,9 @@ private List<ServiceUpdate> getCachedServiceUpdates(@NonNull Context context, @N
647647 return cachedServiceUpdates ;
648648 }
649649
650- private List < ServiceUpdate > getCachedServiceUpdates (@ NonNull Context context , @ NonNull Route route ) {
650+ private ServiceUpdates getCachedServiceUpdates (@ NonNull Context context , @ NonNull Route route ) {
651651 final Map <String , String > targetUUIDs = getServiceUpdateTargetUUIDs (context , route );
652- List < ServiceUpdate > cachedServiceUpdates = ServiceUpdateProviderExtKt .getCachedServiceUpdatesS (this , targetUUIDs .keySet ());
652+ ServiceUpdates cachedServiceUpdates = ServiceUpdateProviderExtKt .getCachedServiceUpdatesS (this , targetUUIDs .keySet ());
653653 enhanceRDServiceUpdateForStop (cachedServiceUpdates , targetUUIDs );
654654 // if (org.mtransit.android.commons.Constants.DEBUG) {
655655 // MTLog.d(this, "getCachedServiceUpdates(%s) > %s", route.getUUID(), cachedServiceUpdates == null ? null : cachedServiceUpdates.size());
@@ -662,7 +662,7 @@ private List<ServiceUpdate> getCachedServiceUpdates(@NonNull Context context, @N
662662 return cachedServiceUpdates ;
663663 }
664664
665- private void enhanceRDServiceUpdateForStop (@ Nullable List < ServiceUpdate > serviceUpdates ,
665+ private void enhanceRDServiceUpdateForStop (@ Nullable ServiceUpdates serviceUpdates ,
666666 @ NonNull Map <String , String > targetUUIDs // different UUID from provider target UUID
667667 ) {
668668 try {
@@ -836,7 +836,7 @@ public NextBusStorage getStorage(@NonNull Context context) {
836836
837837 @ Nullable
838838 @ Override
839- public List < ServiceUpdate > getNewServiceUpdates (@ NonNull ServiceUpdateProviderContract .Filter serviceUpdateFilter ) {
839+ public ServiceUpdates getNewServiceUpdates (@ NonNull ServiceUpdateProviderContract .Filter serviceUpdateFilter ) {
840840 final Context context = requireContextCompat ();
841841 if (serviceUpdateFilter .getPoi () instanceof RouteDirectionStop ) {
842842 return getNewServiceUpdates (context , (RouteDirectionStop ) serviceUpdateFilter .getPoi (), serviceUpdateFilter .isInFocusOrDefault ());
@@ -850,29 +850,29 @@ public List<ServiceUpdate> getNewServiceUpdates(@NonNull ServiceUpdateProviderCo
850850 }
851851 }
852852
853- private List < ServiceUpdate > getNewServiceUpdates (@ NonNull Context context , @ NonNull RouteDirectionStop rds , boolean inFocus ) {
853+ private ServiceUpdates getNewServiceUpdates (@ NonNull Context context , @ NonNull RouteDirectionStop rds , boolean inFocus ) {
854854 updateAgencyServiceUpdateDataIfRequired (requireContextCompat (), inFocus );
855- List < ServiceUpdate > cachedServiceUpdates = getCachedServiceUpdates (context , rds );
855+ ServiceUpdates cachedServiceUpdates = getCachedServiceUpdates (context , rds );
856856 if (CollectionUtils .getSize (cachedServiceUpdates ) == 0 ) {
857857 cachedServiceUpdates = makeServiceUpdateNoneList (this , rds , AGENCY_SOURCE_ID );
858858 enhanceRDServiceUpdateForStop (cachedServiceUpdates , Collections .emptyMap ());
859859 }
860860 return cachedServiceUpdates ;
861861 }
862862
863- private List < ServiceUpdate > getNewServiceUpdates (@ NonNull Context context , @ NonNull RouteDirection rd , boolean inFocus ) {
863+ private ServiceUpdates getNewServiceUpdates (@ NonNull Context context , @ NonNull RouteDirection rd , boolean inFocus ) {
864864 updateAgencyServiceUpdateDataIfRequired (requireContextCompat (), inFocus );
865- List < ServiceUpdate > cachedServiceUpdates = getCachedServiceUpdates (context , rd );
865+ ServiceUpdates cachedServiceUpdates = getCachedServiceUpdates (context , rd );
866866 if (CollectionUtils .getSize (cachedServiceUpdates ) == 0 ) {
867867 cachedServiceUpdates = makeServiceUpdateNoneList (this , rd , AGENCY_SOURCE_ID );
868868 enhanceRDServiceUpdateForStop (cachedServiceUpdates , Collections .emptyMap ());
869869 }
870870 return cachedServiceUpdates ;
871871 }
872872
873- private List < ServiceUpdate > getNewServiceUpdates (@ NonNull Context context , @ NonNull Route route , boolean inFocus ) {
873+ private ServiceUpdates getNewServiceUpdates (@ NonNull Context context , @ NonNull Route route , boolean inFocus ) {
874874 updateAgencyServiceUpdateDataIfRequired (requireContextCompat (), inFocus );
875- List < ServiceUpdate > cachedServiceUpdates = getCachedServiceUpdates (context , route );
875+ ServiceUpdates cachedServiceUpdates = getCachedServiceUpdates (context , route );
876876 if (CollectionUtils .getSize (cachedServiceUpdates ) == 0 ) {
877877 cachedServiceUpdates = makeServiceUpdateNoneList (this , route , AGENCY_SOURCE_ID );
878878 enhanceRDServiceUpdateForStop (cachedServiceUpdates , Collections .emptyMap ());
@@ -912,7 +912,7 @@ private void updateAllAgencyServiceUpdateDataFromWWW(@NonNull Context context, b
912912 deleteAllAgencyServiceUpdateData ();
913913 deleteAllDone = true ;
914914 }
915- List < ServiceUpdate > newServiceUpdates = loadAgencyServiceUpdateDataFromWWW (context );
915+ ServiceUpdates newServiceUpdates = loadAgencyServiceUpdateDataFromWWW (context );
916916 if (newServiceUpdates != null ) { // empty is OK
917917 long nowInMs = TimeUtils .currentTimeMillis ();
918918 if (!deleteAllDone ) {
@@ -944,7 +944,7 @@ private static String getAgencyUrlString(@NonNull Context context) {
944944 }
945945
946946 @ Nullable
947- private List < ServiceUpdate > loadAgencyServiceUpdateDataFromWWW (@ NonNull Context context ) {
947+ private ServiceUpdates loadAgencyServiceUpdateDataFromWWW (@ NonNull Context context ) {
948948 try {
949949 final String urlString = getAgencyUrlString (context );
950950 MTLog .i (this , "Loading from '%s'..." , urlString );
@@ -970,7 +970,7 @@ private List<ServiceUpdate> loadAgencyServiceUpdateDataFromWWW(@NonNull Context
970970 );
971971 xr .setContentHandler (handler );
972972 xr .parse (new InputSource (response .body ().byteStream ()));
973- final List < ServiceUpdate > serviceUpdates = handler .getServiceUpdates ();
973+ final ServiceUpdates serviceUpdates = handler .getServiceUpdates ();
974974 MTLog .i (this , "Found %d service updates." , serviceUpdates .size ());
975975 return serviceUpdates ;
976976 default :
@@ -1627,7 +1627,7 @@ public String getLogTag() {
16271627 private final long serviceUpdateMaxValidityInMs ;
16281628
16291629 @ NonNull
1630- private final List < ServiceUpdate > serviceUpdates = new ArrayList <> ();
1630+ private final ServiceUpdates serviceUpdates = new ServiceUpdates ();
16311631
16321632 private final String agencyTag ;
16331633
@@ -1689,7 +1689,7 @@ public String getLogTag() {
16891689 }
16901690
16911691 @ NonNull
1692- List < ServiceUpdate > getServiceUpdates () {
1692+ ServiceUpdates getServiceUpdates () {
16931693 return this .serviceUpdates ;
16941694 }
16951695
0 commit comments