Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrián Rivero smaugho

  • DSpot Sp. z o.o
  • Wrocław, Poland
View GitHub Profile
View mixed_decks_2
[
{
"suit": "hearts",
"value": 2
},
{
"suit": "hearts",
"value": 9
},
{
View Recursive problem
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);
}
View Chats.java
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 Jul 7, 2017
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
View CustomTimePickerDialog
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
Callback variables in Action Selectors
View DecleX.java
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
Notifications Action Example
View DecleX.java
//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
$DateDialog and $TimeDialog Actions
View DecleX.java
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
AlertDialog action example
View DecleX.java
//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 Apr 29, 2017
ProgressDialog Example
View DecleX.java
Dialog dialog = $ProgressDialog().message("Loading…").dialog();
//Execute time consuming actions
dialog.dismiss();
@smaugho
smaugho / DecleX.java
Created Apr 29, 2017
Toast using example
View DecleX.java
@Model
User_ user;
@Click
void sayHelloToUser() {
$Toast("Hello {user.getName()}!");
}