Skip to content

Instantly share code, notes, and snippets.

View kaneoriley's full-sized avatar

Kane O'Riley kaneoriley

View GitHub Profile
@kaneoriley
kaneoriley / Fragment.kt
Created May 5, 2020 23:21
Safe navigation
/** Workaround for 'unknown to this navigation controller' error */
fun Fragment.isCurrentDestination(): Boolean {
val navController = findNavController()
val currentDestinationId = navController.currentDestination?.id
val fragmentDestinationId = view?.getTag(R.id.tag_navigation_destination_id) ?: currentDestinationId
return if (currentDestinationId == fragmentDestinationId) {
view?.setTag(R.id.tag_navigation_destination_id, fragmentDestinationId)
true
@kaneoriley
kaneoriley / hubottest
Created July 9, 2017 06:34 — forked from coderofsalvation/hubottest
commandline wrapper script to invoke hubot commands from the commandline (handy for testing while developing) using expect
#!/usr/bin/expect -f
# usage: ./hubottest "hubot help"
spawn bin/hubot.coffee
sleep 3
expect "Hubot>"
send "hubot [lrange $argv 0 10]\n"
expect eof
@kaneoriley
kaneoriley / BetterBounceInterpolator.java
Created January 19, 2017 23:59 — forked from Kraiden/BetterBounceInterpolator.java
A more configurable bounce interpolator for Android animations
import android.view.animation.Interpolator;
import static java.lang.Math.*;
public class BetterBounceInterpolator implements Interpolator {
private int mBounces;
private double mEnergy;
/** Have more control over how to bounce your values.
*
@kaneoriley
kaneoriley / AndroidManifest.xml
Created May 22, 2016 12:44
Example entry for enabling Firebase Crash Reporting in a background process
<!-- the provider must extend com.google.firebase.provider.FirebaseInitProvider -->
<provider
android:process=":background_process"
android:name="my.app.package.BackgroundProcessFirebaseProvider"
android:exported="false"
android:authorities="my.app.package.firebaseinitprovider"
android:initOrder="100" />
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
<activity
android:enabled="false"
android:icon="@drawable/leak_canary_icon"
android:label="@string/__leak_canary_display_activity_label"
android:name="com.squareup.leakcanary.internal.DisplayLeakActivity"
android:taskAffinity="com.squareup.leakcanary"
android:theme="@style/__LeakCanary.Base">
<intent-filter tools:node="remove">
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>