Skip to content

Instantly share code, notes, and snippets.

View Richie97's full-sized avatar

Eric Richardson Richie97

View GitHub Profile
@Richie97
Richie97 / CommitEditText.java
Last active November 17, 2016 19:13
CommitContentApi
public class CommitEditText extends AppCompatEditText {
private CommitListener commitListener;
public CommitEditText(Context context) {
super(context);
}
public CommitEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Richie97
Richie97 / FreeMem.java
Created November 16, 2016 19:41
Getting Free Space on External Storage
public long getFreeMemory() {
File externalStorageDir = Environment.getExternalStorageDirectory();
StatFs statFs = new StatFs(externalStorageDir.getAbsolutePath());
long blocks = statFs.getAvailableBlocks();
long free = (blocks * statFs.getBlockSize()) / 1024 / 1024;
return free;
}
100% - FF
95% - F2
90% - E6
85% - D9 
80% - CC
75% - BF
70% - B3
65% - A6
60% - 99
55% - 8C
@Richie97
Richie97 / giveup.java
Created July 23, 2016 18:08
Gist giving up
//give up
repositories{
flatDir{
dirs 'libs'
}
mavenCentral()
}
dependencies {
compile '**PACKAGE NAME**:**NAME OF AAR**:**VERSION**@aar'
//Gradle Dependency:
//In your build gradle
dependencies {
compile 'com.willowtreeapps:oak-library:1.3.3'
}
//Maven Dependency:
//In your pom.xml
<oak.widget.TextViewWithFont
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:res="http://schemas.android.com/apk/res-auto"
res:oakFont="Font.ttf"/>
<oak.widget.TextViewWithFont
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:oak="http://oak/oak/schema"
oak:font="Font.ttf"/>
@Richie97
Richie97 / gist:8221724
Created January 2, 2014 16:22
AsyncTaskLoader Fun.
public class SampleLoader extends AsyncTaskLoader<List<SampleItem>> {
// We hold a reference to the Loader’s data here.
private List<SampleItem> mData;
public SampleLoader(Context ctx) {
// Loaders may be used across multiple Activitys (assuming they aren't
// bound to the LoaderManager), so NEVER hold a reference to the context
// directly. Doing so will cause you to leak an entire Activity's context.
// The superclass constructor will store a reference to the Application
OkHttpClient providesOkHttpClient() {
OkHttpClient httpClient = new OkHttpClient();
SSLContext sslContext;
try {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, null, null);
} catch (GeneralSecurityException e) {
throw new AssertionError(); // The system has no TLS. Just give up.
}
httpClient.setSslSocketFactory(sslContext.getSocketFactory());