Skip to content

Instantly share code, notes, and snippets.

View jimmy-collazos's full-sized avatar

Jimmy Collazos jimmy-collazos

View GitHub Profile
@jimmy-collazos
jimmy-collazos / axample_link.kml
Created July 13, 2012 13:27
Ejemplode KML con links
@jimmy-collazos
jimmy-collazos / example.aspx
Created June 27, 2012 09:52
Esta función dispara un evento, asociado a un elemento con jQuery, dentro del control de Telerik; el nombre de evento se pasa como parámetro
<%-- Este ejemplo asocia un evento 'OnGridCreated' para cuando el grid se haya creado --%>
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
<ClientEvents OnRowCreated="" OnGridCreated="shootEventFromTelerik('OnGridCreated')" OnRowContextMenu=""/>
</ClientSettings>
@jimmy-collazos
jimmy-collazos / toolsdraw.js
Created June 20, 2012 07:48
haciendo una librería para añadir graficos a google maps. Luego se canceló porque google ya trae uno propio: "drawManager"
var ToolsDraw = (function(window, gmaps, $, undefined){
var STATE_HAND = 'HAND',
STATE_MARKER = '',
STATE_LINE = '',
STATE_POLYLINE = '',
state,
map,
mapListenerInstance,
BASE_URI_ICONMARKER = '/Images/Iconos/MapGrid/{color}.png',
colors = [["red", "#ff0000"], ["orange", "#ff8800"], ["green", "#008000"], ["blue", "#000080"], ["purple", "#800080"]],
@jimmy-collazos
jimmy-collazos / app.java
Created April 27, 2012 14:55
Class for check version instaled in Android App
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
public class App {
public static final String PREFERENCE_APP_KEY = "com.my.app.APP_PREFERENCE_PRIVATE";
public static final String PREFERENCE_VERSION_KEY = "com.my.app.APP_VERSION";
@jimmy-collazos
jimmy-collazos / Snippet_Android_ToggleGPS.java
Created December 5, 2011 18:54
Snippet/Android: Toggle GPS
//recordar activar permisos
//<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
private void toggleGPS(boolean enable) {
String provider = Settings.Secure.getString(getContentResolver(),
Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(provider.contains("gps") == enable) {
return; // the GPS is already in the requested state
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Esta aplicación necesita activar el GPS. ¿Desea activar el GPS?")
@jimmy-collazos
jimmy-collazos / Open_PDF_file.java
Created December 5, 2011 09:26
Snippet/Android: Open PDF file
//see http://stackoverflow.com/questions/2883355/how-to-render-pdf-in-android/
public class OpenPdf extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.OpenPdfButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
@jimmy-collazos
jimmy-collazos / Snippet_Android_IsTableDevice.java
Created December 3, 2011 19:56
Snippet/Android: Detected Table
private boolean isTabletDevice() {
if (android.os.Build.VERSION.SDK_INT >= 11) { // honeycomb
// test screen size, use reflection because isLayoutSizeAtLeast is only available since 11
Configuration con = getResources().getConfiguration();
try {
Method mIsLayoutSizeAtLeast = con.getClass().getMethod("isLayoutSizeAtLeast", int.class);
Boolean r = (Boolean) mIsLayoutSizeAtLeast.invoke(con, 0x00000004); // Configuration.SCREENLAYOUT_SIZE_XLARGE
return r;
} catch (Exception x) {
x.printStackTrace();
@jimmy-collazos
jimmy-collazos / Snippet_Android_AlertDialogTitleMessageIconButton.java
Created December 3, 2011 19:47
Snippet/Android: Simple Alert Dialog Popup with Title, Message, Icon and Button
//@See http://www.androidsnippets.com/simple-alert-dialog-popup-with-title-message-icon-and-button
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Title");
alertDialog.setMessage("Message");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//@ TODO Add your code for the button here.
}
});
// Set the Icon for the Dialog
@jimmy-collazos
jimmy-collazos / MoventosAPI_Test.java
Created October 20, 2011 17:56
Moventos-Api Test for Android
package com.moventos.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
@jimmy-collazos
jimmy-collazos / send_trainer.php
Created October 19, 2011 16:44
Moventos-Api Test :: Send trainer
<?php
$params = array(
'cat' => 'a'
,'resumen'=> json_encode(array(
'speed' => array (
'a' => 12,//media
'b' => 21,//max
),
'time' => array (
'a' => 1318513036,//start