mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
renaming some variables, no real code change
This commit is contained in:
parent
25131bd75b
commit
855f9abad5
2 changed files with 117 additions and 117 deletions
|
@ -62,29 +62,29 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
"google nexus 5x"
|
"google nexus 5x"
|
||||||
)
|
)
|
||||||
|
|
||||||
private var isFragmentVisible = false
|
private var mIsFragmentVisible = false
|
||||||
private var isFullscreen = false
|
private var mIsFullscreen = false
|
||||||
private var wasInit = false
|
private var mWasInit = false
|
||||||
private var isPanorama = false
|
private var mIsPanorama = false
|
||||||
private var isSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
|
private var mIsSubsamplingVisible = false // checking view.visibility is unreliable, use an extra variable for it
|
||||||
private var imageOrientation = -1
|
private var mImageOrientation = -1
|
||||||
private var mOriginalSubsamplingScale = 0f
|
private var mOriginalSubsamplingScale = 0f
|
||||||
private var loadZoomableViewHandler = Handler()
|
private var mIoadZoomableViewHandler = Handler()
|
||||||
private var mScreenWidth = 0
|
private var mScreenWidth = 0
|
||||||
private var mScreenHeight = 0
|
private var mScreenHeight = 0
|
||||||
|
|
||||||
private var storedShowExtendedDetails = false
|
private var mStoredShowExtendedDetails = false
|
||||||
private var storedHideExtendedDetails = false
|
private var mStoredHideExtendedDetails = false
|
||||||
private var storedAllowDeepZoomableImages = false
|
private var mStoredAllowDeepZoomableImages = false
|
||||||
private var storedShowHighestQuality = false
|
private var mStoredShowHighestQuality = false
|
||||||
private var storedAllowOneFingerZoom = false
|
private var mStoredAllowOneFingerZoom = false
|
||||||
private var storedExtendedDetails = 0
|
private var mStoredExtendedDetails = 0
|
||||||
|
|
||||||
lateinit var view: ViewGroup
|
private lateinit var mView: ViewGroup
|
||||||
lateinit var medium: Medium
|
private lateinit var mMedium: Medium
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
view = (inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup).apply {
|
mView = (inflater.inflate(R.layout.pager_photo_item, container, false) as ViewGroup).apply {
|
||||||
subsampling_view.setOnClickListener { photoClicked() }
|
subsampling_view.setOnClickListener { photoClicked() }
|
||||||
photo_view.setOnClickListener { photoClicked() }
|
photo_view.setOnClickListener { photoClicked() }
|
||||||
gif_view.setOnClickListener { photoClicked() }
|
gif_view.setOnClickListener { photoClicked() }
|
||||||
|
@ -96,7 +96,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
instant_next_item.parentView = container
|
instant_next_item.parentView = container
|
||||||
|
|
||||||
photo_brightness_controller.initialize(activity!!, slide_info, true, container) { x, y ->
|
photo_brightness_controller.initialize(activity!!, slide_info, true, container) { x, y ->
|
||||||
view.apply {
|
mView.apply {
|
||||||
if (subsampling_view.isVisible()) {
|
if (subsampling_view.isVisible()) {
|
||||||
subsampling_view.sendFakeClick(x, y)
|
subsampling_view.sendFakeClick(x, y)
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,7 +112,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
subsampling_view.setOnTouchListener { v, event ->
|
subsampling_view.setOnTouchListener { v, event ->
|
||||||
if (view.subsampling_view.scale == mOriginalSubsamplingScale) {
|
if (mView.subsampling_view.scale == mOriginalSubsamplingScale) {
|
||||||
handleEvent(event)
|
handleEvent(event)
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
|
@ -122,16 +122,16 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
checkScreenDimensions()
|
checkScreenDimensions()
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
if (!isFragmentVisible && activity is PhotoActivity) {
|
if (!mIsFragmentVisible && activity is PhotoActivity) {
|
||||||
isFragmentVisible = true
|
mIsFragmentVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
mMedium = arguments!!.getSerializable(MEDIUM) as Medium
|
||||||
if (medium.path.startsWith("content://") && !medium.path.startsWith("content://mms/")) {
|
if (mMedium.path.startsWith("content://") && !mMedium.path.startsWith("content://mms/")) {
|
||||||
val originalPath = medium.path
|
val originalPath = mMedium.path
|
||||||
medium.path = context!!.getRealPathFromURI(Uri.parse(originalPath)) ?: medium.path
|
mMedium.path = context!!.getRealPathFromURI(Uri.parse(originalPath)) ?: mMedium.path
|
||||||
|
|
||||||
if (medium.path.isEmpty()) {
|
if (mMedium.path.isEmpty()) {
|
||||||
var out: FileOutputStream? = null
|
var out: FileOutputStream? = null
|
||||||
try {
|
try {
|
||||||
var inputStream = context!!.contentResolver.openInputStream(Uri.parse(originalPath))
|
var inputStream = context!!.contentResolver.openInputStream(Uri.parse(originalPath))
|
||||||
|
@ -148,24 +148,24 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val file = File(context!!.externalCacheDir, Uri.parse(originalPath).lastPathSegment)
|
val file = File(context!!.externalCacheDir, Uri.parse(originalPath).lastPathSegment)
|
||||||
out = FileOutputStream(file)
|
out = FileOutputStream(file)
|
||||||
rotated.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
rotated.compress(Bitmap.CompressFormat.JPEG, 100, out)
|
||||||
medium.path = file.absolutePath
|
mMedium.path = file.absolutePath
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
activity!!.toast(R.string.unknown_error_occurred)
|
activity!!.toast(R.string.unknown_error_occurred)
|
||||||
return view
|
return mView
|
||||||
} finally {
|
} finally {
|
||||||
out?.close()
|
out?.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isFullscreen = activity!!.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
mIsFullscreen = activity!!.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
loadImage()
|
loadImage()
|
||||||
initExtendedDetails()
|
initExtendedDetails()
|
||||||
wasInit = true
|
mWasInit = true
|
||||||
checkIfPanorama()
|
checkIfPanorama()
|
||||||
updateInstantSwitchWidths()
|
updateInstantSwitchWidths()
|
||||||
|
|
||||||
return view
|
return mView
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
@ -176,17 +176,17 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
val config = context!!.config
|
val config = context!!.config
|
||||||
if (wasInit && (config.showExtendedDetails != storedShowExtendedDetails || config.extendedDetails != storedExtendedDetails)) {
|
if (mWasInit && (config.showExtendedDetails != mStoredShowExtendedDetails || config.extendedDetails != mStoredExtendedDetails)) {
|
||||||
initExtendedDetails()
|
initExtendedDetails()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wasInit) {
|
if (mWasInit) {
|
||||||
if (config.allowZoomingImages != storedAllowDeepZoomableImages || config.showHighestQuality != storedShowHighestQuality ||
|
if (config.allowZoomingImages != mStoredAllowDeepZoomableImages || config.showHighestQuality != mStoredShowHighestQuality ||
|
||||||
config.oneFingerZoom != storedAllowOneFingerZoom) {
|
config.oneFingerZoom != mStoredAllowOneFingerZoom) {
|
||||||
isSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
view.subsampling_view.beGone()
|
mView.subsampling_view.beGone()
|
||||||
loadImage()
|
loadImage()
|
||||||
} else if (medium.isGIF()) {
|
} else if (mMedium.isGIF()) {
|
||||||
loadGif()
|
loadGif()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
val allowPhotoGestures = config.allowPhotoGestures
|
val allowPhotoGestures = config.allowPhotoGestures
|
||||||
val allowInstantChange = config.allowInstantChange
|
val allowInstantChange = config.allowInstantChange
|
||||||
|
|
||||||
view.apply {
|
mView.apply {
|
||||||
photo_brightness_controller.beVisibleIf(allowPhotoGestures)
|
photo_brightness_controller.beVisibleIf(allowPhotoGestures)
|
||||||
instant_prev_item.beVisibleIf(allowInstantChange)
|
instant_prev_item.beVisibleIf(allowInstantChange)
|
||||||
instant_next_item.beVisibleIf(allowInstantChange)
|
instant_next_item.beVisibleIf(allowInstantChange)
|
||||||
|
@ -206,9 +206,9 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
override fun setMenuVisibility(menuVisible: Boolean) {
|
override fun setMenuVisibility(menuVisible: Boolean) {
|
||||||
super.setMenuVisibility(menuVisible)
|
super.setMenuVisibility(menuVisible)
|
||||||
isFragmentVisible = menuVisible
|
mIsFragmentVisible = menuVisible
|
||||||
if (wasInit) {
|
if (mWasInit) {
|
||||||
if (!medium.isGIF()) {
|
if (!mMedium.isGIF()) {
|
||||||
photoFragmentVisibilityChanged(menuVisible)
|
photoFragmentVisibilityChanged(menuVisible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,12 +216,12 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
context!!.config.apply {
|
context!!.config.apply {
|
||||||
storedShowExtendedDetails = showExtendedDetails
|
mStoredShowExtendedDetails = showExtendedDetails
|
||||||
storedHideExtendedDetails = hideExtendedDetails
|
mStoredHideExtendedDetails = hideExtendedDetails
|
||||||
storedAllowDeepZoomableImages = allowZoomingImages
|
mStoredAllowDeepZoomableImages = allowZoomingImages
|
||||||
storedShowHighestQuality = showHighestQuality
|
mStoredShowHighestQuality = showHighestQuality
|
||||||
storedAllowOneFingerZoom = oneFingerZoom
|
mStoredAllowOneFingerZoom = oneFingerZoom
|
||||||
storedExtendedDetails = extendedDetails
|
mStoredExtendedDetails = extendedDetails
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,26 +265,26 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadImage() {
|
private fun loadImage() {
|
||||||
imageOrientation = getImageOrientation()
|
mImageOrientation = getImageOrientation()
|
||||||
when {
|
when {
|
||||||
medium.isGIF() -> loadGif()
|
mMedium.isGIF() -> loadGif()
|
||||||
medium.isSVG() -> loadSVG()
|
mMedium.isSVG() -> loadSVG()
|
||||||
else -> loadBitmap()
|
else -> loadBitmap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadGif() {
|
private fun loadGif() {
|
||||||
try {
|
try {
|
||||||
val pathToLoad = getPathToLoad(medium)
|
val pathToLoad = getPathToLoad(mMedium)
|
||||||
val source = if (pathToLoad.startsWith("content://") || pathToLoad.startsWith("file://")) {
|
val source = if (pathToLoad.startsWith("content://") || pathToLoad.startsWith("file://")) {
|
||||||
InputSource.UriSource(context!!.contentResolver, Uri.parse(pathToLoad))
|
InputSource.UriSource(context!!.contentResolver, Uri.parse(pathToLoad))
|
||||||
} else {
|
} else {
|
||||||
InputSource.FileSource(pathToLoad)
|
InputSource.FileSource(pathToLoad)
|
||||||
}
|
}
|
||||||
|
|
||||||
view.photo_view.beGone()
|
mView.photo_view.beGone()
|
||||||
view.gif_view.beVisible()
|
mView.gif_view.beVisible()
|
||||||
view.gif_view.setInputSource(source)
|
mView.gif_view.setInputSource(source)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
loadBitmap()
|
loadBitmap()
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
|
@ -296,13 +296,13 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
Glide.with(context!!)
|
Glide.with(context!!)
|
||||||
.`as`(PictureDrawable::class.java)
|
.`as`(PictureDrawable::class.java)
|
||||||
.listener(SvgSoftwareLayerSetter())
|
.listener(SvgSoftwareLayerSetter())
|
||||||
.load(medium.path)
|
.load(mMedium.path)
|
||||||
.into(view.photo_view)
|
.into(mView.photo_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadBitmap(degrees: Int = 0) {
|
private fun loadBitmap(degrees: Int = 0) {
|
||||||
checkScreenDimensions()
|
checkScreenDimensions()
|
||||||
var pathToLoad = if (medium.path.startsWith("content://")) medium.path else "file://${medium.path}"
|
var pathToLoad = if (mMedium.path.startsWith("content://")) mMedium.path else "file://${mMedium.path}"
|
||||||
pathToLoad = pathToLoad.replace("%", "%25").replace("#", "%23")
|
pathToLoad = pathToLoad.replace("%", "%25").replace("#", "%23")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -315,10 +315,10 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
picasso.rotate(degrees.toFloat())
|
picasso.rotate(degrees.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
picasso.into(view.photo_view, object : Callback {
|
picasso.into(mView.photo_view, object : Callback {
|
||||||
override fun onSuccess() {
|
override fun onSuccess() {
|
||||||
view.photo_view.isZoomable = degrees != 0 || context?.config?.allowZoomingImages == false
|
mView.photo_view.isZoomable = degrees != 0 || context?.config?.allowZoomingImages == false
|
||||||
if (isFragmentVisible && degrees == 0) {
|
if (mIsFragmentVisible && degrees == 0) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,53 +337,53 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
var targetWidth = if (mScreenWidth == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenWidth
|
var targetWidth = if (mScreenWidth == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenWidth
|
||||||
var targetHeight = if (mScreenHeight == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenHeight
|
var targetHeight = if (mScreenHeight == 0) com.bumptech.glide.request.target.Target.SIZE_ORIGINAL else mScreenHeight
|
||||||
|
|
||||||
if (imageOrientation == ORIENTATION_ROTATE_90) {
|
if (mImageOrientation == ORIENTATION_ROTATE_90) {
|
||||||
targetWidth = targetHeight
|
targetWidth = targetHeight
|
||||||
targetHeight = com.bumptech.glide.request.target.Target.SIZE_ORIGINAL
|
targetHeight = com.bumptech.glide.request.target.Target.SIZE_ORIGINAL
|
||||||
}
|
}
|
||||||
|
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(medium.path.getFileSignature())
|
.signature(mMedium.path.getFileSignature())
|
||||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.override(targetWidth, targetHeight)
|
.override(targetWidth, targetHeight)
|
||||||
|
|
||||||
Glide.with(context!!)
|
Glide.with(context!!)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(getPathToLoad(medium))
|
.load(getPathToLoad(mMedium))
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.listener(object : RequestListener<Bitmap> {
|
.listener(object : RequestListener<Bitmap> {
|
||||||
override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, isFirstResource: Boolean) = false
|
override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, isFirstResource: Boolean) = false
|
||||||
|
|
||||||
override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target<Bitmap>?, dataSource: com.bumptech.glide.load.DataSource?, isFirstResource: Boolean): Boolean {
|
override fun onResourceReady(resource: Bitmap?, model: Any?, target: Target<Bitmap>?, dataSource: com.bumptech.glide.load.DataSource?, isFirstResource: Boolean): Boolean {
|
||||||
if (isFragmentVisible) {
|
if (mIsFragmentVisible) {
|
||||||
scheduleZoomableView()
|
scheduleZoomableView()
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}).into(view.photo_view)
|
}).into(mView.photo_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openPanorama() {
|
private fun openPanorama() {
|
||||||
Intent(context, PanoramaPhotoActivity::class.java).apply {
|
Intent(context, PanoramaPhotoActivity::class.java).apply {
|
||||||
putExtra(PATH, medium.path)
|
putExtra(PATH, mMedium.path)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scheduleZoomableView() {
|
private fun scheduleZoomableView() {
|
||||||
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
loadZoomableViewHandler.postDelayed({
|
mIoadZoomableViewHandler.postDelayed({
|
||||||
if (isFragmentVisible && context?.config?.allowZoomingImages == true && medium.isImage() && !isSubsamplingVisible) {
|
if (mIsFragmentVisible && context?.config?.allowZoomingImages == true && mMedium.isImage() && !mIsSubsamplingVisible) {
|
||||||
addZoomableView()
|
addZoomableView()
|
||||||
}
|
}
|
||||||
}, ZOOMABLE_VIEW_LOAD_DELAY)
|
}, ZOOMABLE_VIEW_LOAD_DELAY)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addZoomableView() {
|
private fun addZoomableView() {
|
||||||
val rotation = degreesForRotation(imageOrientation)
|
val rotation = degreesForRotation(mImageOrientation)
|
||||||
val path = getPathToLoad(medium)
|
val path = getPathToLoad(mMedium)
|
||||||
isSubsamplingVisible = true
|
mIsSubsamplingVisible = true
|
||||||
|
|
||||||
val bitmapDecoder = object : DecoderFactory<ImageDecoder> {
|
val bitmapDecoder = object : DecoderFactory<ImageDecoder> {
|
||||||
override fun make() = PicassoDecoder(path, Picasso.get(), rotation)
|
override fun make() = PicassoDecoder(path, Picasso.get(), rotation)
|
||||||
|
@ -394,7 +394,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val config = context!!.config
|
val config = context!!.config
|
||||||
view.subsampling_view.apply {
|
mView.subsampling_view.apply {
|
||||||
setMaxTileSize(if (config.showHighestQuality) Integer.MAX_VALUE else 4096)
|
setMaxTileSize(if (config.showHighestQuality) Integer.MAX_VALUE else 4096)
|
||||||
setMinimumTileDpi(if (config.showHighestQuality) -1 else getMinTileDpi())
|
setMinimumTileDpi(if (config.showHighestQuality) -1 else getMinTileDpi())
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
|
@ -414,8 +414,8 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
override fun onReady() {
|
override fun onReady() {
|
||||||
background = ColorDrawable(if (config.blackBackground) Color.BLACK else config.backgroundColor)
|
background = ColorDrawable(if (config.blackBackground) Color.BLACK else config.backgroundColor)
|
||||||
val useWidth = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sHeight else sWidth
|
val useWidth = if (mImageOrientation == ORIENTATION_ROTATE_90 || mImageOrientation == ORIENTATION_ROTATE_270) sHeight else sWidth
|
||||||
val useHeight = if (imageOrientation == ORIENTATION_ROTATE_90 || imageOrientation == ORIENTATION_ROTATE_270) sWidth else sHeight
|
val useHeight = if (mImageOrientation == ORIENTATION_ROTATE_90 || mImageOrientation == ORIENTATION_ROTATE_270) sWidth else sHeight
|
||||||
setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight))
|
setDoubleTapZoomScale(getDoubleTapZoomScale(useWidth, useHeight))
|
||||||
mOriginalSubsamplingScale = scale
|
mOriginalSubsamplingScale = scale
|
||||||
}
|
}
|
||||||
|
@ -427,15 +427,15 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onImageLoadError(e: Exception) {
|
override fun onImageLoadError(e: Exception) {
|
||||||
view.photo_view.isZoomable = true
|
mView.photo_view.isZoomable = true
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
isSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
beGone()
|
beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreviewLoadError(e: Exception) {
|
override fun onPreviewLoadError(e: Exception) {
|
||||||
background = ColorDrawable(Color.TRANSPARENT)
|
background = ColorDrawable(Color.TRANSPARENT)
|
||||||
isSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
beGone()
|
beGone()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -455,9 +455,9 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkIfPanorama() {
|
private fun checkIfPanorama() {
|
||||||
isPanorama = try {
|
mIsPanorama = try {
|
||||||
val inputStream = if (medium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(medium.path)) else File(medium.path).inputStream()
|
val inputStream = if (mMedium.path.startsWith("content:/")) context!!.contentResolver.openInputStream(Uri.parse(mMedium.path)) else File(mMedium.path).inputStream()
|
||||||
val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, medium.name), HashMap<String, Any>())
|
val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, mMedium.name), HashMap<String, Any>())
|
||||||
imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) || imageParser.contains("<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>", true)
|
imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) || imageParser.contains("<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>", true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
false
|
false
|
||||||
|
@ -465,7 +465,7 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
view.panorama_outline.beVisibleIf(isPanorama)
|
mView.panorama_outline.beVisibleIf(mIsPanorama)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getImageOrientation(): Int {
|
private fun getImageOrientation(): Int {
|
||||||
|
@ -473,11 +473,11 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
var orient = defaultOrientation
|
var orient = defaultOrientation
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val pathToLoad = getPathToLoad(medium)
|
val pathToLoad = getPathToLoad(mMedium)
|
||||||
val exif = android.media.ExifInterface(pathToLoad)
|
val exif = android.media.ExifInterface(pathToLoad)
|
||||||
orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation)
|
orient = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, defaultOrientation)
|
||||||
|
|
||||||
if (orient == defaultOrientation || medium.path.startsWith(OTG_PATH)) {
|
if (orient == defaultOrientation || mMedium.path.startsWith(OTG_PATH)) {
|
||||||
val uri = if (pathToLoad.startsWith("content:/")) Uri.parse(pathToLoad) else Uri.fromFile(File(pathToLoad))
|
val uri = if (pathToLoad.startsWith("content:/")) Uri.parse(pathToLoad) else Uri.fromFile(File(pathToLoad))
|
||||||
val inputStream = context!!.contentResolver.openInputStream(uri)
|
val inputStream = context!!.contentResolver.openInputStream(uri)
|
||||||
val exif2 = ExifInterface()
|
val exif2 = ExifInterface()
|
||||||
|
@ -510,47 +510,47 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun rotateImageViewBy(degrees: Int) {
|
fun rotateImageViewBy(degrees: Int) {
|
||||||
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
view.subsampling_view.beGone()
|
mView.subsampling_view.beGone()
|
||||||
isSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
loadBitmap(degrees)
|
loadBitmap(degrees)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initExtendedDetails() {
|
private fun initExtendedDetails() {
|
||||||
if (context!!.config.showExtendedDetails) {
|
if (context!!.config.showExtendedDetails) {
|
||||||
view.photo_details.apply {
|
mView.photo_details.apply {
|
||||||
beInvisible() // make it invisible so we can measure it, but not show yet
|
beInvisible() // make it invisible so we can measure it, but not show yet
|
||||||
text = getMediumExtendedDetails(medium)
|
text = getMediumExtendedDetails(mMedium)
|
||||||
onGlobalLayout {
|
onGlobalLayout {
|
||||||
if (isAdded) {
|
if (isAdded) {
|
||||||
val realY = getExtendedDetailsY(height)
|
val realY = getExtendedDetailsY(height)
|
||||||
if (realY > 0) {
|
if (realY > 0) {
|
||||||
y = realY
|
y = realY
|
||||||
beVisibleIf(text.isNotEmpty())
|
beVisibleIf(text.isNotEmpty())
|
||||||
alpha = if (!context!!.config.hideExtendedDetails || !isFullscreen) 1f else 0f
|
alpha = if (!context!!.config.hideExtendedDetails || !mIsFullscreen) 1f else 0f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
view.photo_details.beGone()
|
mView.photo_details.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
if (activity?.isDestroyed == false) {
|
if (activity?.isDestroyed == false) {
|
||||||
view.subsampling_view.recycle()
|
mView.subsampling_view.recycle()
|
||||||
}
|
}
|
||||||
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
|
|
||||||
// avoid GIFs being skewed, played in wrong aspect ratio
|
// avoid GIFs being skewed, played in wrong aspect ratio
|
||||||
if (medium.isGIF()) {
|
if (mMedium.isGIF()) {
|
||||||
view.onGlobalLayout {
|
mView.onGlobalLayout {
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
loadGif()
|
loadGif()
|
||||||
}, 50)
|
}, 50)
|
||||||
|
@ -566,10 +566,10 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun hideZoomableView() {
|
private fun hideZoomableView() {
|
||||||
if (context?.config?.allowZoomingImages == true) {
|
if (context?.config?.allowZoomingImages == true) {
|
||||||
isSubsamplingVisible = false
|
mIsSubsamplingVisible = false
|
||||||
view.subsampling_view.recycle()
|
mView.subsampling_view.recycle()
|
||||||
view.subsampling_view.beGone()
|
mView.subsampling_view.beGone()
|
||||||
loadZoomableViewHandler.removeCallbacksAndMessages(null)
|
mIoadZoomableViewHandler.removeCallbacksAndMessages(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,17 +579,17 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun updateInstantSwitchWidths() {
|
private fun updateInstantSwitchWidths() {
|
||||||
val newWidth = resources.getDimension(R.dimen.instant_change_bar_width) + if (activity?.portrait == false) activity!!.navigationBarWidth else 0
|
val newWidth = resources.getDimension(R.dimen.instant_change_bar_width) + if (activity?.portrait == false) activity!!.navigationBarWidth else 0
|
||||||
view.instant_prev_item.layoutParams.width = newWidth.toInt()
|
mView.instant_prev_item.layoutParams.width = newWidth.toInt()
|
||||||
view.instant_next_item.layoutParams.width = newWidth.toInt()
|
mView.instant_next_item.layoutParams.width = newWidth.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fullscreenToggled(isFullscreen: Boolean) {
|
override fun fullscreenToggled(isFullscreen: Boolean) {
|
||||||
this.isFullscreen = isFullscreen
|
this.mIsFullscreen = isFullscreen
|
||||||
view.photo_details.apply {
|
mView.photo_details.apply {
|
||||||
if (storedShowExtendedDetails && isVisible()) {
|
if (mStoredShowExtendedDetails && isVisible()) {
|
||||||
animate().y(getExtendedDetailsY(height))
|
animate().y(getExtendedDetailsY(height))
|
||||||
|
|
||||||
if (storedHideExtendedDetails) {
|
if (mStoredHideExtendedDetails) {
|
||||||
animate().alpha(if (isFullscreen) 0f else 1f).start()
|
animate().alpha(if (isFullscreen) 0f else 1f).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,8 +598,8 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun getExtendedDetailsY(height: Int): Float {
|
private fun getExtendedDetailsY(height: Int): Float {
|
||||||
val smallMargin = resources.getDimension(R.dimen.small_margin)
|
val smallMargin = resources.getDimension(R.dimen.small_margin)
|
||||||
val fullscreenOffset = smallMargin + if (isFullscreen) 0 else context!!.navigationBarHeight
|
val fullscreenOffset = smallMargin + if (mIsFullscreen) 0 else context!!.navigationBarHeight
|
||||||
val actionsHeight = if (context!!.config.bottomActions && !isFullscreen) resources.getDimension(R.dimen.bottom_actions_height) else 0f
|
val actionsHeight = if (context!!.config.bottomActions && !mIsFullscreen) resources.getDimension(R.dimen.bottom_actions_height) else 0f
|
||||||
return context!!.realScreenSize.y - height - actionsHeight - fullscreenOffset
|
return context!!.realScreenSize.y - height - actionsHeight - fullscreenOffset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@ class VideoFragment : ViewPagerFragment() {
|
||||||
private lateinit var mBrightnessSideScroll: MediaSideScroll
|
private lateinit var mBrightnessSideScroll: MediaSideScroll
|
||||||
private lateinit var mVolumeSideScroll: MediaSideScroll
|
private lateinit var mVolumeSideScroll: MediaSideScroll
|
||||||
|
|
||||||
lateinit var mView: View
|
private lateinit var mView: View
|
||||||
lateinit var medium: Medium
|
private lateinit var mMedium: Medium
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
mView = inflater.inflate(R.layout.pager_video_item, container, false).apply {
|
mView = inflater.inflate(R.layout.pager_video_item, container, false).apply {
|
||||||
|
@ -56,8 +56,8 @@ class VideoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
medium = arguments!!.getSerializable(MEDIUM) as Medium
|
mMedium = arguments!!.getSerializable(MEDIUM) as Medium
|
||||||
Glide.with(context!!).load(medium.path).into(mView.video_preview)
|
Glide.with(context!!).load(mMedium.path).into(mView.video_preview)
|
||||||
|
|
||||||
mIsFullscreen = activity!!.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
mIsFullscreen = activity!!.window.decorView.systemUiVisibility and View.SYSTEM_UI_FLAG_FULLSCREEN == View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
checkIfPanorama()
|
checkIfPanorama()
|
||||||
|
@ -68,7 +68,7 @@ class VideoFragment : ViewPagerFragment() {
|
||||||
video_play_outline.beGone()
|
video_play_outline.beGone()
|
||||||
mVolumeSideScroll.beGone()
|
mVolumeSideScroll.beGone()
|
||||||
mBrightnessSideScroll.beGone()
|
mBrightnessSideScroll.beGone()
|
||||||
Glide.with(context!!).load(medium.path).into(video_preview)
|
Glide.with(context!!).load(mMedium.path).into(video_preview)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class VideoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchVideoPlayer() {
|
private fun launchVideoPlayer() {
|
||||||
activity!!.openPath(medium.path, false)
|
activity!!.openPath(mMedium.path, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleFullscreen() {
|
private fun toggleFullscreen() {
|
||||||
|
@ -140,7 +140,7 @@ class VideoFragment : ViewPagerFragment() {
|
||||||
if (context!!.config.showExtendedDetails) {
|
if (context!!.config.showExtendedDetails) {
|
||||||
mView.video_details.apply {
|
mView.video_details.apply {
|
||||||
beInvisible() // make it invisible so we can measure it, but not show yet
|
beInvisible() // make it invisible so we can measure it, but not show yet
|
||||||
text = getMediumExtendedDetails(medium)
|
text = getMediumExtendedDetails(mMedium)
|
||||||
onGlobalLayout {
|
onGlobalLayout {
|
||||||
if (isAdded) {
|
if (isAdded) {
|
||||||
val realY = getExtendedDetailsY(height)
|
val realY = getExtendedDetailsY(height)
|
||||||
|
@ -159,8 +159,8 @@ class VideoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun checkIfPanorama() {
|
private fun checkIfPanorama() {
|
||||||
try {
|
try {
|
||||||
val fis = FileInputStream(File(medium.path))
|
val fis = FileInputStream(File(mMedium.path))
|
||||||
context!!.parseFileChannel(medium.path, fis.channel, 0, 0, 0) {
|
context!!.parseFileChannel(mMedium.path, fis.channel, 0, 0, 0) {
|
||||||
mIsPanorama = true
|
mIsPanorama = true
|
||||||
}
|
}
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
|
@ -170,7 +170,7 @@ class VideoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun openPanorama() {
|
private fun openPanorama() {
|
||||||
Intent(context, PanoramaVideoActivity::class.java).apply {
|
Intent(context, PanoramaVideoActivity::class.java).apply {
|
||||||
putExtra(PATH, medium.path)
|
putExtra(PATH, mMedium.path)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue