Last active
April 29, 2017 13:01
-
-
Save smaugho/e84645e7980e95c246a153d2a6d23342 to your computer and use it in GitHub Desktop.
Example with $LoadModel and $PutModel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@EFragment(R.id.fragment_address) | |
public class AddressFragment extends Fragment { | |
@Model(lazy = true) | |
@Populate | |
@Recollect(validate = true) | |
User user; | |
@AfterViews | |
void loadUser(View userInformation) { | |
Dialog progressDialog = $ProgressDialog() | |
.message("Loading user...") | |
.dialog(); | |
$LoadModel(user); | |
if ($LoadModel.Failed) { | |
progressDialog.dismiss(); | |
$Toast("The user information couldn't be fetched"); | |
} | |
progressDialog.dismiss(); | |
userInformation.setEnabled(true); | |
} | |
@Click | |
void save() { | |
$AlertDialog() | |
.message("Are you sure you want to save these changes?") | |
.positiveButton("Yes").negativeButton("No"); | |
$PutModel(user); | |
if ($PutModel.Failed) { | |
$Toast("User {user.fullName()} couldn't be saved"); | |
} | |
$Toast("User {user.fullName()} has been saved"); | |
getActivity().onBackPressed(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment