Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ public static ArrayList<ServiceUpdate> getCachedServiceUpdatesS(@NonNull Service
);
}

@Nullable
public static ArrayList<ServiceUpdate> getCachedServiceUpdatesStartsWithS(@NonNull ServiceUpdateProviderContract provider, @NonNull String targetUUID, @NonNull Integer charCount) {
return getCachedServiceUpdatesS(
provider,
getServiceUpdateContentUri(provider),
SqlUtils.getLikeEndsWithCharCount(Columns.T_SERVICE_UPDATE_K_TARGET_UUID, targetUUID, charCount) +
SqlUtils.AND +
SqlUtils.getWhereEqualsString(Columns.T_SERVICE_UPDATE_K_LANGUAGE, provider.getServiceUpdateLanguage())
);
}

@Nullable
private static ArrayList<ServiceUpdate> getCachedServiceUpdatesS(@NonNull ServiceUpdateProviderContract provider, Uri uri, String selection) {
ArrayList<ServiceUpdate> cache = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public String getLogTag() {
private final String authority;
@Nullable
private final Route route;
private final boolean includeAllDirections;
@Nullable
private final RouteDirection routeDirection;

Expand All @@ -114,15 +115,22 @@ public String getLogTag() {
private Map<String, String> providedEncryptKeysMap = null;

public Filter(@NonNull POI poi) {
this.poi = poi;
this.authority = poi.getAuthority();
this.poi = poi;
this.route = null;
this.includeAllDirections = false;
this.routeDirection = null;
}

@Deprecated
public Filter(@NonNull String authority, @NonNull Route route) {
this(authority, route, false);
}

public Filter(@NonNull String authority, @NonNull Route route, boolean includeAllDirections) {
this.authority = authority;
this.route = route;
this.includeAllDirections = includeAllDirections;
this.routeDirection = null;
this.poi = null;
}
Expand All @@ -131,6 +139,7 @@ public Filter(@NonNull String authority, @NonNull RouteDirection routeDirection)
this.authority = authority;
this.routeDirection = routeDirection;
this.route = null;
this.includeAllDirections = false;
this.poi = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public ArrayList<ServiceUpdate> getCachedServiceUpdates(@NonNull ServiceUpdatePr
} else if (serviceUpdateFilter.getRouteDirection() != null) {
return getCachedServiceUpdates(context, serviceUpdateFilter.getRouteDirection());
} else if ((serviceUpdateFilter.getRoute() != null)) { // NOT SUPPORTED
return makeServiceUpdateNoneList(this, serviceUpdateFilter.getRoute().getUUID(), SERVICE_UPDATE_SOURCE_ID);
return getCachedServiceUpdates(context, serviceUpdateFilter.getRoute());
} else {
MTLog.w(this, "getCachedServiceUpdates() > no service update (poi null or not RDS or no route)");
return null;
Expand Down Expand Up @@ -299,6 +299,20 @@ private ArrayList<ServiceUpdate> getCachedServiceUpdates(@NonNull Context contex
return cachedServiceUpdates;
}

@NonNull
private ArrayList<ServiceUpdate> getCachedServiceUpdates(@NonNull Context context, @NonNull Route route) {
final ArrayList<ServiceUpdate> cachedServiceUpdates = new ArrayList<>();
final String routeWithoutDirectionUUIDs = getRouteDirectionServiceUpdateTargetUUID(getAgencyTag(context), route.getShortName(), StringUtils.EMPTY);
final ArrayList<ServiceUpdate> routeCachedServiceUpdatesS = ServiceUpdateProvider.getCachedServiceUpdatesStartsWithS(this, routeWithoutDirectionUUIDs, 1);
if (routeCachedServiceUpdatesS != null) {
cachedServiceUpdates.addAll(routeCachedServiceUpdatesS);
}
for (ServiceUpdate serviceUpdate : cachedServiceUpdates) {
serviceUpdate.setTargetUUID(route.getUUID());
}
return cachedServiceUpdates;
}

private void enhanceRDServiceUpdatesForStop(@NonNull Context context,
ArrayList<ServiceUpdate> serviceUpdates,
Map<String, String> targetUUIDs, // different UUID from provider target UUID
Expand Down Expand Up @@ -562,7 +576,7 @@ public ArrayList<ServiceUpdate> getNewServiceUpdates(@NonNull ServiceUpdateProvi
} else if (serviceUpdateFilter.getRouteDirection() != null) {
return getNewServiceUpdates(context, serviceUpdateFilter.getRouteDirection());
} else if ((serviceUpdateFilter.getRoute() != null)) { // NOT SUPPORTED
return makeServiceUpdateNoneList(this, serviceUpdateFilter.getRoute().getUUID(), SERVICE_UPDATE_SOURCE_ID);
return getNewServiceUpdates(context, serviceUpdateFilter.getRoute());
} else {
MTLog.w(this, "getNewServiceUpdates() > no service update (poi null or not RDS or no route)");
return null;
Expand All @@ -581,6 +595,18 @@ private ArrayList<ServiceUpdate> getNewServiceUpdates(@NonNull Context context,
return getCachedServiceUpdates(context, rds);
}

@SuppressWarnings("SameReturnValue")
@Nullable
private ArrayList<ServiceUpdate> getNewServiceUpdates(@SuppressWarnings("unused") @NonNull Context context, @NonNull Route route) {
if (route.getShortName().isEmpty()) {
MTLog.d(this, "getNewServiceUpdates() > skip (stop w/o code OR route w/o short name: %s)", route);
return null;
}
// USING same feed as real-time POI status schedule
// -> can't load status without stop code
return null;
}

@SuppressWarnings("SameReturnValue")
@Nullable
private ArrayList<ServiceUpdate> getNewServiceUpdates(@SuppressWarnings("unused") @NonNull Context context, @NonNull RouteDirection rd) {
Expand Down
Loading