Skip to content

Instantly share code, notes, and snippets.

package com.google.common.eventbus;
import com.google.common.base.Throwables;
import java.lang.reflect.InvocationTargetException;
public class TestEventBus extends EventBus {
//If version 18 or bellow
@Override
void dispatch(Object event, EventSubscriber wrapper) {
@gautier-levert
gautier-levert / RecyclerViewAdapterBase.java
Created August 24, 2017 14:09
AndroidAnnotations RecyclerViewAdapterBase
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* https://github.com/androidannotations/androidannotations/wiki/Adapters-and-lists#recyclerview-and-viewholder
@gautier-levert
gautier-levert / NoDefaultSpinner.java
Created August 24, 2017 12:50
Android spinner without default value
import android.content.Context;
import android.support.v7.widget.AppCompatSpinner;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
@gautier-levert
gautier-levert / PlayDynamicCustomForms.md
Created July 20, 2017 12:15 — forked from kjorg50/PlayDynamicCustomForms.md
Java Play Framework - Dynamic, Custom Forms

Play Framework Dynamic Forms

This post is intended to summarize my efforts in creating a dynamic form with custom data objects in the Java Play Framework. The version I am working with is 2.3.7. This example proved to be very useful

Motivation

I have a CSVData class in my app, and I want to create instances of this class via form input. Here are the basic attributes of this class, with annotations removed for brevity:

public class CSVData extends VirtualSensor implements CSVWrappable {

 // used by play to save it in the DB
@gautier-levert
gautier-levert / WeatherResponse.java
Created April 3, 2017 14:14
Open Weather API JSON response for tests purpose
package org.mybop.weatherapplication;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class WeatherResponse {
private Coord coord;
@gautier-levert
gautier-levert / AnimalImage.java
Last active February 4, 2016 22:19
Android TP3
package fr.iut_amiens.imagelist;
import java.io.Serializable;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
public class AnimalImage implements Serializable {
public static final List<AnimalImage> ANIMAL_IMAGE_LIST = Arrays.asList(
@gautier-levert
gautier-levert / RandomPasswordGenerator.java
Created October 21, 2014 20:06
Java - random password generation
import java.security.SecureRandom;
import java.util.Random;
/**
* @author softdev7
*/
public class RandomPasswordGenerator {
private static final Random RANDOM = new SecureRandom();
@gautier-levert
gautier-levert / RuntimeTypeAdapterFactory.java
Created October 17, 2014 14:27
Corrected GSON RuntimeTypeAdapterFactory
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@gautier-levert
gautier-levert / SeparatedListAdapter.java
Created October 9, 2014 09:02
ListView with sections
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import java.util.LinkedHashMap;
import java.util.Map;
@gautier-levert
gautier-levert / ArrayRemove.js
Last active August 29, 2015 14:07
JS - Array Remove
// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};