mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-08 00:39:54 +00:00
Null Safe ScreenShot Fragment
Removed Coil Library (Unused)
This commit is contained in:
parent
26d4fbbd29
commit
b3ac8e10b1
@ -109,6 +109,5 @@ dependencies {
|
|||||||
implementation 'io.reactivex.rxjava3:rxjava:3.1.1'
|
implementation 'io.reactivex.rxjava3:rxjava:3.1.1'
|
||||||
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
|
||||||
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.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'
|
implementation 'com.squareup.picasso:picasso:2.71828'
|
||||||
}
|
}
|
||||||
|
@ -62,52 +62,60 @@ class ScreenshotsFragment() : DialogFragment() {
|
|||||||
val repositoryId = requireArguments().getLong(EXTRA_REPOSITORY_ID)
|
val repositoryId = requireArguments().getLong(EXTRA_REPOSITORY_ID)
|
||||||
val dialog = Dialog(requireContext(), R.style.Theme_Main_Dark)
|
val dialog = Dialog(requireContext(), R.style.Theme_Main_Dark)
|
||||||
|
|
||||||
val window = dialog.window!!
|
val window = dialog.window
|
||||||
val decorView = window.decorView
|
val decorView = window?.decorView
|
||||||
|
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
if (window != null) {
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
}
|
||||||
|
|
||||||
val background =
|
val background =
|
||||||
dialog.context.getColorFromAttr(android.R.attr.colorBackground).defaultColor
|
dialog.context.getColorFromAttr(android.R.attr.colorBackground).defaultColor
|
||||||
decorView.setBackgroundColor(background.let {
|
decorView?.setBackgroundColor(background.let {
|
||||||
ColorUtils.blendARGB(
|
ColorUtils.blendARGB(
|
||||||
0x00ffffff and it,
|
0x00ffffff and it,
|
||||||
it,
|
it,
|
||||||
0.9f
|
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 {
|
background.let { ColorUtils.blendARGB(0x00ffffff and it, it, 0.8f) }.let {
|
||||||
window.statusBarColor = it
|
window?.statusBarColor = it
|
||||||
window.navigationBarColor = it
|
window?.navigationBarColor = it
|
||||||
}
|
}
|
||||||
window.attributes = window.attributes.apply {
|
if (window != null) {
|
||||||
title = ScreenshotsFragment::class.java.name
|
window.attributes = window.attributes.apply {
|
||||||
format = PixelFormat.TRANSLUCENT
|
title = ScreenshotsFragment::class.java.name
|
||||||
windowAnimations = run {
|
format = PixelFormat.TRANSLUCENT
|
||||||
val typedArray = dialog.context.obtainStyledAttributes(
|
windowAnimations = run {
|
||||||
null,
|
val typedArray = dialog.context.obtainStyledAttributes(
|
||||||
intArrayOf(android.R.attr.windowAnimationStyle), android.R.attr.dialogTheme, 0
|
null,
|
||||||
)
|
intArrayOf(android.R.attr.windowAnimationStyle),
|
||||||
try {
|
android.R.attr.dialogTheme,
|
||||||
typedArray.getResourceId(0, 0)
|
0
|
||||||
} finally {
|
)
|
||||||
typedArray.recycle()
|
try {
|
||||||
|
typedArray.getResourceId(0, 0)
|
||||||
|
} finally {
|
||||||
|
typedArray.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Android.sdk(28)) {
|
||||||
|
layoutInDisplayCutoutMode =
|
||||||
|
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (Android.sdk(28)) {
|
|
||||||
layoutInDisplayCutoutMode =
|
|
||||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val toggleSystemUi = {
|
val toggleSystemUi = {
|
||||||
WindowInsetsControllerCompat(window, decorView).let { controller ->
|
if (window != null && decorView != null) {
|
||||||
controller.hide(WindowInsetsCompat.Type.statusBars())
|
WindowInsetsControllerCompat(window, decorView).let { controller ->
|
||||||
controller.hide(WindowInsetsCompat.Type.navigationBars())
|
controller.hide(WindowInsetsCompat.Type.statusBars())
|
||||||
controller.systemBarsBehavior =
|
controller.hide(WindowInsetsCompat.Type.navigationBars())
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
controller.systemBarsBehavior =
|
||||||
|
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,17 +254,19 @@ class ScreenshotsFragment() : DialogFragment() {
|
|||||||
val screenshot = screenshots[position]
|
val screenshot = screenshots[position]
|
||||||
val (width, height) = size
|
val (width, height) = size
|
||||||
if (width > 0 && height > 0) {
|
if (width > 0 && height > 0) {
|
||||||
holder.image.load(
|
repository?.let {
|
||||||
PicassoDownloader.createScreenshotUri(
|
holder.image.load(
|
||||||
repository!!,
|
PicassoDownloader.createScreenshotUri(
|
||||||
packageName,
|
it,
|
||||||
screenshot
|
packageName,
|
||||||
)
|
screenshot
|
||||||
) {
|
)
|
||||||
placeholder(holder.placeholder)
|
) {
|
||||||
error(holder.placeholder)
|
placeholder(holder.placeholder)
|
||||||
resize(width, height)
|
error(holder.placeholder)
|
||||||
centerInside()
|
resize(width, height)
|
||||||
|
centerInside()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
holder.image.clear()
|
holder.image.clear()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user