Skip to content

Instantly share code, notes, and snippets.

View Jawnnypoo's full-sized avatar

John Carlson Jawnnypoo

View GitHub Profile
package com.jawnnypoo.example;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
### Keybase proof
I hereby claim:
* I am Jawnnypoo on github.
* I am jawnnypoo (https://keybase.io/jawnnypoo) on keybase.
* I have a public key whose fingerprint is 6685 FBCB 3BF0 3236 DDB8 0B53 816A 9180 2393 C178
To claim this, I am signing this object:
@Jawnnypoo
Jawnnypoo / colors.xml
Created October 15, 2015 19:16
Colors Starter
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#ffffffff</color>
<color name="white_90">#E6ffffff</color>
<color name="white_80">#CCffffff</color>
<color name="white_70">#B3ffffff</color>
<color name="white_60">#99ffffff</color>
<color name="white_50">#80ffffff</color>
<color name="white_40">#66FFFFFF</color>
@Jawnnypoo
Jawnnypoo / styles.xml
Created April 7, 2016 16:13
AppCompatDialog theme
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:textColorPrimary">@color/black</item>
<item name="alertDialogTheme">@style/AppAlertDialogStyle</item>
</style>
long days = ChronoUnit.DAYS.between(LocalDate.now(), otherDate);
@Jawnnypoo
Jawnnypoo / CommonIntents.java
Last active August 8, 2017 16:54
Common Android Intents, as builders
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.app.SearchManager;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
import android.provider.AlarmClock;
@Jawnnypoo
Jawnnypoo / onPreDrawExample
Created December 10, 2014 18:20
Example of setting an onPreDrawListener on a view
final View view = findViewById(R.id.view_id);
view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
view.getViewTreeObserver().removeOnPreDrawListener(this);
//Do the things you want to do. Return true if you want to draw that frame, otherwise return false
return false;
}
});
@Jawnnypoo
Jawnnypoo / CrashlyticsTree.java
Created March 8, 2016 15:16
Timber tree which prints error messages and stack traces to Crashlytics
package com.example;
import android.util.Log;
import com.crashlytics.android.Crashlytics;
import timber.log.Timber;
/**
* {@link timber.log.Timber.Tree} which prints important messages to Crashlytics
@Jawnnypoo
Jawnnypoo / ObjectAnimator Change Icon Color
Last active May 13, 2020 16:08
Use ObjectAnimator to change color of an icon dynamically
We couldn’t find that file to show.
@Jawnnypoo
Jawnnypoo / AccelerometerActivity.java
Last active March 25, 2022 22:03
Accelerometer example that shows moving a circle based on accelerometer input.
package com.jawnnypoo.example;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.hardware.Sensor;
import android.hardware.SensorEvent;