Skip to content

Instantly share code, notes, and snippets.

View Felipe00's full-sized avatar
😤
Banzai!

Felipe Costa Felipe00

😤
Banzai!
  • SulAmérica
  • Brazil - PI
View GitHub Profile
public class ServiceRace extends IntentService {
private static final String TAG = "UserTravelResponse";
private static final String TAXI_ACCEPTED = "taxi_accepted";
private static final String USER_RESPONSE_FINISHED = "finished";
private static final String USER_RESPONSE_CANCELED = "canceled";
private static final String USER_RESPONSE_MESSAGE = "message";
private final String[] route_status = {""};
private final Boolean[] acceptReceipt = {false};
private final Boolean[] cancelReceipt = {false};
@Felipe00
Felipe00 / CreditCardFormattingTextWatcher.java
Created February 22, 2017 17:57 — forked from epool/CreditCardFormattingTextWatcher.java
Text watcher for giving "#### #### #### ####" format to edit text.
import android.text.Editable;
import android.text.TextWatcher;
/**
* Text watcher for giving "#### #### #### ####" format to edit text.
* Created by epool on 3/14/16.
*/
public class CreditCardFormattingTextWatcher implements TextWatcher {
private static final String EMPTY_STRING = "";
@Felipe00
Felipe00 / Dude.kt
Last active April 14, 2018 05:30
Lambda use cases. Simple example.
public class Dude {
// Easy way ¬¬ april, 14 2018
fun main(args: Array<String>) {
lambdaCall({
System.out.println(it)
})
}
@Felipe00
Felipe00 / Exemplo_page.java
Created April 28, 2017 11:04
Exemplo de interação com a troca de abas do ViewPager
// Verifico se é a aba de produtos e, caso seja, troco o menu da toolbar
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
// Verifico se é a aba de produtos
@Felipe00
Felipe00 / activity_main.xml
Created April 29, 2017 00:45
Ajuda pro Arleyde. Viewpager com título.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F3F3F4"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
@Felipe00
Felipe00 / ExemploSuperClass.java
Created May 4, 2017 14:24
Exemplo de uso de herança
class Monster extends Enemy {
private String monsterName;
protected void monsterfy() {
this.monsterName = "Monster " + getRandomId(); // comando qualquer
}
}
class People extends Monster {
// quando a classe for criada, eu quero que o método monsterfy() execute como um "init()"
@Felipe00
Felipe00 / DialogBuilder.java
Created May 25, 2017 20:35
Generic dialog with a button and a text
public class DialogBuilder {
/**
* Cria um diálogo com uma mensagem personalizada
*
* @param context
* @param message
*/
public static void createGenericErrorDialog(Context context, String message) {
final Dialog errorDialog = new Dialog(context);
@Felipe00
Felipe00 / PlayController.java
Last active November 29, 2017 19:42
Como usar threads e fazer a página aguardar a requisição ser finalizada. [CompletableFuture<Result> , Firebase]
/** This method was called by Play! through the some tag in the html */
public CompletableFuture<Result> submit() {
auth = FirebaseAuth.getInstance(app);
final Form<LoginForm> filledForm = loginForm.bindFromRequest();
return signIn(filledForm);
}
private CompletableFuture<Result> signIn(Form<LoginForm> filledForm) {
final CompletableFuture<Result> resultFuture = new CompletableFuture();
@Felipe00
Felipe00 / ConsultarLista.java
Last active December 30, 2017 01:07
Dúvida: Como retornar uma lista de um objeto Foo, com base no type da list Doo?
class Foo {
public static Finder<Long, Foo> find = new Finder<>(Foo.class);
Long id;
String name;
List<Doo> dooList;
/* Retorna uma lista de objetos Foo pelo type de Doo */
public static List<Foo> getAllFoos(String type) {
@Felipe00
Felipe00 / SeuController.java
Last active January 22, 2018 17:12 — forked from anonymous/LoginForm.java
Chamando um método do Controller através da View - Play framework
public class SeuController extends Controller {
public Result login() {
System.out.println("Chamando meu método java");
// Aqui vc faz algo...
// retorno pra view...
return ok();
}