Skip to content

Instantly share code, notes, and snippets.

@Volcanoscar
Volcanoscar / image_resize
Last active August 29, 2015 14:26 — forked from moltak/image_resize
안드로이드 이미지 리사이즈
#!/usr/bin/python
from os import listdir
from os.path import isfile, join
import os
import shutil
from PIL import Image
import string
xxhdpi = './drawable-xxhdpi/'
@Volcanoscar
Volcanoscar / gist:b423d431be448d7c01b3
Last active August 29, 2015 14:26 — forked from saymagic/gist:f8734b11a7b50decf303
ActionBar useful functions.
//设置ActionBar图片常显
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
if (featureId == Window.FEATURE_ACTION_BAR && menu != null) {
if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
try {
Method m = menu.getClass().getDeclaredMethod(
"setOptionalIconsVisible", Boolean.TYPE);
m.setAccessible(true);
m.invoke(menu, true);
@Volcanoscar
Volcanoscar / RevealDrawable.java
Last active August 29, 2015 14:26 — forked from rharter/RevealDrawable.java
A Drawable that transitions between two child Drawables based on this Drawable's current level value. The idea here is that the center value (5000) will show the 'selected' Drawable, and any other value will show a transitional value between the 'selected' Drawable and the 'unselected' Drawable.
package com.pixite.fragment.widget;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.Callback;
import android.view.Gravity;
@Volcanoscar
Volcanoscar / ParallaxPageTransformer.java
Last active September 10, 2015 05:50 — forked from johncordeiro/ParallaxPageTransformer.java
PagerTransformer for Parallax views.
import android.support.v4.view.ViewPager;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
/**
* Parallax transformer for ViewPagers that let you set different parallax
* effects for each view in your Fragments.
*
@Volcanoscar
Volcanoscar / ActivityToView.java
Last active September 10, 2015 05:53 — forked from JetXing/ActivityToView.java
Activity convertion to View
/**
* <p>Helper class for managing multiple running embedded activities in the same
* process. This class is not normally used directly, but rather created for
* you as part of the {@link android.app.ActivityGroup} implementation.
*
* @see ActivityGroup
*
* @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs
* instead; these are also
* available on older platforms through the Android compatibility package.
@Volcanoscar
Volcanoscar / RxAdapter.java
Last active September 10, 2015 05:56 — forked from vijaysharm/RxAdapter.java
On-demand model loading for Android ListView with large number of items
import android.content.Context;
import android.util.LruCache;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import rx.Observable;
import rx.Subscription;
@Volcanoscar
Volcanoscar / gist:700799742ef4d39a7973
Last active September 10, 2015 05:59 — forked from syndarin/gist:8799233
Custom view example
public class ShapeView extends View {
private final static String tag = ShapeView.class.getSimpleName();
private final int DEFAULT_SIZE_DP = 100;
private int measuredWidth;
private int measuredHeight;
private Shape shapeType;
private int color;
@Volcanoscar
Volcanoscar / HeaderFooterRecyclerViewAdapter.java
Last active September 10, 2015 06:04 — forked from mheras/HeaderFooterRecyclerViewAdapter.java
Header & footer support for RecyclerView.Adapter
public abstract class HeaderFooterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_MAX_COUNT = 1000;
private static final int HEADER_VIEW_TYPE_OFFSET = 0;
private static final int FOOTER_VIEW_TYPE_OFFSET = HEADER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private static final int CONTENT_VIEW_TYPE_OFFSET = FOOTER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private int headerItemCount;
private int contentItemCount;
private int footerItemCount;
@Volcanoscar
Volcanoscar / 10: animator-morph_ridge_2_to_tick.xml
Last active September 10, 2015 06:07 — forked from nickbutcher/10: animator-morph_ridge_2_to_tick.xml
Demonstrating an animation for scanning a fingerprint and showing success or failure. This uses a number of AnimatedVectorDrawables (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) to 'morph' parts of the fingerprint into the tick or cross to report success or failure. It also uses a moving clip-pat…
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@Volcanoscar
Volcanoscar / 1 search_bar.xml
Last active September 10, 2015 06:08 — forked from nickbutcher/1 search_bar.xml
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0