Skip to content

Instantly share code, notes, and snippets.

Desmond boxme

Block or report user

Report or block boxme

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
boxme / gist:659843a26e90ab76629128668bd8b97c
Created Apr 18, 2016 — forked from ixiyang/gist:7922825
difference between requestLayout() and forceLayout()
View gist:659843a26e90ab76629128668bd8b97c
Please note that the methods in Listing 1-10 are internal methods and are not part of the
public API, so they may change with newer releases. However, the underlying protocol would remain
the same.
In Listing 1-10, it is easier to first tell what forceLayout( ) is. It is like a touch command in build
environments. Usually when a file hasn’t changed, the build dependencies will ignore it. So, you
force that file to be compiled by “touch”ing, and thereby updating its time stamp. Just like touch,
the forceLayout( ) will not invoke any build commands by itself (unless your build environment is too
boxme / Android Studio .gitignore
Created May 9, 2015
Android Studio Project .gitignore gist
View Android Studio .gitignore
# generated files
# Ignore gradle files
View Android Color Control Cheat Sheet
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21.
To use the support version of these attributes, remove the android namespace.
For instance, "android:colorControlNormal" becomes "colorControlNormal".
These attributes will be propagated to their corresponding attributes within the android namespace
for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
boxme / BaseFragment
Created Mar 24, 2015
BaseFragment that all Fragments should extend from in order to save state in all circumstances using argument
View BaseFragment
public abstract class BaseFragment extends Fragment {
static final String STATE = "saved_state";
Bundle mSavedState;
public BaseFragment() {}
public abstract void refreshData();
protected void showSoftKeyboard(View editText) {
boxme / blurringTheBitmap
Created Mar 24, 2015
Blurring an image using Renderscript
View blurringTheBitmap
public static Bitmap blendRenderScript(RenderScript rs, Bitmap originalBitmap) {
// Creates a matching Renderscript allocation object and
// copies the contents of the bitmap into the allocation
Allocation input = Allocation.createFromBitmap(rs, originalBitmap,
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
// Generates an Allocation identical in structure to the first
Allocation output = Allocation.createTyped(rs, input.getType());
boxme / CursorPagerAdapter
Created Mar 24, 2015
PagerAdapter that uses uses Cursor as its data format
View CursorPagerAdapter
public abstract class CursorPagerAdapter extends PagerAdapter {
public static final String TAG = CursorPagerAdapter.class.getSimpleName();
protected WeakReference<Context> ctxRef;
protected boolean mDataValid;
protected boolean mAutoRequery;
protected Cursor mCursor;
protected int mRowIDColumn;
View AbstractCursorRecyclerAdapter
public abstract class AbstractCursorRecyclerAdapter<VH extends RecyclerView.ViewHolder>
extends RecyclerView.Adapter<VH> {
protected Context mContext;
protected Cursor mCursor;
protected boolean mDataValid;
protected int mRowIDColumn;
protected ChangeObserver mChangeObserver;
boxme / Simple Hide & Reveal Animation
Created Mar 12, 2015
Switching between views with reveal and hide animations
View Simple Hide & Reveal Animation
private void setupView() {
? R.drawable.revealed
: R.drawable.not_revealed);
int hideTranslateY = -mToBeRevealedViewContainer.getHeight() / 4; // last 25% of animation
if (mIsRevealed && mToBeRevealedViewContainer.getTranslationY() == 0) {
// initial setup
You can’t perform that action at this time.