by veskoiliev | Jan 18, 2017 | Android, Development
1. Observable creation and error handling
Consider the following example:
public Observable<Book> getFavoriteBook(User user) {
return Observable.just(user.getFavoriteBookId())
.flatMap(bookId -> bookService.getById(bookId))
.onErrorReturn(throwable -> DEFAULT_FAVORITE_BOOK);
}
Focus on the error handling part. In my experience in 95% of the cases the expectation behind the statement .onErrorReturn(...);
is to ensure that the method getFavoriteBook()
is “safe”, e.g. that an exception cannot be thrown from it at all, as if it was surrounded by a giant try-catch.
read more
by veskoiliev | Sep 7, 2016 | Android, Development
Note: This post is based on the widely used Retrofit2 networking library. Although the examples use a Gson
converter, the same concept can be used with most of the other supported ones as well.
Imagine you’re in a situation where your backend can return a JSON
response that’s dynamic in nature, a.k.a some parts of it don’t adhere to a specific pre-defined schema. Say you retrieve information about a webpage that you need to open in a WebView
. You need to support both GET
and POST
HTTP requests, so two valid responses are:
read more
by veskoiliev | Jul 28, 2016 | Android, Development
Unit tests
Here’s a few handy commands if you want to run only a specific unit test(s). Suppose we have the following unit tests in the project:

./gradlew test
– run unit tests for all variants
./gradlew testDebug
– run tests for Debug variant
./gradlew testDebug --tests="*.helpers.*"
– run all tests in the helpers
package
./gradlew testDebug --tests="*.HelperTest"
– run all tests in HelperTest.java
class
./gradlew testDebug --tests="*.getHelp"
– run only the getHelp
test method.
read more
by veskoiliev | Feb 21, 2016 | Android, Development
This post will list some of my favourite features of a Proxy tool that are used on a daily bases in my team. It’s about giving you the overview of how such a tool will help you be more efficient in your day-to-day development process. It won’t get into details of how to setup a proxy, how to use these features or which specific tool to use – this will be covered in a future post.
Let’s get to it!
read more
by veskoiliev | Nov 2, 2015 | Android, Development
What, when?
With the release of Android M (API 23) the Support library got a major update as well. One of the unsung heroes is a feature badly requested since Android’s early days – the ability to set dimensions in percentages. With the release of the Percent Support Library is’t now possible to set a View
to take exactly 30% of the screen, or to set it’s marginTop
to 10% for example.
read more
by veskoiliev | Oct 21, 2015 | Android, Development
As an Android developer you should certainly know what overdraw is and why it’s bad. If not – THIS episode of Android Performance Patterns got you covered, check it out.
Finding overdraw is super easy – you can do it right on your device:
read more