Skip to content

Instantly share code, notes, and snippets.

View billmote's full-sized avatar

Bill Mote billmote

  • Boca Raton, FL
  • 04:24 (UTC -04:00)
View GitHub Profile
@trongtinh1212
trongtinh1212 / Tweaks.reg
Last active April 17, 2024 08:23
Registry Tweaks Windows 10
Windows Registry Editor Version 5.00
;USE AT YOUR OWN RISK!
;USE AT YOUR OWN RISK!
;USE AT YOUR OWN RISK!
;Improves system responsiveness and network speed.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile]
"SystemResponsiveness"=dword:00000001
@patrickhammond
patrickhammond / GsonParser.java
Last active August 29, 2015 14:16
Jackson parser behavior when encountering integer, nulls, and empty strings.
import com.google.gson.Gson;
import java.io.IOException;
public class GsonParser implements Parser {
@Override
public <T> T parse(String json, Class<T> clazz) throws IOException {
return new Gson().fromJson(json, clazz);
}
}
@JakeWharton
JakeWharton / gist:f50f3b4d87e57d8e96e9
Created February 7, 2015 01:59
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
@patrickhammond
patrickhammond / README.md
Last active April 30, 2018 21:24
Faster way to include stripped down Google Mobile Services in your application as a workaround to the 64k dex method limit problem that GMS frequently introduces. See README.md for details.

Context

I was previously using https://gist.github.com/dmarcato/d7c91b94214acd936e42 to strip down Google Mobiele Services, but the build times for my project in Android Studio consistently exceeded 75 seconds; this solution is much less dynamic (and even a little ugly) but keeps my build times less than 15s.

Assumptions

  • Your app module has a directory named aars that will work as a project specific Maven repository; this directory should be placed under version control.
  • Maven (mvn) is installed and available on your path when running this script.

Usage

public class MyAdapter extends BaseAdapter {
@Override public void getView(int position, View view, ViewGroup parent) {
ViewHolder holder;
if (view != null) {
holder = (ViewHolder) view.getTag();
} else {
view = inflater.inflate(R.layout.whatever, parent, false);
holder = new ViewHolder(view);
view.setTag(holder);
}
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* An implementation of {@link BaseAdapter} which uses the new/bind pattern and
* view holder pattern for its views.
*
@JakeWharton
JakeWharton / BindingAdapter.java
Last active July 25, 2023 05:49
An adapter base class that uses a new/bind pattern for its views.
// Apache 2.0 licensed.
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
/** An implementation of {@link BaseAdapter} which uses the new/bind pattern for its views. */
public abstract class BindableAdapter<T> extends BaseAdapter {