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

View File

@ -1,6 +1,5 @@
package com.github.libretube.ui.fragments
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
@ -30,7 +29,6 @@ import com.github.libretube.helpers.ImageHelper
import com.github.libretube.helpers.NavigationHelper
import com.github.libretube.obj.ChannelTabs
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.VideosAdapter
import com.github.libretube.ui.dialogs.ShareDialog
@ -202,11 +200,17 @@ class ChannelFragment : Fragment() {
ImageHelper.loadImage(response.avatarUrl, binding.channelImage)
binding.channelImage.setOnClickListener {
NavigationHelper.openImagePreview(requireContext(), response.avatarUrl ?: return@setOnClickListener)
NavigationHelper.openImagePreview(
requireContext(),
response.avatarUrl ?: return@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

View File

@ -78,18 +78,34 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
// limit left and right movement
if (scaleWidth < width) {
deltaX = 0f
if (y + deltaY > 0) deltaY = -y else if (y + deltaY < -bottom) deltaY =
if (y + deltaY > 0) {
deltaY = -y
} else if (y + deltaY < -bottom) {
deltaY =
-(y + bottom)
}
} else if (scaleHeight < height) {
deltaY = 0f
if (x + deltaX > 0) deltaX = -x else if (x + deltaX < -right) deltaX =
if (x + deltaX > 0) {
deltaX = -x
} else if (x + deltaX < -right) {
deltaX =
-(x + right)
}
} else {
if (x + deltaX > 0) deltaX = -x else if (x + deltaX < -right) deltaX =
if (x + deltaX > 0) {
deltaX = -x
} else if (x + deltaX < -right) {
deltaX =
-(x + right)
if (y + deltaY > 0) deltaY = -y else if (y + deltaY < -bottom) deltaY =
}
if (y + deltaY > 0) {
deltaY = -y
} else if (y + deltaY < -bottom) {
deltaY =
-(y + bottom)
}
}
// move the image with the matrix
bitmapMatrix.postTranslate(deltaX, deltaY)
// set the last touch location to the current
@ -169,15 +185,19 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
val y = m[Matrix.MTRANS_Y]
if ((origWidth * saveScale).roundToInt() < width) {
if (y < -bottom) bitmapMatrix.postTranslate(
if (y < -bottom) {
bitmapMatrix.postTranslate(
0f,
-(y + bottom)
) else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
)
} else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
} else {
if (x < -right) bitmapMatrix.postTranslate(
if (x < -right) {
bitmapMatrix.postTranslate(
-(x + right),
0f
) else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
)
} else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
}
}
} else {
@ -187,14 +207,18 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
val y = m[Matrix.MTRANS_Y]
if (mScaleFactor < 1) {
if (x < -right) bitmapMatrix.postTranslate(
if (x < -right) {
bitmapMatrix.postTranslate(
-(x + right),
0f
) else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
if (y < -bottom) bitmapMatrix.postTranslate(
)
} else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
if (y < -bottom) {
bitmapMatrix.postTranslate(
0f,
-(y + bottom)
) else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
)
} else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
}
}
return true