Skip to content

Instantly share code, notes, and snippets.

@emoralest
emoralest / splitToArrayList
Created April 19, 2015 03:31
Convert String to ArrayList. Ideal for simple adapters like spiners o listviews.
private ArrayList<String> splitToArrayList(String string) {
ArrayList<String> result = new ArrayList<String>();
if(string == null || string.trim().length() == 0)
return result;
//Pipes, in this case.
String[] split = string.split("[|]");
return new ArrayList<String>(Arrays.asList(split));
}
@emoralest
emoralest / DialogDivider.java
Created April 14, 2015 19:57
Android - Ocultar Divider de un Dialog
final Dialog dialog = new Dialog(getActivity());
dialog.setContentView(R.layout.dialog_regemail);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
//HACK PARA ELIMINAR DIVIDER DE UN DIALOG
int dividerId = dialog.getContext().getResources().getIdentifier("android:id/titleDivider", null, null);
View divider = dialog.findViewById(dividerId);
divider.setBackgroundColor(getResources().getColor(android.R.color.transparent));
//CONTROLES DENTRO DEL DIALOG
Button btnRegistrar = (Button) dialog.findViewById(R.id.btnRegistrar);
//LISTENER DE BOTÓN DEL DIALOG
@emoralest
emoralest / LocationService.java
Created April 10, 2015 03:53
The best way for get location in background service in Android
/*
* LocationService
* La mejor forma de obtener Lat y Long dependiendo el proveedor.
* Usando un BroadcastReceiver para la obtención de location
*
* import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;