Merge pull request #4847 from Bnyro/master

style: run ktlint
This commit is contained in:
Bnyro 2023-09-25 10:04:16 +02:00 committed by GitHub
commit bc863d2e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 39 deletions

View File

@ -1,7 +1,6 @@
package com.github.libretube.ui.activities package com.github.libretube.ui.activities
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.graphics.Bitmap
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isGone import androidx.core.view.isGone
@ -9,7 +8,6 @@ import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.constants.IntentData import com.github.libretube.constants.IntentData
import com.github.libretube.databinding.ActivityZoomableImageBinding import com.github.libretube.databinding.ActivityZoomableImageBinding
import com.github.libretube.extensions.parcelableExtra
import com.github.libretube.helpers.ImageHelper import com.github.libretube.helpers.ImageHelper
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch

View File

@ -1,6 +1,5 @@
package com.github.libretube.ui.fragments package com.github.libretube.ui.fragments
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
@ -30,7 +29,6 @@ import com.github.libretube.helpers.ImageHelper
import com.github.libretube.helpers.NavigationHelper import com.github.libretube.helpers.NavigationHelper
import com.github.libretube.obj.ChannelTabs import com.github.libretube.obj.ChannelTabs
import com.github.libretube.obj.ShareData import com.github.libretube.obj.ShareData
import com.github.libretube.ui.activities.ZoomableImageActivity
import com.github.libretube.ui.adapters.SearchAdapter import com.github.libretube.ui.adapters.SearchAdapter
import com.github.libretube.ui.adapters.VideosAdapter import com.github.libretube.ui.adapters.VideosAdapter
import com.github.libretube.ui.dialogs.ShareDialog import com.github.libretube.ui.dialogs.ShareDialog
@ -202,11 +200,17 @@ class ChannelFragment : Fragment() {
ImageHelper.loadImage(response.avatarUrl, binding.channelImage) ImageHelper.loadImage(response.avatarUrl, binding.channelImage)
binding.channelImage.setOnClickListener { binding.channelImage.setOnClickListener {
NavigationHelper.openImagePreview(requireContext(), response.avatarUrl ?: return@setOnClickListener) NavigationHelper.openImagePreview(
requireContext(),
response.avatarUrl ?: return@setOnClickListener
)
} }
binding.channelBanner.setOnClickListener { binding.channelBanner.setOnClickListener {
NavigationHelper.openImagePreview(requireContext(), response.bannerUrl ?: return@setOnClickListener) NavigationHelper.openImagePreview(
requireContext(),
response.bannerUrl ?: return@setOnClickListener
)
} }
// recyclerview of the videos by the channel // recyclerview of the videos by the channel

View File

@ -64,8 +64,8 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
mode = ZOOM mode = ZOOM
} }
MotionEvent.ACTION_MOVE -> //if the mode is ZOOM or MotionEvent.ACTION_MOVE -> // if the mode is ZOOM or
//if the mode is DRAG and already zoomed // if the mode is DRAG and already zoomed
if (mode == ZOOM || mode == DRAG && saveScale > minScale) { if (mode == ZOOM || mode == DRAG && saveScale > minScale) {
var deltaX = curr.x - last.x // x difference var deltaX = curr.x - last.x // x difference
var deltaY = curr.y - last.y // y difference var deltaY = curr.y - last.y // y difference
@ -73,26 +73,42 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
.toFloat() // width after applying current scale .toFloat() // width after applying current scale
val scaleHeight = (origHeight * saveScale).roundToInt() val scaleHeight = (origHeight * saveScale).roundToInt()
.toFloat() // height after applying current scale .toFloat() // height after applying current scale
//if scaleWidth is smaller than the views width // if scaleWidth is smaller than the views width
//in other words if the image width fits in the view // in other words if the image width fits in the view
//limit left and right movement // limit left and right movement
if (scaleWidth < width) { if (scaleWidth < width) {
deltaX = 0f deltaX = 0f
if (y + deltaY > 0) deltaY = -y else if (y + deltaY < -bottom) deltaY = if (y + deltaY > 0) {
-(y + bottom) deltaY = -y
} else if (y + deltaY < -bottom) {
deltaY =
-(y + bottom)
}
} else if (scaleHeight < height) { } else if (scaleHeight < height) {
deltaY = 0f deltaY = 0f
if (x + deltaX > 0) deltaX = -x else if (x + deltaX < -right) deltaX = if (x + deltaX > 0) {
-(x + right) deltaX = -x
} else if (x + deltaX < -right) {
deltaX =
-(x + right)
}
} else { } else {
if (x + deltaX > 0) deltaX = -x else if (x + deltaX < -right) deltaX = if (x + deltaX > 0) {
-(x + right) deltaX = -x
if (y + deltaY > 0) deltaY = -y else if (y + deltaY < -bottom) deltaY = } else if (x + deltaX < -right) {
-(y + bottom) deltaX =
-(x + right)
}
if (y + deltaY > 0) {
deltaY = -y
} else if (y + deltaY < -bottom) {
deltaY =
-(y + bottom)
}
} }
//move the image with the matrix // move the image with the matrix
bitmapMatrix.postTranslate(deltaX, deltaY) bitmapMatrix.postTranslate(deltaX, deltaY)
//set the last touch location to the current // set the last touch location to the current
last[curr.x] = curr.y last[curr.x] = curr.y
} }
@ -169,15 +185,19 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
val y = m[Matrix.MTRANS_Y] val y = m[Matrix.MTRANS_Y]
if ((origWidth * saveScale).roundToInt() < width) { if ((origWidth * saveScale).roundToInt() < width) {
if (y < -bottom) bitmapMatrix.postTranslate( if (y < -bottom) {
0f, bitmapMatrix.postTranslate(
-(y + bottom) 0f,
) else if (y > 0) bitmapMatrix.postTranslate(0f, -y) -(y + bottom)
)
} else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
} else { } else {
if (x < -right) bitmapMatrix.postTranslate( if (x < -right) {
-(x + right), bitmapMatrix.postTranslate(
0f -(x + right),
) else if (x > 0) bitmapMatrix.postTranslate(-x, 0f) 0f
)
} else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
} }
} }
} else { } else {
@ -187,14 +207,18 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
val y = m[Matrix.MTRANS_Y] val y = m[Matrix.MTRANS_Y]
if (mScaleFactor < 1) { if (mScaleFactor < 1) {
if (x < -right) bitmapMatrix.postTranslate( if (x < -right) {
-(x + right), bitmapMatrix.postTranslate(
0f -(x + right),
) else if (x > 0) bitmapMatrix.postTranslate(-x, 0f) 0f
if (y < -bottom) bitmapMatrix.postTranslate( )
0f, } else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
-(y + bottom) if (y < -bottom) {
) else if (y > 0) bitmapMatrix.postTranslate(0f, -y) bitmapMatrix.postTranslate(
0f,
-(y + bottom)
)
} else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
} }
} }
return true return true