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
@ -37,4 +35,4 @@ class ZoomableImageActivity : AppCompatActivity() {
}
}
}
}
}

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

@ -64,8 +64,8 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
mode = ZOOM
}
MotionEvent.ACTION_MOVE -> //if the mode is ZOOM or
//if the mode is DRAG and already zoomed
MotionEvent.ACTION_MOVE -> // if the mode is ZOOM or
// if the mode is DRAG and already zoomed
if (mode == ZOOM || mode == DRAG && saveScale > minScale) {
var deltaX = curr.x - last.x // x 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
val scaleHeight = (origHeight * saveScale).roundToInt()
.toFloat() // height after applying current scale
//if scaleWidth is smaller than the views width
//in other words if the image width fits in the view
//limit left and right movement
// if scaleWidth is smaller than the views width
// in other words if the image width fits in the view
// limit left and right movement
if (scaleWidth < width) {
deltaX = 0f
if (y + deltaY > 0) deltaY = -y else if (y + deltaY < -bottom) deltaY =
-(y + bottom)
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 =
-(x + right)
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 =
-(x + right)
if (y + deltaY > 0) deltaY = -y else if (y + deltaY < -bottom) deltaY =
-(y + bottom)
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 =
-(y + bottom)
}
}
//move the image with the matrix
// move the image with the matrix
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
}
@ -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(
0f,
-(y + bottom)
) else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
if (y < -bottom) {
bitmapMatrix.postTranslate(
0f,
-(y + bottom)
)
} else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
} else {
if (x < -right) bitmapMatrix.postTranslate(
-(x + right),
0f
) else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
if (x < -right) {
bitmapMatrix.postTranslate(
-(x + right),
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(
-(x + right),
0f
) else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
if (y < -bottom) bitmapMatrix.postTranslate(
0f,
-(y + bottom)
) else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
if (x < -right) {
bitmapMatrix.postTranslate(
-(x + right),
0f
)
} else if (x > 0) bitmapMatrix.postTranslate(-x, 0f)
if (y < -bottom) {
bitmapMatrix.postTranslate(
0f,
-(y + bottom)
)
} else if (y > 0) bitmapMatrix.postTranslate(0f, -y)
}
}
return true
@ -207,4 +231,4 @@ class ZoomableImageView(context: Context, attr: AttributeSet?) : AppCompatImageV
const val ZOOM = 2
const val CLICK = 3
}
}
}