Skip to content

Instantly share code, notes, and snippets.

@romannurik
romannurik / DashboardLayout.java
Created March 23, 2011 05:06
A custom Android layout class that arranges children in a grid-like manner, optimizing for even horizontal and vertical whitespace.
/*
* ATTENTION:
*
* This layout is now maintained in the `iosched' code.google.com project:
*
* http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/ui/widget/DashboardLayout.java
*
*/
/*
@granoeste
granoeste / gist:1033085
Created June 18, 2011 13:15
[Android]Using the Handler and Lopper with HandlerThread
// With reference to the android.app.IntentService of the Android framework
// Member variable
private volatile Looper mServiceLooper;
private volatile ServiceHandler mServiceHandler;
// Handler Class
private final class ServiceHandler extends Handler {
public ServiceHandler(Looper looper) {
super(looper);
@codeincontext
codeincontext / gist:1226678
Created September 19, 2011 14:53
Android square layout
package com.cube.vision;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class SquareLayout extends LinearLayout {
public SquareLayout(Context context) {
super(context);
}
@davidnunez
davidnunez / gist:1404789
Created November 29, 2011 13:20
list all installed packages in android adb shell
pm list packages -f
@kristofferh
kristofferh / git-export
Created December 7, 2011 13:01
"Export" a git repository to zip file
git archive --format zip --output /full/path/to/zipfile.zip master
@Pretz
Pretz / RoundedImageView.java
Created January 10, 2012 02:47
Andround Rounded Image View
package com.yelp.android.ui.widgets;
import com.yelp.android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
@coolaj86
coolaj86 / meta-fts.table.sql
Created July 21, 2012 06:43
Create a virtual full-text search table in sqlite
CREATE TABLE data(
id VARCHAR PRIMARY KEY ,
uuid CHAR NOT NULL ,
created_at INTEGER NOT NULL ,
updated_at INTEGER NOT NULL ,
md5 CHAR NOT NULL ,
sha1 CHAR ,
imported_at INTEGER NOT NULL ,
path TEXT ,
name VARCHAR NOT NULL ,
@nathanchen
nathanchen / JAVA - 操作BigDecimal
Created October 25, 2012 09:13
JAVA - 操作BigDecimal
import java.math.BigDecimal;
public class Arith
{
/**
* 由于Java的简单类型不能够精确的对浮点数进行运算,这个工具类提供精 确的浮点数运算,包括加减乘除和四舍五入。
*/
//默认除法运算精度
private static final int DEF_DIV_SCALE = 10;
@abhinav1592
abhinav1592 / gist:4382110
Last active March 20, 2021 07:46
A simple Notepad using Java. I have used swing and awt.
package notepad;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner;
import java.io.*;
public class Notepad extends JFrame implements ActionListener {
private TextArea textArea = new TextArea("", 0,0, TextArea.SCROLLBARS_VERTICAL_ONLY);
@abender
abender / AbstractDb.java
Last active October 27, 2019 14:53
A simple Android SQLite template to use databases. The example table holds information about users and their corresponding password. (It's only an example to show the usage so the passwords aren't encrypted by the sample code.)
package de.databasetemplate.db;
import java.util.HashMap;
import java.util.Map;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;