Skip to content

Commit

Permalink
Merge pull request #214 from amardeshbd/develop
Browse files Browse the repository at this point in the history
release build for 2.7
  • Loading branch information
hossain-khan authored Sep 9, 2020
2 parents 51bc558 + ae8588c commit eb36497
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
11 changes: 10 additions & 1 deletion android-app/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions android-app/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId "com.blacklivesmatter.policebrutality"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode 13
versionName "2.6"
versionCode 14
versionName "2.7"

// https://developer.android.com/studio/build/shrink-code#unused-alt-resources
resConfigs "en"
Expand Down Expand Up @@ -174,7 +174,7 @@ dependencies {
testImplementation "org.mockito:mockito-inline:$rootProject.mockitoVersion" // Mockito framework
testImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.7"
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.work:work-testing:$rootProject.workVersion"
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class BrutalityIncidentRepository @Inject constructor(
Timber.i("Removed $affectedRows stale records from database.")
}

override suspend fun deleteAllRecords() {
val affectedRows = incidentDao.deleteAllRecords()
Timber.i("Removed $affectedRows records from database.")
}

override suspend fun totalIncidents(): Int {
return incidentDao.getTotalRecords()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ interface IncidentDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertAll(incidents: List<Incident>)

// NOTE: With lot of records it throws following error
// SQLiteException: too many SQL variables (code 1 SQLITE_ERROR)
// So, instead use `deleteAllRecords()`
@Query("DELETE FROM incidents WHERE id NOT IN (:ids)")
suspend fun deleteItemByIds(ids: List<String>): Int

@Query("DELETE FROM incidents WHERE 1")
suspend fun deleteAllRecords(): Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ interface IncidentRepository {
* Should remove all stale incidents except the [latestIncidents] provided here.
*/
suspend fun removeStaleIncidents(latestIncidents: List<Incident>)
suspend fun deleteAllRecords()
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ class LocationViewModel @ViewModelInject constructor(
Timber.d("Received total ${incidents.size} incidents, updating local cache.")
saveLastUpdatedTimestamp()

incidentRepository.deleteAllRecords()
incidentRepository.addIncidents(incidents)
incidentRepository.removeStaleIncidents(incidents)
_refreshEvent.value = RefreshEvent.Success(incidents.size)
}
}
Expand Down
2 changes: 1 addition & 1 deletion android-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
androidXHiltVersion = '1.0.0-alpha02' // https://developer.android.com/jetpack/androidx/releases/hilt
appCompatVersion = '1.2.0'
cardViewVersion = '1.0.0'
constraintLayoutVersion = '2.0.0-rc1'
constraintLayoutVersion = '2.0.1'
coreTestingVersion = '2.0.0'
espressoVersion = '3.1.1'
firebaseAnalyticsVersion = '17.4.4'
Expand Down

0 comments on commit eb36497

Please sign in to comment.