This repository has been archived by the owner on May 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Action Sequences Example (Obsolete)
Adrián Rivero edited this page Mar 10, 2017
·
1 revision
Let's declare the model that we're going to use in this example:
@ServerModel(
baseUrl = "http://example.com/",
post = "/data?query={query}",
model = "this"
)
@EBean
public class UploadData {
String data;
int successful;
public void isSuccessFul() {
return successful==1;
}
}
In this example, when a button with Id btnUpload
is pressed, a Modal named uploadData
is put to upload data to a server, sending query=all
. After the upload, in the UI Thread, it is tested isSuccessful()
method to check if the Data was successfully uploaded and display a Toast depending of it.
@Model(lazy=true)
UploadData uploadData;
@Action({
"message=\"Uploading Data\" -> :uploadingDialog",
"query=all $uploadData",
"ui: ;savingDialog.dismiss() -> uploadData.isSuccessful()?? -> Data uploaded successfully"
"An error occurred while uploading the data"
})
S4<ProgressDialog, PutModel, Toast, Toast> btnUpload;
See that by default, putting a model will be executed asynchronously in a background Thread, because of it, before showing the Toast we change to the UI Thread starting the declaration with "ui" because a Toast can be shown only in the UI Thread, if not an exception will be thrown.
Sponsored by DSpot Sp. z o.o. Contact us at info@dspot.com.pl