Skip to content

Commit

Permalink
added result to selected from gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
celalbaydar committed Feb 21, 2024
1 parent e4be728 commit 6192760
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pix/src/main/java/io/ak1/pix/helpers/UsabilityHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ enum class Status {

data class Results(
var data: List<Uri> = ArrayList(),
var status: Status = Status.SUCCESS
var status: Status = Status.SUCCESS,
var selectedFromGallery: Boolean
)

fun AppCompatActivity.addPixImagePickerToActivity(
Expand Down
3 changes: 2 additions & 1 deletion pix/src/main/java/io/ak1/pix/ui/camera/CameraFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class CameraFragment(private val resultCallback: ((Results) -> Unit)? = null) :
resultCallback?.invoke(
Results(
data = results,
status = status
status = status,
selectedFromGallery = false
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class ImagePickerFragment(private val resultCallback: ((Results) -> Unit)? = nul
viewModel.changeSelectionList(HashSet())
options.preSelectedUrls.clear()
val results = set.map { it.contentUrl }
resultCallback?.invoke(Results(results))
resultCallback?.invoke(Results(results, selectedFromGallery = true))
}
}
viewModel.onBackPressedResult.observe(requireActivity()) { event ->
Expand All @@ -211,7 +211,8 @@ class ImagePickerFragment(private val resultCallback: ((Results) -> Unit)? = nul
resultCallback?.invoke(
Results(
results,
Status.BACK_PRESSED
Status.BACK_PRESSED,
selectedFromGallery = true
)
)
}
Expand Down Expand Up @@ -269,8 +270,9 @@ class ImagePickerFragment(private val resultCallback: ((Results) -> Unit)? = nul
gridLayout.fastscrollHandle.isSelected = true
handler.removeCallbacks(mScrollbarHider)
cancelAnimation(mScrollbarAnimator, mBubbleAnimator)
if (gridLayout.fastscrollScrollbar.isVisible.not()&& (gridLayout.recyclerView.computeVerticalScrollRange() - mViewHeight > 0)) {
mScrollbarAnimator = showScrollbar(gridLayout.fastscrollScrollbar, requireActivity())
if (gridLayout.fastscrollScrollbar.isVisible.not() && (gridLayout.recyclerView.computeVerticalScrollRange() - mViewHeight > 0)) {
mScrollbarAnimator =
showScrollbar(gridLayout.fastscrollScrollbar, requireActivity())
}
showBubble()
val y = event.rawY
Expand All @@ -281,12 +283,14 @@ class ImagePickerFragment(private val resultCallback: ((Results) -> Unit)? = nul

return true
}

MotionEvent.ACTION_MOVE -> {
val y = event.rawY
binding.setViewPositions(y - toolbarHeight)
binding.setRecyclerViewPosition(y, mainImageAdapter)
return true
}

MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
v?.parent?.requestDisallowInterceptTouchEvent(false)
binding.gridLayout.fastscrollHandle.isSelected = false
Expand Down

0 comments on commit 6192760

Please sign in to comment.