Skip to content

Instantly share code, notes, and snippets.

Avatar
⚛️
Writing React components.

Douglas Nassif Roma Junior douglasjunior

⚛️
Writing React components.
View GitHub Profile
@douglasjunior
douglasjunior / ProgressRequestBody.java
Created Feb 19, 2016
Class used to monitoring the file upload progress in Retrofit2 library.
View ProgressRequestBody.java
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okio.BufferedSink;
@douglasjunior
douglasjunior / Codigo.java
Last active Nov 4, 2015
Exemplo de ID com Auto-incremento utilizando Realm Database
View Codigo.java
/**
* Entidade que irá armazenar sempre o último código de cada entidade na base de dados Realm.
*
* Created by douglas on 06/08/15.
*/
public class Codigo extends RealmObject {
@PrimaryKey
private String classe;
@douglasjunior
douglasjunior / JsonChildSerializer.java
Last active Oct 8, 2015
Implementação de JsonSerializer para evitar recursividade. Somente o ID dos objetos filhos é serializado.
View JsonChildSerializer.java
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
/**
* Implementação do JsonSerializar customizado para adicionar somente o ID do objeto filho.
*
* Created by douglas on 02/02/15.
@douglasjunior
douglasjunior / BodyEditorLoader.java
Last active Oct 5, 2015
Fix for JsonParser problem.
View BodyEditorLoader.java
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.OrderedMap;
@douglasjunior
douglasjunior / CustomMaterialSpinner.java
Created Sep 30, 2015
Override to fix enable/disable problem.
View CustomMaterialSpinner.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner;
/**
* Created by Douglas Nassif Roma Junior on 30/09/15.
*/
public class CustomMaterialSpinner extends MaterialBetterSpinner {
@douglasjunior
douglasjunior / OnItemSelectedListener.java
Last active Jan 20, 2019
Implementação de Adapter genérico para utilizar no com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner (ver comentários)
View OnItemSelectedListener.java
package com.youtproject.util;
import android.text.Editable;
import android.text.TextWatcher;
/**
* Listener used to capture "on selected item" event on MaterialBetterSpinner.
* Created by douglas on 22/09/15.
*/
public abstract class OnItemSelectedListener implements TextWatcher {
@douglasjunior
douglasjunior / AbstractAdapter.java
Last active Sep 10, 2015
Exemplo de uso do Adapter com RecyclerView
View AbstractAdapter.java
import android.content.Context;
import android.content.res.TypedArray;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import java.util.ArrayList;
import java.util.List;
@douglasjunior
douglasjunior / CustomAndroidApplication.java
Created Sep 8, 2015
Fix 24hours for android-validation-komensky
View CustomAndroidApplication.java
import android.app.Application;
import eu.inmite.android.lib.validations.form.validators.ValidatorFactory;
/**
* Created by douglas on 06/08/15.
*/
public class CustomAndroidApplication extends Application {
static {
// register the custom validator
@douglasjunior
douglasjunior / exemploJson.php
Last active Jun 22, 2020
Exemplo de consulta no banco de dados e retorno de JSON utilizando PHP e MySQL.
View exemploJson.php
<?php
header('Content-Type: application/json');
header('Character-Encoding: utf-8');
// recebe os parâmetros
$QTD = (int) filter_input(INPUT_GET, 'qtd', FILTER_VALIDATE_INT);
$LAT = (float) filter_input(INPUT_GET, 'lat', FILTER_VALIDATE_FLOAT);
$LNG = (float) filter_input(INPUT_GET, 'lng', FILTER_VALIDATE_FLOAT);
if ($LAT && $LNG) {
View AsyncTask.swift
//
// AsyncTask.swift
//
// Created by Douglas Nassif Roma Junior on 08/06/15.
// Copyright (c) 2015 Douglas Nassif Roma Junior. All rights reserved.
//
import Foundation
class AsyncTask<Params, Progress, Result> : NSObject {
You can’t perform that action at this time.