-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle editing the book from the category controller.
- Loading branch information
1 parent
55a4059
commit 1c41152
Showing
6 changed files
with
118 additions
and
47 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/src/main/java/de/ph1b/audiobook/features/GalleryPicker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.ph1b.audiobook.features | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import com.bluelinelabs.conductor.Controller | ||
import de.ph1b.audiobook.features.bookOverview.EditCoverDialogController | ||
import java.util.UUID | ||
import javax.inject.Inject | ||
|
||
private const val REQUEST_CODE = 7 | ||
|
||
class GalleryPicker | ||
@Inject constructor() { | ||
|
||
private var pickForBookId: UUID? = null | ||
|
||
fun pick(bookId: UUID, controller: Controller) { | ||
pickForBookId = bookId | ||
val intent = Intent(Intent.ACTION_PICK) | ||
.setType("image/*") | ||
controller.startActivityForResult(intent, REQUEST_CODE) | ||
} | ||
|
||
fun parse(requestCode: Int, resultCode: Int, data: Intent?): EditCoverDialogController.Arguments? { | ||
if (requestCode != REQUEST_CODE) { | ||
return null | ||
} | ||
return if (resultCode == Activity.RESULT_OK) { | ||
val imageUri = data?.data | ||
val bookId = pickForBookId | ||
if (imageUri == null || bookId == null) { | ||
null | ||
} else { | ||
EditCoverDialogController.Arguments(imageUri, bookId) | ||
} | ||
} else { | ||
null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters