-
Notifications
You must be signed in to change notification settings - Fork 1
Zoom #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kinnerapriyap
wants to merge
12
commits into
main
Choose a base branch
from
zoom
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Zoom #74
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bdc50de
Fix spelling
kinnerapriyap 0d99b4a
Merge branch 'main' into zoom
kinnerapriyap a22c0bd
Fix lint
kinnerapriyap 1766014
Remove view_media_object_preview
kinnerapriyap 2a12518
Add previewMaxScaleFactor to choice
kinnerapriyap c870f11
Add MediaPreviewPageFragment
kinnerapriyap 44ce9d3
Use FragmentStateAdapter instead of RecyclerView.Adapter
kinnerapriyap 6ec8dd7
Format lint
kinnerapriyap 653a042
Update default
kinnerapriyap 34f9250
Merge branch 'main' into zoom
kinnerapriyap 2cc7183
Merge branch 'main' into zoom
kinnerapriyap 430683c
Merge branch 'main' into zoom
kinnerapriyap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
85 changes: 85 additions & 0 deletions
85
sher-gil/src/main/java/com/kinnerapriyap/sugar/mediapreview/MediaPreviewPageFragment.kt
This file contains hidden or 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,85 @@ | ||
| package com.kinnerapriyap.sugar.mediapreview | ||
kinnerapriyap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import android.os.Bundle | ||
kinnerapriyap marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import android.view.LayoutInflater | ||
| import android.view.ScaleGestureDetector | ||
| import android.view.View | ||
| import android.view.ViewGroup | ||
| import android.view.MotionEvent | ||
| import androidx.databinding.DataBindingUtil | ||
| import androidx.fragment.app.Fragment | ||
| import androidx.fragment.app.activityViewModels | ||
| import com.kinnerapriyap.sugar.R | ||
| import com.kinnerapriyap.sugar.ShergilViewModel | ||
| import com.kinnerapriyap.sugar.databinding.FragmentMediaPreviewPageBinding | ||
| import com.kinnerapriyap.sugar.mediagallery.cell.MediaCellDisplayModel | ||
|
|
||
| class MediaPreviewPageFragment : Fragment(), View.OnTouchListener { | ||
|
|
||
| private val viewModel: ShergilViewModel by activityViewModels() | ||
|
|
||
| private var binding: FragmentMediaPreviewPageBinding? = null | ||
|
|
||
| private var scaleFactor = 1f | ||
|
|
||
| private lateinit var scaleListener: ScaleGestureDetector.SimpleOnScaleGestureListener | ||
|
|
||
| private val scaleDetector by lazy { | ||
| ScaleGestureDetector(context, scaleListener) | ||
| } | ||
|
|
||
| private val displayModel: MediaCellDisplayModel? | ||
| get() = arguments?.getParcelable(MEDIA_CELL_DISPLAY_MODEL) | ||
|
|
||
| companion object { | ||
| private const val MEDIA_CELL_DISPLAY_MODEL = "media_cell_display_model" | ||
|
|
||
| @JvmStatic | ||
| fun createInstance(displayModel: MediaCellDisplayModel) = | ||
| MediaPreviewPageFragment().apply { | ||
| arguments = Bundle().apply { | ||
| putParcelable(MEDIA_CELL_DISPLAY_MODEL, displayModel) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun onCreateView( | ||
| inflater: LayoutInflater, container: ViewGroup?, | ||
kinnerapriyap marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| savedInstanceState: Bundle? | ||
| ): View? { | ||
| binding = DataBindingUtil.inflate( | ||
| inflater, | ||
| R.layout.fragment_media_preview_page, | ||
| container, | ||
| false | ||
| ) | ||
| binding?.root?.setOnTouchListener(this) | ||
| return binding?.root | ||
| } | ||
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
| binding?.displayModel = displayModel | ||
| binding?.listener = parentFragment as? MediaPreviewFragment | ||
| scaleListener = object : ScaleGestureDetector.SimpleOnScaleGestureListener() { | ||
|
|
||
| override fun onScale(detector: ScaleGestureDetector): Boolean { | ||
| scaleFactor *= detector.scaleFactor | ||
| scaleFactor = | ||
| 1f.coerceAtLeast( | ||
| scaleFactor.coerceAtMost( | ||
| viewModel.getChoiceSpec().previewMaxScaleFactor | ||
| ) | ||
| ) | ||
| binding?.imageView?.scaleX = scaleFactor | ||
| binding?.imageView?.scaleY = scaleFactor | ||
| return true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun onTouch(v: View?, event: MotionEvent?): Boolean { | ||
| scaleDetector.onTouchEvent(event) | ||
| return true | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.