Skip to content

Commit

Permalink
[23022]
Browse files Browse the repository at this point in the history
- [TripGov5] update strings.xml to update TripGov5 app name to TripGo
- [TripGov5] update TripGoApplication to set default modes
- [TripKit] update RouteStore to add record counter
- [TripKit] update WhereClauses to update return type to nullable
- [TripGov5] update TripGoFavoritesSuggestionProvider and TripGoFixedSuggestionsProvider to add checking for Home and Work Favorites before adding them to the suggestions list
- [TripKit] update MultiSourceGeocodingAggregator to update sorting by scoring
- [TripKitUI] update CustomBinding.kt to add a custom binding adapter to set view's height
- [TripKitUI] update FixedSuggestionsProvider to add passing favoriteRepository for home and work favorites checking
- [TripKitUI] update GetRealtimeText to remove am/pm on 24hour time format
- [TripKitUI] update LocationSearchViewModel to inject FavoritesRepository and pass it to fixedSuggestionsProvider
- [TripKitUI] update trip_result_list_fragment.xml to bind TripResultListCustomRecyclerViewAdapter to routes recyclerview
- [TripKitUI] update trip_result_list_item_trip.xml to adjust quickboocking action button binding
- [TripKitUI] update TripKitDateTimePickerDialogFragment to reduce memory consumption by calling Garbage collector onResume and update how minutes picker is being formatted
- [TripKitUI] update TripPreviewPagerViewModel and inject PrintTime and pass to generateTripPreviewHeader utility function
- [TripKitUI] add TripResultListCustomRecyclerViewAdapter to handle me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter
- [TripKitUI] update TripResultListFragment to clear disposable onResume
- [TripKitUI] update TripResultViewModel to put all disposable into the CompositeDisposables. Update trips sorting strategy to use weightedScore field. Add temporary fix for badges handling by force refreshing the TripResultListCustomRecyclerViewAdapter when list is updated
- [TripKitUI] update TripResultViewModel to handle badge setting and visibility by using livedata instead of Observable fields
- [TripKitUI] update TripGroupRepositoryImpl to add function for deleting past routes with specific hours. And another function to clear all tripGroups, trips and segments
  • Loading branch information
MichaelReyes committed Dec 11, 2024
1 parent c0891c7 commit 77c6940
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MultiSourceGeocodingAggregator<T : GCResultInterface> private constructor(
}
}

return GeocodeUtilities.sortByScore(scoredResults)
return scoredResults.sortedByDescending { it.score }
}

fun flattenAggregate(userQuery: GCQueryInterface, providersResults: List<List<T>>): List<GCResultInterface> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ open class RouteStore(private val databaseHelper: SQLiteOpenHelper, private val

open fun deleteByTableAsync(
tables: List<String>,
whereClauses: List<Pair<String, Array<String>>>
whereClauses: List<Pair<String?, Array<String>?>>
): Observable<Int> {
if (tables.size != whereClauses.size) {
throw IllegalArgumentException("Tables and whereClauses must have the same size")
Expand Down Expand Up @@ -248,9 +248,28 @@ open class RouteStore(private val databaseHelper: SQLiteOpenHelper, private val
return database.delete(TABLE_TRIP_GROUPS, whereClause.first, whereClause.second)
}

fun countRecords(tableName: String): Int {
val database = databaseHelper.writableDatabase
database.beginTransaction()
var recordCount = 0
val cursor = database.rawQuery("SELECT COUNT(*) FROM $tableName", null)
try {
if (cursor.moveToFirst()) {
recordCount = cursor.getInt(0)
}
} catch (e: Exception) {
e.printStackTrace()
} finally {
cursor.close()
database.setTransactionSuccessful()
database.endTransaction()
}
return recordCount
}

private fun deleteByTablesInTransaction(
tables: List<String>,
whereClauses: List<Pair<String, Array<String>>>
whereClauses: List<Pair<String?, Array<String>?>>
): Int {
val database = databaseHelper.writableDatabase
var totalRowsDeleted = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object WhereClauses {
fun removeTripGroupsHappenedBefore(
hours: Long,
currentMillis: Long
): Pair<String, Array<String>> {
): Pair<String?, Array<String>?> {
val secs = HOURS.toSeconds(hours)
val currentSecs = MILLISECONDS.toSeconds(currentMillis)
val args = arrayOf((currentSecs - secs).toString())
Expand All @@ -51,14 +51,14 @@ object WhereClauses {
}

// Remove all trips that doesn't have a group in tripGroups table
fun removeTripsWithNoTripGroup(): Pair<String, Array<String>> {
fun removeTripsWithNoTripGroup(): Pair<String?, Array<String>?> {
val where: String =
"$COL_GROUP_ID NOT IN (SELECT $COL_UUID FROM $TABLE_TRIP_GROUPS)"
return Pair(where, arrayOf())
}

// Remove all segments that doesn't have a trip in trips table
fun removeSegmentsWithNoTrip(): Pair<String, Array<String>> {
fun removeSegmentsWithNoTrip(): Pair<String?, Array<String>?> {
val where: String =
"$COL_TRIP_ID NOT IN (SELECT $COL_UUID FROM $TABLE_TRIPS)"
return Pair(where, arrayOf())
Expand Down

0 comments on commit 77c6940

Please sign in to comment.