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
//Prepare the intent | |
Intent intent = $MainActivity().intent() | |
.flags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK) | |
.get(); | |
//Prepare pending intent | |
PendingIntent contentIntent = PendingIntent.getActivity( | |
this, 0, notificationIntent, | |
PendingIntent.FLAG_CANCEL_CURRENT); |
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
void selectDate() { | |
$DateDialog(); | |
int $year = 0, $month = 0, $day = 0; | |
String selectedDate = String.format(Locale.US, "Selected date is %02d-%02d-%02d", $year , $month+1, $day); | |
$Toast(selectedDate); | |
} | |
void selectTime() { | |
$TimeDialog(); |
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
Dialog dialog = $ProgressDialog().message("Loading…").dialog(); | |
//Execute time consuming actions | |
dialog.dismiss(); |
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
@Model | |
User_ user; | |
@Click | |
void sayHelloToUser() { | |
$Toast("Hello {user.getName()}!"); | |
} |
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
$PutModel(user).withProgress("Saving user...") | |
.onFailed().toast("An error occurred"); | |
$PutModel(user).always().code("checkState();") | |
.onDone().toast("User was saved") | |
.onFailed().toast("An error occurred"); |
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) { |
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
@Event | |
void onAuthenticationDone(String userName) { | |
//Do some action after the event is triggered | |
} |
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
@Model | |
@Populate | |
List<Item> itemsList; | |
void sortAndUpdateItemsList() { | |
//This will run the following code in an Asynchronous (Background) Thread | |
$Background(); | |
Collections.sort(itemsList, |
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
@Click | |
void selectAction() { | |
String[] actions = {"Action 1", "Action 2", "Action 3"} | |
$AlertDialog().items(actions) | |
.positiveButton("More Actions") | |
.negativeButton("Cancel"); | |
if ($AlertDialog.ItemSelected) { | |
$Toast("Action selected was {actions[position]}"); |
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
@EActivity(R.id.activity_main) | |
public class MainActivity extends Activity { | |
@Model | |
User_ user; | |
@Click | |
void showSettings() { | |
$SettingsActivity().userName(user.getName()).withResult(); | |
if ($SettingsActivity.OnResult) { |