AppDetailsFragment: Don't modify original app object
Copy and use a new object for manual downloads with the requested version Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -136,8 +136,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
|
|
||||||
is BusEvent.ManualDownload -> {
|
is BusEvent.ManualDownload -> {
|
||||||
if (app.packageName == event.packageName) {
|
if (app.packageName == event.packageName) {
|
||||||
app.versionCode = event.versionCode
|
purchase(app.copy(versionCode = event.versionCode))
|
||||||
purchase()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +503,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun purchase() {
|
private fun purchase(app: App) {
|
||||||
if (app.fileList.requiresObbDir()) {
|
if (app.fileList.requiresObbDir()) {
|
||||||
if (permissionProvider.isGranted(PermissionType.STORAGE_MANAGER)) {
|
if (permissionProvider.isGranted(PermissionType.STORAGE_MANAGER)) {
|
||||||
viewModel.download(app)
|
viewModel.download(app)
|
||||||
@@ -589,7 +588,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
toast(R.string.toast_app_unavailable)
|
toast(R.string.toast_app_unavailable)
|
||||||
setText(R.string.status_unavailable)
|
setText(R.string.status_unavailable)
|
||||||
} else {
|
} else {
|
||||||
purchase()
|
purchase(app)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,13 +627,13 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
|||||||
if (!permissionProvider.isGranted(PermissionType.INSTALL_UNKNOWN_APPS)) {
|
if (!permissionProvider.isGranted(PermissionType.INSTALL_UNKNOWN_APPS)) {
|
||||||
permissionProvider.request(PermissionType.INSTALL_UNKNOWN_APPS) {
|
permissionProvider.request(PermissionType.INSTALL_UNKNOWN_APPS) {
|
||||||
if (it) {
|
if (it) {
|
||||||
purchase()
|
purchase(app)
|
||||||
} else {
|
} else {
|
||||||
toast(R.string.permissions_denied)
|
toast(R.string.permissions_denied)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
purchase()
|
purchase(app)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user