From 9d90b480e20620d1a3f477a34d1a9de36c4e84b4 Mon Sep 17 00:00:00 2001 From: Sean Mac Gillicuddy Date: Mon, 30 Mar 2020 10:51:19 +0100 Subject: [PATCH] #1977 Can't Download Item with no description - propogate nullability through models --- .../library_view/adapter/LibraryListItem.kt | 2 +- .../kiwix/kiwixmobile/core/dao/FetchDownloadDao.kt | 2 +- .../core/dao/entities/BookOnDiskEntity.kt | 2 +- .../core/dao/entities/FetchDownloadEntity.kt | 2 +- .../core/downloader/model/DownloadItem.kt | 2 +- .../core/downloader/model/DownloadRequest.kt | 13 ++----------- .../core/entity/LibraryNetworkEntity.java | 4 +++- 7 files changed, 10 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt index b9884f7e5..da856fac8 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/zim_manager/library_view/adapter/LibraryListItem.kt @@ -62,7 +62,7 @@ sealed class LibraryListItem { val downloadId: Long, val favIcon: Base64String, val title: String, - val description: String, + val description: String?, val bytesDownloaded: Long, val totalSizeBytes: Long, val progress: Int, diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/FetchDownloadDao.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/FetchDownloadDao.kt index 84acad0a0..e3f9dcf3d 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/FetchDownloadDao.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/FetchDownloadDao.kt @@ -85,7 +85,7 @@ class FetchDownloadDao @Inject constructor( box.store.callInTx { if (doesNotAlreadyExist(book)) { insert( - downloadRequester.enqueue(DownloadRequest(url, book)), + downloadRequester.enqueue(DownloadRequest(url)), book = book ) } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookOnDiskEntity.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookOnDiskEntity.kt index 4d0218c0b..c9e7f3b93 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookOnDiskEntity.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/BookOnDiskEntity.kt @@ -33,7 +33,7 @@ data class BookOnDiskEntity( val file: File = File(""), val bookId: String, val title: String, - val description: String, + val description: String?, val language: String, val creator: String, val publisher: String, diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/FetchDownloadEntity.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/FetchDownloadEntity.kt index 484c981b4..ebdde4b7b 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/FetchDownloadEntity.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/dao/entities/FetchDownloadEntity.kt @@ -41,7 +41,7 @@ data class FetchDownloadEntity( val progress: Int = -1, val bookId: String, val title: String, - val description: String, + val description: String?, val language: String, val creator: String, val publisher: String, diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadItem.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadItem.kt index 50297b5e2..fa7b81688 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadItem.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadItem.kt @@ -36,7 +36,7 @@ data class DownloadItem( val downloadId: Long, val favIcon: Base64String, val title: String, - val description: String, + val description: String?, val bytesDownloaded: Long, val totalSizeBytes: Long, val progress: Int, diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadRequest.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadRequest.kt index f88f38245..d06080733 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadRequest.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/downloader/model/DownloadRequest.kt @@ -18,22 +18,13 @@ package org.kiwix.kiwixmobile.core.downloader.model import android.net.Uri -import org.kiwix.kiwixmobile.core.entity.LibraryNetworkEntity.Book import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.utils.StorageUtils -data class DownloadRequest( - val urlString: String, - val title: String, - val description: String -) { +data class DownloadRequest(val urlString: String) { val uri: Uri get() = Uri.parse(urlString) - constructor(url: String, book: Book) : this(url, book.title, book.description) - fun getDestination(sharedPreferenceUtil: SharedPreferenceUtil): String = - "${sharedPreferenceUtil.prefStorage}/Kiwix/${ - StorageUtils.getFileNameFromUrl(urlString) - }" + "${sharedPreferenceUtil.prefStorage}/Kiwix/${StorageUtils.getFileNameFromUrl(urlString)}" } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/entity/LibraryNetworkEntity.java b/core/src/main/java/org/kiwix/kiwixmobile/core/entity/LibraryNetworkEntity.java index 203961aef..5c6f93aa9 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/entity/LibraryNetworkEntity.java +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/entity/LibraryNetworkEntity.java @@ -17,6 +17,7 @@ */ package org.kiwix.kiwixmobile.core.entity; +import androidx.annotation.Nullable; import java.io.File; import java.io.Serializable; import java.util.LinkedList; @@ -51,7 +52,7 @@ public class LibraryNetworkEntity { public String title; @Attribute(name = "description", required = false) - public String description; + @Nullable public String description; @Attribute(name = "language", required = false) public String language; @@ -103,6 +104,7 @@ public class LibraryNetworkEntity { return this.title; } + @Nullable public String getDescription() { return this.description; }