Skip to content

Instantly share code, notes, and snippets.

View smaugho's full-sized avatar

Adrián Rivero smaugho

  • Wrocław, Poland
View GitHub Profile
@smaugho
smaugho / mixed_decks_2
Created September 8, 2020 15:46
Mixed decks
[
{
"suit": "hearts",
"value": 2
},
{
"suit": "hearts",
"value": 9
},
{
public class RunningClass {
public static void main(String [] args)
{
List<String> list = new LinkedList<>();
process(Collections.singletonList("2890"), list);
for (String element : list) {
System.out.println(element);
}
@smaugho
smaugho / Chats.java
Last active September 1, 2017 08:19
Code
public void loadChats() {
final User_ currentUser = authenticateManager.getCurrentUser();
if (currentUser != null) {
//Fetch all the teachers associated to this student
$FirebaseDatabase("/associations/{currentUser.getUserId()}/teachers").model(User_.class).setKeyIntoField("userId");
if ($FirebaseDatabase.MultipleValues) {
List<Chat_> chats = new LinkedList<>();
@smaugho
smaugho / CustomTimePickerDialog
Created July 7, 2017 14:34
This class overrides the TimePickerDialog, showing alswas the Fixed Spinner even for Android 7 Nougout, and it permits to the spinner only to select in 15 minutes interval
public class CustomTimePickerDialog extends TimePickerDialog {
private final static int TIME_PICKER_INTERVAL = 15;
private TimePicker timePicker;
private final OnTimeSetListener callback;
public HorekoTimePicker(Context context,
OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView) {
super(context, callBack, hourOfDay, minute/TIME_PICKER_INTERVAL, is24HourView);
this.callback = callBack;
@smaugho
smaugho / DecleX.java
Last active May 3, 2017 14:34
Callback variables in Action Selectors
String[] types= {"Select Date", "Select Time"}
$AlertDialog().items(types);
if ($AlertDialog.ItemSelected) {
int $position = 0;
if ($position == 0 ) {
$DateDialog();
int $year = 0, $month = 0, $day = 0;
@smaugho
smaugho / DecleX.java
Created May 3, 2017 13:13
Notifications Action Example
//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);
@smaugho
smaugho / DecleX.java
Created May 3, 2017 13:03
$DateDialog and $TimeDialog Actions
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();
@smaugho
smaugho / DecleX.java
Last active May 4, 2017 14:12
AlertDialog action example
//Showing AlertDialog with a message and a title
//----------------------------------------------
$AlertDialog().title("Example")
.message("This is an example")
.positiveButton("OK");
//Showing a "Rate this app" message using Strings resources
//---------------------------------------------------------
$AlertDialog().message(R.string.rate_this_app)
@smaugho
smaugho / DecleX.java
Created April 29, 2017 17:27
ProgressDialog Example
Dialog dialog = $ProgressDialog().message("Loading…").dialog();
//Execute time consuming actions
dialog.dismiss();
@smaugho
smaugho / DecleX.java
Created April 29, 2017 17:16
Toast using example
@Model
User_ user;
@Click
void sayHelloToUser() {
$Toast("Hello {user.getName()}!");
}