Garrett

Garrett

Help, how to update arraylist in jetpack compose

I’m stuck trying to understand how to get a variable initialised, and later updated, in kotlin to update in Jetpack Compose and cause a composition that uses it to recompose. The variable is an arraylist of bitmaps set up like so (all of this works fine so I have not included the getOutputDirectory() and imageReaderNew() functions):

// set up an empty bitmaps arraylist
// should I be using mutableListOf() here? if so how?
var bitmaps: ArrayList<Bitmap> = ArrayList()

// get the uri of the folder to save images to
val outputDirectory = getOutputDirectory()

// read in a list of images in the images folder
var fileList: ArrayList<File> = imageReaderNew(outputDirectory)

// get a list of bitmaps of the images
bitmaps = getBitmapList(fileList)

When I initialise my composition I do this:

BottomSheetScaffold(
scaffoldState = scaffoldState,
sheetPeekHeight = 0.dp,
sheetContent = {
PhotoBottomSheetContent(
bitmaps = bitmaps,
//should I be using remember here?
//bitmaps = remember { bitmaps },
modifier = Modifier.fillMaxWidth()
)
}
)
{ }

Finally, in my composable I do this:

fun PhotoBottomSheetContent(
bitmaps: List<Bitmap>,
// should I be using mutableListOf() or remember { } here? again if so how?
modifier: Modifier = Modifier
)
{
}

Where Next?

Popular Android topics Top

Exadra37
I am in the process of research for my next technical blog about bypassing certificate pinning with Frida, thus I need to find some open ...
New
AndroidMan
I’ve tried signing up for Airnow as I used to do very well when they were Airpush, but i haven’t used them in years. I went through the s...
New
ciger
I want to get a clone of Instagram APK But with a difference I want to define in this clone that, for example, it is not possible to acc...
New
Apoorv
I have made my version of browser on android platform.I have used chromium as base. I have build it successfully &amp; but the logo or i...
New
mpdizcashtag
Hi, this is my parrition informarion. A week ago I erased ‘system’ and now my hotpepper puya tablet bootloops. I have a gsi im trying to...
New
vsiPr
I am trying to develop an app which will make your smartphone act as a “keyboard”. I need it to send different symbols to another devices...
New
Creator
Could you please help me to find the problem why startScan function is not executed. By debugging after @RequiresBluetoothLocationPermiss...
New
codergrid
I’m new to Android Studio, and curious about how long you’ve been using your Android Studio IDE. I read on Wikipedia that this year, Andr...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New
nihar-gingercube
We have developed a audio/video calling functionality using opentok sdk, now we want to integrate speech recognizer for transcribing voic...
New

Other popular topics Top

AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File &gt; New Rule: And select Deny, O...
New
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New
OSZAR »