Android – Replacement for Gradle “The TaskInternal.execute() method has been deprecated”

So lot’s of people use “dynamic” tasks in gradle, like so:

Which is now deprecated: The TaskInternal.execute() method has been deprecated and is scheduled to be removed in Gradle 5.0. There are better ways to re-use task logic, see We found ourselves in this position with the com.eriwen JS and CSS minification plugins.  The […]

Android – match_parent won’t always match parent

Here’s a simple example:

(You may want to throw that whole block in a ScrollView for more obvious results) So what you have above is pretty straightforward. You have a container with wrap_content for height. It has 2 children, one is at a fixed height of 10000dp, and the other is set to match_parent. […]

Android – Throttle and Debounce

Throttle: one submission every , won’t start a new task until elapsed time has passed. Debounce: one submission every , will cancel all pending tasks to schedule a new one. Both are instantiated with and the only public API is attempt(Runnable), where Runnable is the task to be queued. In practical terms:

In the […]

JavaScript – get absolute position from top or left of document (x, y)

This should probably not be as complicated as it is, but obviously: JavaScript. Anyway, there are 2 basic approaches. You may see offsetTop and offsetLeft used in examples in blogs and on stack. This is great in a garden path setup, but only gives the distance between the element and it’s nearest “offsetParent” (which is […]

Android – layout available space

This is one of the most common questions around Android layout, and one that’s not at all intuitive or well documented. Let’s take the most simple use case: you have a thumbnail that’s 75dp on the right, and you want a TextView to take up the rest of the space. Of course, you could satisfy […]

Android – Application object as Server (instances instead of singletons)

Singletons have drawbacks. This is an old argument and I won’t get into it, but if you find static classes or Singletons are serving large portions of your app, here’s an alternative approach I’ve found success with. This is in directly violation of DI and I understand there are valid arguments against it, but at […]

Applying a Paint (including ColorFilters and ColorMatrix) to a View

Stackoverflow has a bunch of examples of how to apply a ColorFilter (and therefore a ColorMatrix) to a bitmap, or an ImageView (which has a built-in API), but applying color effects to an entire View are not nearly as well documented. The basic idea is to use your ColorMatrix instances in ColorFilters, then wrap that […]

Java – simple HashCode generator

Example use:

JavaScript – find next node in dom

Android – pass touch events to a child view

AOSP offers a delegate mechanism to modify the touchable area of Views, but this may not always behave as expected. A common use-case is having a View shown within a constrained area, but wanted to react to scrolling gestures from anywhere on the screen – e.g., imagine a RecyclerView on a landscape tablet that design […]