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
// Cria essa variável antes de chamar o método
// Aqui você instancia um Handler, que é uma Atividade (Task) de segundo plano semelhante à AsynkTask.
Handler handler = new Handler();
/**
* Chama esse método de onde vc quer que o layout mude.
* Ex: Dentro do onCreate.
*/
public void metodoParaMudarBackground(Context context) {
// Executa uma thread.
<div class="input-field col s6">
@inputText(userForm("name"), 'id -> "name", '_label -> null)
<label for="name">NOME</label>
</div>
@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>
@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 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 / 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 / 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 / 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 / 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 / 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>();
/**