Gil's profile at Stack Overflow Coding challenges at Project Euler

Pro Tip: Android Studio shortcuts for unit tests

Testing is an important part of the development process. Today we will leverage Android Studio shortcuts to create and run unit tests faster and without using a mouse.

Create and run unit tests without a mouse

Read more

TopTal: How I passed the interview

In this blog post I will share my experience on the TopTal interview and how you can prepare to pass it.

Read more

Google Code Jam 2016 Qualification Round: Passed

Google Code Jam is an algorithmic competition held each year by Google. The participation does not cost anything so I decided to test myself and have some practice. In this post I will talk about my experience and my results.

Read more

Loading DEX code over the network

Today we are going to see how code can be downloaded and executed over the network. This technique is useful if you want to update parts of an app without rolling out a complete update. In the code sample, we will fetch two dex files, load them dynamically, and then execute their code. Along the way we will explain how class loading works under the hood.

Read more

Three tools to stay in the zone

So precious are those moments when we, software developers, find ourselves in the flow; yet exiting that state is way too easy. Today I will describe three tools you can use to stay in the zone, to boost your productivity and accomplish more.

Read more

Hidden activities are not destroyed under memory pressure

Many developers after reading the official documentation believe that the system will reap the hidden activities of a task when running out of memory. In this post we will see this is not the case and how to solve the problem.

Read more

Retrofit 2: Code walkthrough

Retrofit is an open source library by Square that turns annotated java interfaces into REST clients. The library is currently in its second beta and changed quite a bit from its first version to better support the Ok stack. In this post we will go through its code, explaining its main techniques and inner workings. This post assumes some knowledge of the library as a user of it.

Read more

Git: Getting back an amended commit

Today we are going to see how to recover a commit that was accidentally amended.

Read more

Getting annotation value of an enum constant

In this post we will see how to extract the annotation value, (i.e. "choc" in @SerializedName("choc")) given an annotated enum constant. This technique is useful when we generate strings for unit tests in the context of Json deserialization. Furthermore, we will discuss some features of enums and annotations, and their connections with the reflection API.

Read more

Git: Committed on master instead of forking a branch

Sometimes we start working on a feature but mistakenly commit on the master branch. We realize the mistake too late and would like to "move" this commit or commits to a new feature branch. In this post I explain the fastest way to do this, if the commits have not been pushed to upstream yet.

Read more

ADB over wifi

The adb command is well known to Android developers, it provides utility commands such as shelling into a device, manipulating basic services like the activity manager, and pushing or pulling files from a device. What is not widely known is that you don't actually need an usb cable to talk to your device.

Read more

The retained fragment trick

The first tough problem a new Android developer faces is how to manage work in the background. Spawning a new Thread is easy, but once UI objects need to be notified with the result, the situation becomes tricky: the UI objects might have been replaced by the system because of a configuration change. In this post we explore how to bind and rebind to the new UI objects with a retained Fragment.

Read more

A library that draws transparent text in a TextView

Today we will make TextView render its text as transparent so that we can see underneath the TextView, for example the activity background. This technique uses the Porter's and Duff's transfer modes. A ready-to-use library along with its source code can be found here.

Read more

The basics of bit manipulation

Talking with fellow developers, I realized that many feel confused when it comes down to bit manipulation. It is indeed something not used on a day-to-day basis, but nevertheless the Android framework relies on it heavily in for memory optimizations: when a boolean can do, a bit can do too. Examples are View and Window flags. This post sets out to demystify the basics of bit manipulation: afterwards it will feel no more difficult than using arrays.

Read more

Espresso: Click on last item in AdapterView

In Espresso is quite easy to tap on the first element of an AdapterView, such as a ListView. This can be easily done calling DataIteraction.atPosition(0). Clicking on the last item though, is much more complicated. The last position is unknown to Espresso and extracting it stringing together a findViewById() and AdapterView.getCount() seems to defeat the purpose of using Espresso altogether.

Read more