Skip to content

Commit

Permalink
Simplify the Cover editing by only referring to the book id, not the
Browse files Browse the repository at this point in the history
whole book.
  • Loading branch information
PaulWoitaschek committed Jan 5, 2019
1 parent a012bf6 commit 55a4059
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ class BookOverviewController : BaseController(),
private var playPauseDrawableSetter: PlayPauseDrawableSetter by clearAfterDestroyView()
private var adapter: BookOverviewAdapter by clearAfterDestroyView()
private var currentTapTarget by clearAfterDestroyViewNullable<TapTargetView>()
private var menuBook: Book? = null
private var menuBookId: UUID? = null
private var useGrid = false
// private var columnCount = 1

override fun onViewCreated() {
val gridMenuItem = setupToolbar()
Expand Down Expand Up @@ -162,12 +161,12 @@ class BookOverviewController : BaseController(),
COVER_FROM_GALLERY -> {
if (resultCode == Activity.RESULT_OK) {
val imageUri = data?.data
val book = menuBook
if (imageUri == null || book == null) {
val bookId = menuBookId
if (imageUri == null || bookId == null) {
return
}

EditCoverDialogController(this, book, imageUri).showDialog(router)
EditCoverDialogController(this, bookId, imageUri).showDialog(router)
}
}
else -> super.onActivityResult(requestCode, resultCode, data)
Expand Down Expand Up @@ -270,7 +269,7 @@ class BookOverviewController : BaseController(),
}

override fun onFileCoverRequested(book: Book) {
menuBook = book
menuBookId = book.id
val galleryPickerIntent = Intent(Intent.ACTION_PICK)
galleryPickerIntent.type = "image/*"
startActivityForResult(galleryPickerIntent, COVER_FROM_GALLERY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.afollestad.materialdialogs.MaterialDialog
import com.bluelinelabs.conductor.Controller
import com.squareup.picasso.Picasso
import de.ph1b.audiobook.R
import de.ph1b.audiobook.data.Book
import de.ph1b.audiobook.data.repo.BookRepository
import de.ph1b.audiobook.injection.appComponent
import de.ph1b.audiobook.misc.DialogController
Expand Down Expand Up @@ -122,12 +121,12 @@ class EditCoverDialogController(args: Bundle) : DialogController(args) {

operator fun <T> invoke(
target: T,
book: Book,
bookId: UUID,
uri: Uri
): EditCoverDialogController where T : Controller, T : Callback {
val args = Bundle().apply {
putString(NI_COVER_URI, uri.toString())
putUUID(NI_BOOK_ID, book.id)
putUUID(NI_BOOK_ID, bookId)
}
return EditCoverDialogController(args).apply {
targetController = target
Expand Down

0 comments on commit 55a4059

Please sign in to comment.