I'm trying to create an Appwidget, using Glance Jetpack with .SVG image support.
I'm able to download the bitmap using
ImageRequest.Builder(this)
.data(url)
.decoderFactory(SvgDecoder.Factory())
...and as seen in the last line of logging, there's a non-null bitmap assigned to var coinImage.
The problem is, the widget doesn't seem to re-compose after the bitmap's value changes. I'm stuck seeing the circularProgressSpinner.
What am I missing/doing wrong? Am I missing something foundational with the composition's state?
My code and logcat is at:
https://gist.github.com/Alvtag/5bd46a2007e6c4f382d431e43aa96e80
Any help is appreciated!
Current Glance alpha05 does not support recomposition.
Partial recomposition support will come in next version. You can use the Snapshot to access to it.
Without recomposition you should follow this sample
https://github.com/android/user-interface-samples/blob/main/AppWidget/app/src/main/java/com/example/android/appwidget/glance/image/ImageGlanceWidget.kt
With recomposition support it will be simplified
https://gist.github.com/marcelpinto/6df5e3e6ca42c6a0bf34b9f4b6eb1cff
Related
So i'm using LazyVertialGrid alongside coil to display some images, i have 3 fixed columns but whenever i scroll it gets pretty stuttery, almost unusable.
Am i doing something wrong or missing something?
I tried release mode, and lowering coil images resolution with no performance changes whatsoever.
I even commented the asyncImage line to see if coil was the problem, but even scrolling wasnt %100 smooth.
Edit1:
I checked the logs and saw this: https://gyazo.com/f292139703889495e5b4d385e170f425
Heres a video example of it: https://gyazo.com/ed7b4a9c7e1f4f256ad683d719ed62a7
I noticed that everytime i scroll down or up coil checks and tries to load an image (the loading icon), how do i prevent this behavior?
Edit2: Heres the code part of my lazyverticalGrid:
https://gyazo.com/14262effe8a2f6aa48b45fd1a7f7bb41
I have a list of photos in my activity.
I should render those concurrently. so I find the best way to have 3 TextureView at first and change the position of them on scrolling the list. If I create EGLThread each time, It runs correctly, but it has a little delay to update the texture. so I need to have EGLThreads permanently, but I don't know to change the bitmap of each EGLThread. I try so many codes but I couldn't find the solution.
I solved.
should run code in postRunnable in EGLThread
I am still new to Android, and never had to deal with memory management in my previous experience.
In my android application, I have an activity with a TextView, a ListView, and ImageView. I have listeners for the textview and listview, and the code that changes the contents in all three of those views. The contents is stored in the arraylist. The source for the ImageView is stored in form of a String (filenames), and the code that makes the changes looks like this:
tv1.setText(myText);
imgView.setImageResource(myImage);
This worked perfectly well while I only had a few images to test the logic, but once I added more images, I started to get the OutOfMemory error. If I make the images smaller, I get that error a little later in the process, but I still get it.
At first, I thought that Android does not release the previous source, so I thought using recycle() before the reassignment will help. Instead, I've got another error when I try to change the source:
Cannot draw recycled bitmaps
It looks like I am missing some vital understanding about how the ImageView handles the source images. Does it assign the bitmap reference and then keeps the same reference, but somehow changes content?
Then, after reading this article, I realized I have a different kind of problem altogether, the one that might be solved by using the inBitmap. Yet, the documentation says the bitmaps have to be the same size for that, and mine are not.
I am thinking of converting my drawable to bitmap, then scaling it to some hard-coded dimensions, then using inBitmap. I guess my second question is - does this approach make sense? Are there any downfalls in scaling the images? And any examples would be appreciated, of course.
Thank you!
I want to do image processing on frames from Android Camera in real time with OpenCv, but all the OpenCv Android examples provide a preview of the image being captured. I really don't need previews of the frames , is there any way to get the frames without actually showing the preview ?
A quick/naive way would be to make onCameraFrame method returning null and set your CameraBridgeViewBase visibility to SurfaceView.INVISIBLE or SurfaceView.GONE.
I still would like to know if it worked for you, but meanwhile I found the solution that worked for me. As I feel grateful for the guy who wrote it, I'm sharing this (scroll down to answers section) with anyone who will have same problem in future.
In case the link vanished, here's his/her pro-tip:
You can set your preview (in this case a CameraBridgeViewBase)
transparent by setting the alpha value of the view, with 0 being
completely invisible.
mOpenCvCameraView.setAlpha(0);
This should make your preview "disappear".
I wonder how your solution works, because as you can read in the docs:
This method is invoked when delivery of the frame needs to be done.
The returned values - is a modified frame which needs to be displayed
on the screen.
Indeed, in my case it doesn't work but I desperately need such a functionality.
Now a day i am doing a project related to image processing with the fallowing feature
1)Stretch 2)Scale 3)Twist
I am not understand how to achieve it in android.
Here i am putting some screen shot related to this project for makeing more clarity in my question.
The above image is the real image i want to apply image processing over this image for making it like
blow image.
Please me any suggestion,help url ,tutorial and other thinks for achieve this task.
You need to find a function which, when applied to pixel coordinates, outputs new pixel coordinates producing the twist effect you're looking for.
It may help to take a look at some of the functions listed at http://reference.wolfram.com/mathematica/ref/ImageTransformation.html (esp. the section "Neat examples").
Once you have defined the function, you'd need to implement in Android the equivalent of the ImageTransformation command. Basically, for each pixel in the output image, call the function to know where to sample in the input image; use windowing when sampling the input image so that you limit artifacts and get a smoother result.