mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-11 08:27:50 -04:00
Fixed downloading start after clicking on storage selection dialog if file system has not enough space
This commit is contained in:
parent
2b9ea973f4
commit
47cddb0964
@ -55,7 +55,6 @@ import org.kiwix.kiwixmobile.core.base.BaseActivity
|
|||||||
import org.kiwix.kiwixmobile.core.base.BaseFragment
|
import org.kiwix.kiwixmobile.core.base.BaseFragment
|
||||||
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
|
import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions
|
||||||
import org.kiwix.kiwixmobile.core.downloader.Downloader
|
import org.kiwix.kiwixmobile.core.downloader.Downloader
|
||||||
import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity
|
|
||||||
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.navigate
|
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.navigate
|
||||||
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel
|
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.viewModel
|
||||||
import org.kiwix.kiwixmobile.core.extensions.closeKeyboard
|
import org.kiwix.kiwixmobile.core.extensions.closeKeyboard
|
||||||
@ -100,7 +99,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
@Inject lateinit var alertDialogShower: AlertDialogShower
|
@Inject lateinit var alertDialogShower: AlertDialogShower
|
||||||
private var fragmentDestinationDownloadBinding: FragmentDestinationDownloadBinding? = null
|
private var fragmentDestinationDownloadBinding: FragmentDestinationDownloadBinding? = null
|
||||||
|
|
||||||
private var downloadBookItem: LibraryNetworkEntity.Book? = null
|
private var downloadBookItem: LibraryListItem.BookItem? = null
|
||||||
private val zimManageViewModel by lazy {
|
private val zimManageViewModel by lazy {
|
||||||
requireActivity().viewModel<ZimManageViewModel>(viewModelFactory)
|
requireActivity().viewModel<ZimManageViewModel>(viewModelFactory)
|
||||||
}
|
}
|
||||||
@ -329,7 +328,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadFile() {
|
private fun downloadFile() {
|
||||||
downloadBookItem?.let {
|
downloadBookItem?.book?.let {
|
||||||
downloader.download(it)
|
downloader.download(it)
|
||||||
downloadBookItem = null
|
downloadBookItem = null
|
||||||
}
|
}
|
||||||
@ -344,7 +343,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
sharedPreferenceUtil.getPublicDirectoryPath(storageDevice.name)
|
sharedPreferenceUtil.getPublicDirectoryPath(storageDevice.name)
|
||||||
)
|
)
|
||||||
sharedPreferenceUtil.putStoragePosition(INTERNAL_SELECT_POSITION)
|
sharedPreferenceUtil.putStoragePosition(INTERNAL_SELECT_POSITION)
|
||||||
downloadFile()
|
clickOnBookItem()
|
||||||
} else {
|
} else {
|
||||||
if (sharedPreferenceUtil.isPlayStoreBuild) {
|
if (sharedPreferenceUtil.isPlayStoreBuild) {
|
||||||
setExternalStoragePath(storageDevice)
|
setExternalStoragePath(storageDevice)
|
||||||
@ -364,7 +363,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
private fun setExternalStoragePath(storageDevice: StorageDevice) {
|
private fun setExternalStoragePath(storageDevice: StorageDevice) {
|
||||||
sharedPreferenceUtil.putPrefStorage(storageDevice.name)
|
sharedPreferenceUtil.putPrefStorage(storageDevice.name)
|
||||||
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION)
|
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION)
|
||||||
downloadFile()
|
clickOnBookItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun selectFolder() {
|
private fun selectFolder() {
|
||||||
@ -388,7 +387,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
data?.let {
|
data?.let {
|
||||||
getPathFromUri(requireActivity(), data)?.let(sharedPreferenceUtil::putPrefStorage)
|
getPathFromUri(requireActivity(), data)?.let(sharedPreferenceUtil::putPrefStorage)
|
||||||
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION)
|
sharedPreferenceUtil.putStoragePosition(EXTERNAL_SELECT_POSITION)
|
||||||
downloadFile()
|
clickOnBookItem()
|
||||||
} ?: run {
|
} ?: run {
|
||||||
activity.toast(
|
activity.toast(
|
||||||
resources
|
resources
|
||||||
@ -465,7 +464,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
|
|
||||||
private fun onBookItemClick(item: LibraryListItem.BookItem) {
|
private fun onBookItemClick(item: LibraryListItem.BookItem) {
|
||||||
if (checkExternalStorageWritePermission()) {
|
if (checkExternalStorageWritePermission()) {
|
||||||
downloadBookItem = item.book
|
downloadBookItem = item
|
||||||
when {
|
when {
|
||||||
isNotConnected -> {
|
isNotConnected -> {
|
||||||
noInternetSnackbar()
|
noInternetSnackbar()
|
||||||
@ -474,7 +473,7 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
noWifiWithWifiOnlyPreferenceSet -> {
|
noWifiWithWifiOnlyPreferenceSet -> {
|
||||||
dialogShower.show(WifiOnly, {
|
dialogShower.show(WifiOnly, {
|
||||||
sharedPreferenceUtil.putPrefWifiOnly(false)
|
sharedPreferenceUtil.putPrefWifiOnly(false)
|
||||||
downloadFile()
|
clickOnBookItem()
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -515,8 +514,12 @@ class OnlineLibraryFragment : BaseFragment(), FragmentActivityExtensions {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
sharedPreferenceUtil.showStorageOption = false
|
sharedPreferenceUtil.showStorageOption = false
|
||||||
downloadFile()
|
clickOnBookItem()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun clickOnBookItem() {
|
||||||
|
downloadBookItem?.let(::onBookItemClick)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user