February 25, 2016

Binary search tricks

Probably array is the most popular collection of data. Everyone have used, is using and will use it. If array is sorted, this means you can simplify your life while processing array. I want to share some simple, but effective trick with binary search algorithm.

Imagine you have sequence of N numbers which splits space for N + 1 segments. Two of them on the edges are infinite. For instance, this is fuzzy thermometer.


February 08, 2016

February 06, 2016

Android Dev Tips: How to replace Enum by int or String efficiently?

There's a good topic on developer.android.com about how to manage app's memory. I want to touch specific paragraph about enums:
Enums often require more than twice as much memory as static constants. You should strictly avoid using enums on Android.
Lot of developers don't want to follow this rule, saying this is inconvenient, hard to navigate through code, hard to debug, blah-blah-blah... 

Android guys want to help developers with this. They provided android.support.annotation package with lot of powerful annotations for Android Studio and Lint. I want to explain more about IntDef and StringDef. There two classes may help to replace enums efficiently for both: performance and convenience.

February 05, 2016

Android Dev Tips - How to get static Application Context from anywhere?

Everyone is facing with the problem of accessing Context instance from methods, which aren't logically linked with Activity or Service.

It may be needed for accessing independent resources, like strings or files from assets folder. Sometimes it may be inconvenient to initialize and keep additional variable with the static context.

There're lot of questions on StackOverflow about this. Today I want to share my experience of handling such kind of problems.


February 04, 2016

Android Dashboards - February 1st

Do you still care how to choose min SDK version? Last two years Google guys spent lot of efforts in order to make Android more fluent for vendors. The most popular devices now regularly receive firmware updates automatically. From the developer's point of view it's a fantastic! We don't need to care about dino-phones anymore.

You can see it by yourself from latest statistics from Google. Devices with API 19 and higher now cover more than 70% of market! This means we can use lot of modern features of Android KitKat, Lollipop and Marshmallow without tons of libraries and crutches.

You can find more details here.