Skip to content

Instantly share code, notes, and snippets.

Avatar

Desmond boxme

  • Singapore
View GitHub Profile
@boxme
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
boxme / Android Studio .gitignore
Created May 9, 2015
Android Studio Project .gitignore gist
View Android Studio .gitignore
*.iml
# generated files
bin/
gen/
# Ignore gradle files
.gradle
build/
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
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
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
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
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() {
mViewStateIndicator.setImageResource(mIsRevealed
? R.drawable.revealed
: R.drawable.not_revealed);
int hideTranslateY = -mToBeRevealedViewContainer.getHeight() / 4; // last 25% of animation
if (mIsRevealed && mToBeRevealedViewContainer.getTranslationY() == 0) {
// initial setup
mToBeRevealedViewContainer.setAlpha(0);
mToBeRevealedViewContainer.setTranslationY(hideTranslateY);
}
You can’t perform that action at this time.