Skip to content

Commit

Permalink
removing the deprecated parcelize import and also added an option to …
Browse files Browse the repository at this point in the history
…show the picker with fragment manager instead of a context
  • Loading branch information
CrazyLegenD committed Dec 2, 2020
1 parent 3150c54 commit 8324498
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.graphics.Bitmap
import android.net.Uri
import android.os.Parcelable
import com.crazylegend.core.dto.BaseCursorModel
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.crazylegend.core.modifiers.base.BaseMultiPickerModifier
import com.crazylegend.core.modifiers.multi.DoneButtonModifier
import com.crazylegend.core.modifiers.multi.SelectIconModifier
import com.crazylegend.core.modifiers.single.ImageModifier
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.crazylegend.audiopicker.modifiers
import com.crazylegend.core.modifiers.TitleTextModifier
import com.crazylegend.core.modifiers.base.BaseSinglePickerModifier
import com.crazylegend.core.modifiers.single.ImageModifier
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest
import android.content.Context
import android.util.Log
import androidx.annotation.RequiresPermission
import androidx.fragment.app.FragmentManager
import com.crazylegend.audiopicker.audios.AudioModel
import com.crazylegend.audiopicker.consts.MULTI_PICKER_BOTTOM_SHEET
import com.crazylegend.audiopicker.consts.MULTI_PICKER_DIALOG
Expand Down Expand Up @@ -46,6 +47,16 @@ object MultiAudioPicker {
}
}

@RequiresPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
fun showPicker(fragmentManager: FragmentManager, modifier: MultiAudioPickerModifier.() -> Unit = {}, audioList: (list: List<AudioModel>) -> Unit = {}) {
val setupModifier = setupModifier(modifier)
with(MultiAudioPickerBottomSheetDialog()) {
addModifier(setupModifier)
onAudiosPicked = onAudiosDSL(audioList)
show(fragmentManager, MULTI_PICKER_BOTTOM_SHEET)
}
}

private inline fun setupModifier(modifier: MultiAudioPickerModifier.() -> Unit) =
MultiAudioPickerModifier().also(modifier)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest
import android.content.Context
import android.util.Log
import androidx.annotation.RequiresPermission
import androidx.fragment.app.FragmentManager
import com.crazylegend.audiopicker.audios.AudioModel
import com.crazylegend.audiopicker.consts.SINGLE_PICKER_BOTTOM_SHEET
import com.crazylegend.audiopicker.consts.SINGLE_PICKER_DIALOG
Expand Down Expand Up @@ -45,5 +46,15 @@ object SingleAudioPicker {
}
}

@RequiresPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
fun showPicker(manager: FragmentManager, pickerModifier: SingleAudioPickerModifier.() -> Unit = {}, onPickedAudio: (audio: AudioModel) -> Unit = {}) {
val modifier = setupModifier(pickerModifier)
with(SingleAudioPickerBottomSheetDialog()) {
addModifier(modifier)
onAudioPicked = onAudioDSL(onPickedAudio)
show(manager, SINGLE_PICKER_BOTTOM_SHEET)
}
}

private inline fun setupModifier(audioPicker: SingleAudioPickerModifier.() -> Unit) = SingleAudioPickerModifier().also(audioPicker)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.os.Build
import android.os.Parcelable
import android.provider.MediaStore
import android.util.Size
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize
import java.util.*
import java.util.concurrent.TimeUnit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.setMargins
import androidx.core.view.setPadding
import androidx.core.view.updateLayoutParams
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.crazylegend.core.modifiers.TitleTextModifier
import com.crazylegend.core.modifiers.multi.DoneButtonModifier
import com.crazylegend.core.modifiers.multi.SelectIconModifier
import com.crazylegend.core.modifiers.single.ImageModifier
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.crazylegend.core.modifiers.base
import android.os.Parcelable
import com.crazylegend.core.modifiers.TitleTextModifier
import com.crazylegend.core.modifiers.single.ImageModifier
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.core.view.setMargins
import androidx.core.view.setPadding
import androidx.core.view.updateLayoutParams
import com.google.android.material.button.MaterialButton
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.core.view.setMargins
import androidx.core.view.setPadding
import androidx.core.view.updateLayoutParams
import androidx.core.widget.ImageViewCompat
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.setMargins
import androidx.core.view.setPadding
import androidx.core.view.updateLayoutParams
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.crazylegend.imagepicker.images
import android.net.Uri
import android.os.Parcelable
import com.crazylegend.core.dto.BaseCursorModel
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize

/**
* Simple data class to hold information about an image included in the device's MediaStore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest.permission.READ_EXTERNAL_STORAGE
import android.content.Context
import android.util.Log
import androidx.annotation.RequiresPermission
import androidx.fragment.app.FragmentManager
import com.crazylegend.core.modifiers.base.BaseMultiPickerModifier
import com.crazylegend.core.setupModifier
import com.crazylegend.extensions.setupManager
Expand Down Expand Up @@ -50,5 +51,18 @@ object MultiImagePicker {
}
}

@RequiresPermission(READ_EXTERNAL_STORAGE)
fun showPicker(
fragmentManager: FragmentManager, multiImagePickerModifier: BaseMultiPickerModifier.() -> Unit = {},
imagesList: (list: List<ImageModel>) -> Unit = {}
) {
val modifier = setupModifier(multiImagePickerModifier)
with(MultiImagePickerBottomSheetDialog()) {
addModifier(modifier)
onImagesPicked = onImagesDSL(imagesList)
show(fragmentManager, MULTI_PICKER_BOTTOM_SHEET)
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest.permission.READ_EXTERNAL_STORAGE
import android.content.Context
import android.util.Log
import androidx.annotation.RequiresPermission
import androidx.fragment.app.FragmentManager
import com.crazylegend.core.modifiers.base.BaseSinglePickerModifier
import com.crazylegend.core.setupModifier
import com.crazylegend.extensions.setupManager
Expand Down Expand Up @@ -51,4 +52,19 @@ object SingleImagePicker {
}


@RequiresPermission(READ_EXTERNAL_STORAGE)
fun showPicker(
fragmentManager: FragmentManager,
pickerModifier: BaseSinglePickerModifier.() -> Unit = {},
onPickedImage: (image: ImageModel) -> Unit = {}
) {
val modifier = setupModifier(pickerModifier)
with(SingleImagePickerBottomSheetDialog()) {
addModifier(modifier)
onImagePicked = onImageDSL(onPickedImage)
show(fragmentManager, SINGLE_PICKER_BOTTOM_SHEET)
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest
import android.content.Context
import android.util.Log
import androidx.annotation.RequiresPermission
import androidx.fragment.app.FragmentManager
import com.crazylegend.core.modifiers.base.BaseMultiPickerModifier
import com.crazylegend.core.setupModifier
import com.crazylegend.extensions.setupManager
Expand Down Expand Up @@ -47,4 +48,14 @@ object MultiVideoPicker {
}
}

@RequiresPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
fun showPicker(fragmentManager: FragmentManager, modifier: BaseMultiPickerModifier.() -> Unit = {}, videoList: (list: List<VideoModel>) -> Unit = {}) {
val setupModifier = setupModifier(modifier)
with(MultiVideoPickerBottomSheetDialog()) {
addModifier(setupModifier)
onVideosPicked = onVideosDSL(videoList)
show(fragmentManager, MULTI_PICKER_BOTTOM_SHEET)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.Manifest
import android.content.Context
import android.util.Log
import androidx.annotation.RequiresPermission
import androidx.fragment.app.FragmentManager
import com.crazylegend.core.modifiers.base.BaseSinglePickerModifier
import com.crazylegend.core.setupModifier
import com.crazylegend.extensions.setupManager
Expand Down Expand Up @@ -46,5 +47,15 @@ object SingleVideoPicker {
}
}

@RequiresPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
fun showPicker(fragmentManager: FragmentManager, pickerModifier: BaseSinglePickerModifier.() -> Unit = {}, onPickedVideo: (video: VideoModel) -> Unit = {}) {
val modifier = setupModifier(pickerModifier)
with(SingleVideoPickerBottomSheetDialog()) {
addModifier(modifier)
onVideoPicked = onVideoDSL(onPickedVideo)
show(fragmentManager, SINGLE_PICKER_BOTTOM_SHEET)
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.crazylegend.videopicker.videos
import android.net.Uri
import android.os.Parcelable
import com.crazylegend.core.dto.BaseCursorModel
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize


/**
Expand Down

0 comments on commit 8324498

Please sign in to comment.