Skip to content

Commit

Permalink
- fixed dangling foreground service that happened when going back on …
Browse files Browse the repository at this point in the history
…Trips fragment

- notify recyclerview when Map is deleted
  • Loading branch information
lmj0011 committed May 1, 2020
1 parent 4543b47 commit 6d58468
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {
applicationId "name.lmj0011.courierlocker"
minSdkVersion 19
targetSdkVersion 29
versionCode 46
versionCode 47
versionName "1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -50,7 +50,7 @@ android {
productFlavors {
dev { // active development/testing
applicationIdSuffix ".dev"
versionNameSuffix ".1.2-dev"
versionNameSuffix ".1.3-dev"
resValue("string", "app_name", "Courier Locker (dev)")
manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher_dev",
Expand All @@ -60,7 +60,7 @@ android {
}
beta { // public testing
applicationIdSuffix ".beta"
versionNameSuffix ".1.2-beta"
versionNameSuffix ".1.3-beta"
resValue("string", "app_name", "Courier Locker (beta)")
manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher_beta",
Expand All @@ -70,7 +70,7 @@ android {
}
prod { // official release
applicationIdSuffix ".prod"
versionNameSuffix ".1.2"
versionNameSuffix ".1.3"
resValue("string", "app_name", "Courier Locker")
manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher",
Expand Down
28 changes: 12 additions & 16 deletions app/src/main/java/name/lmj0011/courierlocker/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,27 +142,23 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
}

override fun onSupportNavigateUp(): Boolean {
this.onBackPressed()
return true
when(navController.currentDestination?.id) {
// seems to be the only way to get the Maps recyclerview to show updated items when navigated
// from EditAptBuildingsMapsFragment
R.id.editAptBuildingsMapsFragment -> {
navController.navigate(R.id.mapsFragment)
return true
}
}

return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}

override fun onBackPressed() {
if (binding.drawerLayout.isDrawerOpen(GravityCompat.START)) {
// an open drawer means user is at a top level destination, close app
finish()
}else if(topLevelDestinations.contains(navController.currentDestination?.id)) {
binding.drawerLayout.openDrawer(GravityCompat.START)
binding.drawerLayout.closeDrawer(GravityCompat.START)
}else {
when(navController.currentDestination?.id) {
// seems to be the only way to get the Maps recyclerview to show updated items when navigated
// from EditAptBuildingsMapsFragment
R.id.editAptBuildingsMapsFragment -> {
navController.navigate(R.id.mapsFragment)
}
else -> {
super.onBackPressed()
}
}
super.onBackPressed()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class MapsFragment : Fragment() {
withContext(Dispatchers.IO) {
apartmentViewModel.database.deleteByApartmentId(aptId)
}
listAdapter.notifyDataSetChanged()
}
}
), this)
Expand Down

0 comments on commit 6d58468

Please sign in to comment.