Skip to content

Commit

Permalink
Fix crash on aspect scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Jan 9, 2025
1 parent 91a7c4e commit d68f7f0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ dependencies {
implementation(project(":jxlcoderglide"))
// implementation("com.github.awxkee:jxl-coder-glide:1.5.1")
implementation("com.github.bumptech.glide:compose:1.0.0-alpha.5")

implementation("com.squareup.okio:okio:3.3.0")
}
41 changes: 28 additions & 13 deletions app/src/main/java/com/awxkee/jxlcoder/app/glide/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.awxkee.jxlcoder.app.glide

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
Expand All @@ -9,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Button
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.MaterialTheme
Expand All @@ -21,11 +23,16 @@ import androidx.compose.ui.unit.dp
import com.awxkee.jxlcoder.app.glide.ui.theme.JxlCoderGlideTheme
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.bumptech.glide.load.engine.DiskCacheStrategy
import okio.buffer
import okio.source

class MainActivity : ComponentActivity() {
@OptIn(ExperimentalGlideComposeApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// val buffer5 =
// assets.open("pexels-lastly-808465.jxl").source().buffer().readByteArray()
setContent {
JxlCoderGlideTheme {
// A surface container using the 'background' color from the theme
Expand All @@ -35,20 +42,28 @@ class MainActivity : ComponentActivity() {
) {
Greeting("Android")

Column {
GlideImage(
model = "https://wh.aimuse.online/preset/jxl_icc_12.bit.jxl",
contentDescription = ""
)
LazyColumn {
item {
GlideImage(
// model = "https://wh.aimuse.online/preset/jxl_icc_12.bit.jxl",
model = Uri.parse("file:///android_asset/pexels-lastly-808465.jxl"),
contentDescription = "",
) { requestBuilder ->
requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
}
}

FilledTonalButton(modifier = Modifier
.padding(start = 8.dp, top = 8.dp)
.height(
50.dp
), onClick = {
startActivity(Intent(this@MainActivity, ProbeActivity::class.java))
}) {
Text("View View Activity")
item {
FilledTonalButton(modifier = Modifier
.padding(start = 8.dp, top = 8.dp)
.height(
50.dp
), onClick = {
startActivity(Intent(this@MainActivity, ProbeActivity::class.java))
}) {
Text("View View Activity")
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.6.1" apply false
id("com.android.application") version "8.8.0-rc02" apply false
id("org.jetbrains.kotlin.android") version "2.0.20" apply false
id("com.android.library") version "8.6.1" apply false
id("com.android.library") version "8.8.0-rc02" apply false
id("com.google.devtools.ksp") version "2.0.20-1.0.25" apply false
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Sep 18 23:05:09 MYT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion jxlcoderglide/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ dependencies {
implementation("com.github.bumptech.glide:glide:4.16.0")
ksp("com.github.bumptech.glide:ksp:4.16.0")

api("io.github.awxkee:jxl-coder:2.3.0")
api("io.github.awxkee:jxl-coder:2.4.0.6")
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package com.awxkee.jxlcoder.glide

import android.graphics.Bitmap
import android.os.Build
import android.util.Log
import com.awxkee.jxlcoder.JxlCoder
import com.awxkee.jxlcoder.JxlResizeFilter
import com.awxkee.jxlcoder.PreferredColorConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class JxlCoderStreamDecoder(private val bitmapPool: BitmapPool, private val chec
source: InputStream, width: Int, height: Int, options: Options
): Resource<Bitmap>? {
val bb = ByteBufferUtil.fromStream(source)
source.reset()
bb.rewind()
return byteBufferDecoder.decode(bb, width, height, options)
}
Expand Down

0 comments on commit d68f7f0

Please sign in to comment.