Null Safe ScreenShot Fragment

Removed Coil Library (Unused)
This commit is contained in:
LooKeR 2021-10-08 01:29:51 +05:30
parent 26d4fbbd29
commit b3ac8e10b1
2 changed files with 49 additions and 40 deletions

View File

@ -109,6 +109,5 @@ dependencies {
implementation 'io.reactivex.rxjava3:rxjava:3.1.1'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0'
implementation 'io.coil-kt:coil:1.3.2'
implementation 'com.squareup.picasso:picasso:2.71828'
}

View File

@ -62,32 +62,37 @@ class ScreenshotsFragment() : DialogFragment() {
val repositoryId = requireArguments().getLong(EXTRA_REPOSITORY_ID)
val dialog = Dialog(requireContext(), R.style.Theme_Main_Dark)
val window = dialog.window!!
val decorView = window.decorView
val window = dialog.window
val decorView = window?.decorView
if (window != null) {
WindowCompat.setDecorFitsSystemWindows(window, false)
}
val background =
dialog.context.getColorFromAttr(android.R.attr.colorBackground).defaultColor
decorView.setBackgroundColor(background.let {
decorView?.setBackgroundColor(background.let {
ColorUtils.blendARGB(
0x00ffffff and it,
it,
0.9f
)
})
decorView.setPadding(0, 0, 0, 0)
decorView?.setPadding(0, 0, 0, 0)
background.let { ColorUtils.blendARGB(0x00ffffff and it, it, 0.8f) }.let {
window.statusBarColor = it
window.navigationBarColor = it
window?.statusBarColor = it
window?.navigationBarColor = it
}
if (window != null) {
window.attributes = window.attributes.apply {
title = ScreenshotsFragment::class.java.name
format = PixelFormat.TRANSLUCENT
windowAnimations = run {
val typedArray = dialog.context.obtainStyledAttributes(
null,
intArrayOf(android.R.attr.windowAnimationStyle), android.R.attr.dialogTheme, 0
intArrayOf(android.R.attr.windowAnimationStyle),
android.R.attr.dialogTheme,
0
)
try {
typedArray.getResourceId(0, 0)
@ -100,9 +105,11 @@ class ScreenshotsFragment() : DialogFragment() {
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
}
}
val toggleSystemUi = {
if (window != null && decorView != null) {
WindowInsetsControllerCompat(window, decorView).let { controller ->
controller.hide(WindowInsetsCompat.Type.statusBars())
controller.hide(WindowInsetsCompat.Type.navigationBars())
@ -110,6 +117,7 @@ class ScreenshotsFragment() : DialogFragment() {
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
}
val viewPager = ViewPager2(dialog.context)
viewPager.adapter = Adapter(packageName) { toggleSystemUi() }
@ -246,9 +254,10 @@ class ScreenshotsFragment() : DialogFragment() {
val screenshot = screenshots[position]
val (width, height) = size
if (width > 0 && height > 0) {
repository?.let {
holder.image.load(
PicassoDownloader.createScreenshotUri(
repository!!,
it,
packageName,
screenshot
)
@ -258,6 +267,7 @@ class ScreenshotsFragment() : DialogFragment() {
resize(width, height)
centerInside()
}
}
} else {
holder.image.clear()
}