Skip to content

Instantly share code, notes, and snippets.

View creativedrewy's full-sized avatar

Andrew Watson creativedrewy

View GitHub Profile
@creativedrewy
creativedrewy / 06-03-2016.md
Last active January 25, 2024 07:10
## Quick Hit: styling an Android checkbox w/ AppCompat compatibility

The Problem

It turns out trying to find information about how to style an Android checkbox is actually quite challenging. Searching reveals a smattering of blog posts and Statck Overflow articles that don't really solve the problem. Here's what I was trying to do:

  • Change the default unchecked "open box" color on a checkbox
  • Change the default checked box color on a checkbox
  • Use in an API leve 18 Android app

It turns out the solution is relatively simple.

@creativedrewy
creativedrewy / 2016-08-05.md
Last active September 12, 2016 18:00
## Quick Hit: Android menus inside library projects

Summary: Android has issues if you have identically named menu resources in a library and consuming app project.

I recently discovered something to look out for if you are attempting to work with Activity toolbar/actionbar menus inside of a library. In my case, here is what I was doing:

  • Working with an activity inside of a library project.
  • Attempting to inflate a menu resource in the library Activity that was contained inside of the library project.
  • Open the library activity (actually an extended version of the activity) from the consuming Android app.

When I ran my consuming app activity, I was not seeing changes reflected to the menu in my app. This was really, really confusing.

@creativedrewy
creativedrewy / 2016-10-27.md
Last active August 12, 2021 14:10
## Quick Hit: Getting valid thumbnails using Google Drive Library on Android

Update 10-28-2016: Update to the discussion of the request fields.

The Problem:

When using the Google Drive Java Client Library to list a user's photos and videos in your app, the thumbnailLink property is empty.

The Solution:

As far as I can tell, there is literally no good documentation on the solution for this. However, with the help of a co-worker and the REST API operations, I've gotten the solution.

@creativedrewy
creativedrewy / CustomDatePicker.kt
Last active April 15, 2022 12:45 — forked from izmajlowiczl/CustomDatePicker.java
Date/Time Picker fix for ScrollView - Kotlin
package com.myproject.myapp.myviews
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.DatePicker
/**
* Extended DatePicker to allow for year-selection scrolling within a scrollview
*/
fun <A> chain(vararg funcs: (A) -> Unit): (A) -> Unit {
return fun(a: A) {
funcs.forEach { it(a) }
}
}
fun logThenDoSomething() {
chain({ Log.v("TAG", "Log this first, yo!")}, ::functionInMyClass)
}
@creativedrewy
creativedrewy / pairTo.kt
Created January 11, 2019 22:15
pairTo.kt
/**
* Combine two objects into a Pair
*/
infix fun <A, B> A.pairTo(that: B): Pair<A, B> = Pair(this, that)
/**
* Combine three objects into a Triple (by way of one Pair and a new value)
*/
infix fun <A, B, C> Pair<A, B>.tripleTo(that: C) = Triple(first, second, that)
/**
* Execute a lambda with two verified non-null values
*/
inline fun <T : Any, U : Any, W : Any> Pair<T?, U?>.bothNotNull(block: (one: T, two: U) -> W) {
first?.let { one ->
second?.let { two ->
block(one, two)
}
}
}
@creativedrewy
creativedrewy / BlockCommentDetector.kt
Created January 11, 2019 22:18
//BLOCK comment lint rule
class BlockCommentDetector : Detector(), Detector.UastScanner {
companion object {
val ISSUE: Issue = Issue.create(
"BlockComment",
"BLOCK comment found, cannot continue build.",
"Please resolve all BLOCK commented code before merging.",
Category.CORRECTNESS,
6,
Severity.ERROR,
Implementation(BlockCommentDetector::class.java, Scope.JAVA_FILE_SCOPE)
@creativedrewy
creativedrewy / .bash_profile
Last active October 26, 2021 08:57
My Config Files
alias ls='ls -l'
alias weather='curl wttr.in/SanFrancisco?n'
alias nuget="mono /usr/local/bin/nuget.exe"
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home"
export PATH=$PATH:/Users/<user>/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/<user>/Library/Android/sdk/emulator
export PATH=$PATH:/usr/local/bin
@creativedrewy
creativedrewy / 07-21-19-link.md
Last active July 24, 2019 21:29
## Fancy link previewing in React