-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from shockbytes/update-image-picker-dep
Update image picker dep
- Loading branch information
Showing
11 changed files
with
107 additions
and
69 deletions.
There are no files selected for viewing
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
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
30 changes: 7 additions & 23 deletions
30
core/src/main/java/at/shockbytes/dante/core/image/picker/DefaultImagePicking.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 |
---|---|---|
@@ -1,31 +1,15 @@ | ||
package at.shockbytes.dante.core.image.picker | ||
|
||
import android.app.Activity | ||
import android.net.Uri | ||
import androidx.fragment.app.FragmentActivity | ||
import androidx.fragment.app.Fragment | ||
import com.github.dhaval2404.imagepicker.ImagePicker | ||
import io.reactivex.Single | ||
|
||
class DefaultImagePicking(private val imagePickerConfig: ImagePickerConfig) : ImagePicking { | ||
|
||
override fun openGallery(activity: FragmentActivity): Single<Uri> { | ||
return Single.create { emitter -> | ||
ImagePicker.with(activity) | ||
.galleryOnly() | ||
.compress(imagePickerConfig.maxSize) | ||
.maxResultSize(imagePickerConfig.maxWidth, imagePickerConfig.maxHeight) | ||
.start { resultCode, data -> | ||
if (resultCode == Activity.RESULT_OK) { | ||
val url = data?.data | ||
if (url != null) { | ||
emitter.onSuccess(url) | ||
} else { | ||
emitter.tryOnError(NullPointerException("Data url is null!")) | ||
} | ||
} else { | ||
emitter.tryOnError(IllegalStateException("Cannot open gallery! Activity result canceled!")) | ||
} | ||
} | ||
} | ||
override fun openGallery(fragment: Fragment, requestCode: Int) { | ||
ImagePicker.with(fragment) | ||
.galleryOnly() | ||
.compress(imagePickerConfig.maxSize) | ||
.maxResultSize(imagePickerConfig.maxWidth, imagePickerConfig.maxHeight) | ||
.start(requestCode) | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
core/src/main/java/at/shockbytes/dante/core/image/picker/ImagePicking.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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
package at.shockbytes.dante.core.image.picker | ||
|
||
import android.net.Uri | ||
import androidx.fragment.app.FragmentActivity | ||
import io.reactivex.Single | ||
import androidx.fragment.app.Fragment | ||
|
||
interface ImagePicking { | ||
|
||
fun openGallery(activity: FragmentActivity): Single<Uri> | ||
fun openGallery(fragment: Fragment, requestCode: Int) | ||
} |
Oops, something went wrong.