This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.provider.Settings; | |
import android.service.quicksettings.Tile; | |
import android.service.quicksettings.TileService; | |
import android.widget.Toast; | |
import java.util.concurrent.TimeUnit; | |
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// retries up to 3 times while exponentially backing off with each retry | |
.retryWhen(errors -> | |
errors | |
.zipWith( | |
Observable.range(1, MAX_RETRIES), (n, i) -> i | |
) | |
.flatMap( | |
retryCount -> Observable.timer((long) Math.pow(4, retryCount), TimeUnit.SECONDS) | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.desk.android.util; | |
import android.graphics.Color; | |
/** | |
* Lightens or darkens a color | |
*/ | |
public final class ColorUtils { | |
private ColorUtils() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for file in jars/*.jar; do | |
echo $file; /Applications/Android\ Studio.app/sdk/build-tools/19.0.3/dx --dex --output=temp.dex $file 2> /dev/null | |
cat temp.dex| head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"' | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Path; | |
import android.graphics.RectF; | |
import android.util.AttributeSet; | |
import android.widget.RelativeLayout; | |
/** | |
* A {@link android.widget.RelativeLayout} that supports rounded corners. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
f=$(pwd) | |
mkdir drawable-mdpi drawable-hdpi drawable-xhdpi drawable-xxhdpi | |
# fake argv and argc in bash | |
argc=$#; argv[0]=$0 # argv[0] is a prog name | |
for foo in $( seq $argc ) | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dex-method-count() { | |
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"' | |
} | |
function dex-method-count-by-package() { | |
dir=$(mktemp -d -t dex) | |
java -jar baksmali.jar $1 -o $dir | |
for pkg in `find $dir/* -type d`; do | |
java -jar smali.jar $pkg -o $pkg/classes.dex | |
count=$(dex-method-count $pkg/classes.dex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Picasso.with(context).load(url).into(new Target() { | |
@Override | |
public void onSuccess(Bitmap bitmap) { | |
holder.image.setImageBitmap(bitmap); | |
} | |
@Override | |
public void onError() { | |
// handle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ZoomFragment implements OnTouchListener { | |
private static final float MIN_SCALE = 0.95f; | |
private float mLastScaleFactor = 0; | |
private float mTouchY; | |
@Override | |
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { | |
mView = inflater.inflate(R.layout.fragment_layout, container, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.BroadcastReceiver; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.content.IntentFilter; | |
import android.support.v4.content.AsyncTaskLoader; | |
/** | |
* Generic {@link AsyncTaskLoader} which also registers and handles data changes via a {@link BroadcastReceiver}. | |
* | |
* @author jmardis |
NewerOlder