Skip to content

Instantly share code, notes, and snippets.

View smaugho's full-sized avatar

Adrián Rivero smaugho

  • DSpot Sp. z o.o
  • Wrocław, Poland
View GitHub Profile
@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 / 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 / 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
Last active May 4, 2017 13:47
Passing Parameters when Navigating
@EActivity(R.id.activity_settings)
public class SettingsActivity extends Activity {
@Extra
String userName;
@Click
void showProfile() {
$ProfileFragment().userName(userName);
}
@smaugho
smaugho / DecleX.java
Last active May 4, 2017 13:01
Actions in fields
@EActivity(R.id.activity_settings)
public class SettingsActivity extends Activity {
@Click
$ProfileFragment showProfile;
@Click
$NotificationsFragment showNotifications;
...
@smaugho
smaugho / DecleX.java
Last active May 4, 2017 12:52
Navigating in the app with Actions
@EActivity(R.id.activity_settings)
public class SettingsActivity extends Activity {
@Click
void showProfile() {
$ProfileFragment();
}
@Click
void showNotifications() {
$NotificationsFragment();
@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
Last active May 3, 2017 13:42
Actions handling Future Results
@Click
void sendInformation() {
int informationType = getInformationType();
$Toast("The information type index is {informationType}");
}
int getInformationType() {
String[] types= {"Type 1", "Type 2", "Type 3"}
$AlertDialog().items(types).negativeButton("Cancel");