Comments (8)
Thank you very much @saket, that was the issue. Now everything work perfect
from telephoto.
Please add some more context in the form of a video or code to reproduce. It's hard to tell what's happening otherwise.
from telephoto.
It seems that .listener()
is causing blinking. On my end it's blinking/flashing all the time.
val zoomSpec = ZoomSpec(maxZoomFactor = 4.0f)
val zoomableImageState = rememberZoomableImageState(rememberZoomableState(zoomSpec = zoomSpec))
ZoomableAsyncImage(
modifier = modifier,
state = zoomableImageState,
model = ImageRequest.Builder(LocalContext.current)
.data(imageUrl)
.placeholderMemoryCacheKey(imageUrl)
.crossfade(IMAGE_CROSSFADE_DURATION)
.listener()
.build(),
contentDescription = null,
)
If I remove .listener()
everything works fine.
Is there any other way to get notified when the image is loaded?
from telephoto.
From what I understand, this is happening because listener()
is creating a new object on every recomposition, making telephoto think that the ImageRequest was changed. You'll need to remember your listener object (example).
I wonder how Coil is able to avoid this. Does AsyncImage
not suffer from this problem?
from telephoto.
Thanks for the link.
I never had blinking problem with Coil. I'm using SubcomposeAsyncImage
which also provides custom loading
, error
and success
composable functions to render the states and it's really nice feature to have.
from telephoto.
Yep that's indeed nice to have. I want to explore if I can offer something similar in the future, but for now you're restricted to managing the loading & error states yourself.
from telephoto.
@saket , @AleksandarIlic thanks for the reply and sorry for late response.
I am using ZoomableAsyncImage inside a HorizontalPager. When I add/remove images from the 'imageUriList', Image blinks. But Coil doesn't have this issue
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ImageViewerScreen(
imageUriList: List<Uri>
){
val context = LocalContext.current
val state = rememberPagerState(initialPage = 0, 0f) { imageUriList.size }
HorizontalPager(
key = { pos ->
imageUriList[pos]
},
state = state,
modifier = Modifier.fillMaxSize()
){ page ->
ZoomableAsyncImage(
modifier = Modifier.fillMaxSize(),
model = imageUriList[page],
contentDescription = "",
imageLoader = ImageLoader.Builder(context)
.components {
add(ImageDecoderDecoder.Factory())
add(SvgDecoder.Factory())
}
.build()
)
}
}
from telephoto.
I wonder if it's because you're creating a new ImageLoader
for each image. Does hoisting and remembering your loader change anything?
val context = LocalContext.current
val state = rememberPagerState(initialPage = 0, 0f) { imageUriList.size }
val imageLoader = remember {
ImageLoader.Builder(context)
.components {
add(ImageDecoderDecoder.Factory())
add(SvgDecoder.Factory())
}
.build()
}
HorizontalPager(
key = { pos ->
imageUriList[pos]
},
state = state,
modifier = Modifier.fillMaxSize()
) { page ->
ZoomableAsyncImage(
modifier = Modifier.fillMaxSize(),
model = imageUriList[page],
contentDescription = "",
imageLoader = imageLoader,
)
}
from telephoto.
Related Issues (20)
- Unable to capture bitmap from ZoomableAsyncImage composable HOT 9
- Better zoom gestures HOT 13
- Please provide a way to change zoom and offset programatically HOT 9
- Coil returned a null cache snapshot HOT 4
- Telephoto internal NPE HOT 7
- Incorrect fling velocity on zoom gesture end with Compose 1.7.0-alpha02 HOT 1
- Zoomable modifier looses state after ZoomableState gets disposed and recreated HOT 12
- Allow disabling "Double tap to zoom" & "Pinch to zoom" separately HOT 2
- Content padding HOT 2
- Keyboard support HOT 2
- IllegalStateException: maximumVelocity should be a positive value HOT 16
- IllegalStateException: Coil returned a null cache snapshot HOT 5
- Gif Not Working HOT 5
- Individual Zoom for Canvas Rectangles using rememberZoomState. HOT 2
- Add mouse wheel zoom support HOT 5
- Different double tap/zoom functionality HOT 1
- Need SubsamplingScaleImageView.visibleFileRect(Rect fRect) analog HOT 4
- Fatal Exception: java.io.FileNotFoundException: No content provider: url HOT 4
- Lower minSDK to 21 HOT 6
- NullPointerException in RealZoomableState HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telephoto.