Skip to content

Instantly share code, notes, and snippets.

@pskink
pskink / VG.java
Last active August 29, 2015 14:07
// ViewDragHelper test
public class VG extends ViewGroup {
private static final String TAG = "VG";
private final ViewDragHelper mDragHelper;
private Rect[] mBounds = new Rect[4];
public VG(Context context) {
super(context);
int[] colors = {Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW};
for (int i = 0; i < 4; i++) {
TextView tv = new TextView(getContext());
package com.example.app.myapplication;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
/*
res/layout/fsvt.xml test layout file:
<?xml version="1.0" encoding="utf-8"?>
@pskink
pskink / ColumnExtenderCursor.java
Created August 9, 2015 06:07
ColumnExtenderCursor
package com.example.app.myapplication;
import android.database.Cursor;
import android.database.CursorWrapper;
public class ColumnExtenderCursor extends CursorWrapper {
private final String[] columnNames;
public ColumnExtenderCursor(Cursor cursor, String... newColumns) {
@pskink
pskink / ghost_contact_cursor
Created September 30, 2015 07:58
ghost contact cursor
// add in Activity#onCreate
ListView lv = new ListView(this);
setContentView(lv);
Uri uri = ContactsContract.Contacts.CONTENT_URI;
Wrapper c = Wrapper.query(getContentResolver(), uri, null, null, null, ContactsContract.Contacts.DISPLAY_NAME, getResources());
String[] from = {
ContactsContract.Contacts.DISPLAY_NAME,
Wrapper.PHONES,
};
abstract class DecoratedDrawable extends LevelListDrawable {
public DecoratedDrawable(Context ctx, int resId) {
TypedArray typedArray = ctx.obtainStyledAttributes(new int[] {resId});
Drawable drawable = typedArray.getDrawable(0);
typedArray.recycle();
if (drawable == null) {
drawable = ctx.getResources().getDrawable(resId);
}
init(drawable);
}
class CircleBitmapDrawable extends Drawable {
Bitmap bitmap;
Paint maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
Paint borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
float side;
float radius;
public CircleBitmapDrawable(Bitmap wrappedBitmap, float borderWidth, int borderColor) {
bitmap = wrappedBitmap;
borderPaint.setStyle(Paint.Style.STROKE);
class RoundedListView extends StatefulWidget {
@override
_RoundedListViewState createState() => _RoundedListViewState();
}
class _RoundedListViewState extends State<RoundedListView> with TickerProviderStateMixin {
var size = 32;
@override
Widget build(BuildContext context) {
/*
*
<declare-styleable name="GridSpanLayout">
<attr name="rows" format="integer" />
<attr name="columns" format="integer" />
<attr name="column" format="integer" />
<attr name="row" format="integer" />
<attr name="columnSpan" format="integer" />
<attr name="rowSpan" format="integer" />
class LongPressRipple extends StatefulWidget {
final Widget child;
final VoidCallback onLongPress;
LongPressRipple({
Key key,
this.child,
@required this.onLongPress,
}) : assert(onLongPress != null), super(key: key);
class FruitColorizer extends TextEditingController {
final Map<String, TextStyle> mapping;
final Pattern pattern;
FruitColorizer(this.mapping)
: pattern = RegExp(mapping.keys.map((key) => RegExp.escape(key)).join('|'));
FruitColorizer.fromColors(Map<String, Color> colorMap)
: this(colorMap.map((text, color) => MapEntry(text, TextStyle(color: color))));