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 MainActivity extends Activity {
ProductDAO dao;
EditText nomeProduto, descricaoProduto;
Button btnCadatrarProduto;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@Felipe00
Felipe00 / GSONConverter.java
Last active December 23, 2015 12:13
Exemplo de como receber uma resposta do servidor atravรฉs do GSON
//Baixe a dependรชncia: compile 'org.immutables:gson:2.1.4'
//Implemente a interface Serializรกvel. Se houver outras classes nos atributos, implemente a interface nelas tambรฉm!
public class User implements Serializable {
private String login;
private String senha;
//Getters and Setters..
}
//Recebendo uma Lista do servidor (webservice)
@Felipe00
Felipe00 / MainActivity.java
Last active November 27, 2015 19:33
Como implementar uma ListView e um BaseAdapter.
public class MainActivity extends Activity {
List<String> listaBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listaBox = new ArrayList<String>();
/**
@Felipe00
Felipe00 / GcmSender.java
Last active November 12, 2015 00:28
Classe pra enviar uma mensagem por meio do Gcm do google. Tรก quebrado :T
package util;
import ch.qos.logback.core.net.SyslogOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.simple.JSONObject;
import play.Logger;
@Felipe00
Felipe00 / playintellijidea.md
Created October 29, 2015 21:12 — forked from ntenisOT/playintellijidea.md
Build and Debug Play 2.3+ using IntellijIdea 14

Download and Installation

Download Play Framework:

 https://www.playframework.com/download

Execute:

./activator ( Mac )

@Felipe00
Felipe00 / LocalController.java
Last active October 20, 2015 20:53
Exemplo de view e controller para editar um objeto.
// Recebo o id da View
public Result update(Long id) {
Form<Local> editForm = localForm.bindFromRequest();
//Busco o local pelo id (no banco)
Local localFromDb = Local.find.byId(id);
if (editForm.hasErrors()) {
LocalController.flashGlobalError(String.valueOf(editForm.get().getId()));
return badRequest(views.html.localEdit.render(localForm, id));
@Felipe00
Felipe00 / LocalController.java
Last active October 16, 2015 23:10
Manda o id sempre null para o controller
public Result update(Long id) {
Form<Local> editForm = localForm.bindFromRequest();
Local localFromForm = Local.find.byId(id);
if (editForm.hasErrors() || editForm.get().getId() == null) {
return badRequest(views.html.localEdit.render(localForm, localFromForm.getMainUser(), id));
}
Local local = editForm.get();
Ebean.refresh(local);
return redirect(routes.LocalController.localByUser(localFromForm.getMainUser().getId()));
@Felipe00
Felipe00 / index.scala.html
Created October 15, 2015 18:54
align button problem
<div class="card">
<div class="col s12">
<div class="row">
<!-- like <form> tag -->
@form(routes.MainUserController.findUserByName(), 'class -> "container") {
<div class="input-field col s8">
<input type="text" id="name" name="name" required placeholder="Pesquise um cliente" value="@userForm.apply(" name").value" />
</div>
<div class="col s4">
<button class="btn waves-effect waves-light" type="submit"
@Felipe00
Felipe00 / LocalType
Last active October 15, 2015 19:57
Select with Enum Options
public enum LocalType {
PREFEITURA(1), CAMARA(2);
public final int id;
LocalType(int id) {
this.id = id;
}
}
@Felipe00
Felipe00 / index.scala.html
Created October 13, 2015 20:38
Problema ao renderizar uma tag @input (play framework)
<div class="input-field col s6">
@inputText(userForm("name"), 'id -> "name", '_label -> null)
<label for="name">NOME</label>
</div>