Update an existing Section
Updating a section is a process very similar to creating a new one, but you will need the id of the section you wish to update--the block_id is not necessary.
You should only pay attention in that you must provide a valid locale and only the section with the given locale will be updated; other locale variants will remain untouched.
Also, all media you will send through the API will be appended to the pre-existent array of media.
If you wish to replace and image or a media you will need to call the MBurgerAdminTasks.deleteMedia(this, media_id) method before calling the update.
If you wish to update a section, the method is similar to creating one:
1
//EditTexts for inserting content
2
val edt_title: EditText
3
val edt_content: EditText
4
val edt_link: EditText
5
6
var listener: MBAdminApiUpdateSectionListener
7
8
val section_id = //ID of the section you wish to update
9
10
//URI of the image, taken from camera or gallery
11
var img_uri: Uri
12
13
//Set if you want this section to be hidden when requesting for block sections, or not
14
val show_in_app = true;
15
16
fun updateSection() {
17
val params = ArrayList<MBAdminParameter>()
18
params.add(MBAdminParameter(“title”, edt_title.getText().toString()))
19
params.add(MBAdminParameter(“content”, edt_content.getText().toString()))
20
params.add(MBAdminParameter(“link”, edt_link.getText().toString()))
21
22
val params_file = ArrayList<MBAdminParameterFile>()
23
val files = ArrayList<MBAdminSingleFile>()
24
25
files.add(MBAdminSingleFile(getFileName(),
26
getMimeType(),
27
getUriRealPath(application, img_uri)))
28
29
params_file.add(MBAdminParameterFile(“image”, files))
30
31
MBurgerAdminTasks.updateSection(applicationContext,
32
section_id,
33
listener,
34
params,
35
params_file,
36
Locale.getDefault().getLanguage(), show_in_app);
37
}
Copied!
Copy link