Skip to content

Instantly share code, notes, and snippets.

View chiemy's full-sized avatar

chiemy chiemy

View GitHub Profile
@chiemy
chiemy / ColorOptionsView.java
Last active August 29, 2015 14:06
blog code snippet
package com.vogella.android.customview.compoundview;
import com.vogella.android.view.compoundview.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
// Defines a list of columns to retrieve from the Cursor and load into an output row
String[] mWordListColumns ={
UserDictionary.Words.WORD, // Contract class constant containing the word column name UserDictionary.Words.LOCALE // Contract class constant containing the locale column name
};
// Defines a list of View IDs that will receive the Cursor columns for each row
int[] mWordListItems = { R.id.dictWord, R.id.locale};
// Creates a new SimpleCursorAdapter
mCursorAdapter = new SimpleCursorAdapter(
getApplicationContext(), // 上下文对象
R.layout.wordlistrow, // ListView的Item(一行)
/*
* This defines a one-element String array to contain the selection argument.
*/
String[] mSelectionArgs = {""};
// 从UI中获取单词
mSearchString = mSearchWord.getText().toString();
// Remember to insert code here to check for invalid or malicious input.
// 如果为空,则获取全部单词
if (TextUtils.isEmpty(mSearchString)) {
// 设置选择条件为空,会返回所有
// 查询返回的列
String[] mProjection ={
UserDictionary.Words._ID,    // Contract class constant for the _ID column name   
UserDictionary.Words.WORD,   // Contract class constant for the word column name   
UserDictionary.Words.LOCALE  // Contract class constant for the locale column name};
// 查询条件
String mSelectionClause = null;
// 查询条件的参数值
String[] mSelectionArgs = {""};
// Queries the user dictionary and returns results
mCursor = getContentResolver().query(
UserDictionary.Words.CONTENT_URI, // The content URI of the words table
mProjection, // The columns to return for each row
mSelectionClause // Selection criteria
mSelectionArgs, // Selection criteria
mSortOrder);
public class CircularProgressDrawable extends Drawable
implements Animatable {
private static final Interpolator ANGLE_INTERPOLATOR = new LinearInterpolator();
private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator();
private static final int ANGLE_ANIMATOR_DURATION = 2000;
private static final int SWEEP_ANIMATOR_DURATION = 600;
private static final int MIN_SWEEP_ANGLE = 30;
private final RectF fBounds = new RectF();
@chiemy
chiemy / 0_reuse_code.js
Created March 27, 2014 13:51
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console