Android development can be (and usually is) much easier and satisfying with Kotlin, compared to Java. But it’s also quite different. Lots of things, like predefined nullability (or lack of it), no static as we know it, extension and top-level functions are there to be used in our favor. No wonder that it may be confusing what approach to choose, especially when the same thing can be done in different ways.
Today I’m gonna present you a better way of initializing and using SharedPreferences in your Kotlin app. No more repeating code with initialization in every place you want to get a preference, no more long lines to get or set a pref. How to accomplish this? Use object with lateinit and custom getters & setters.
Continue reading [Tutorial] How to use SharedPreferences in Kotlin
Since the introduction of AppBar in 2015, Android developers have spent lots of time styling and modifying it, making beautiful and unique apps. The ways of modifying Toolbar and flexible area beneath it are quite impressive. Yet, still the entry threshold is quite high for those who want to make their first steps in Material design world.
Partly, this is because of an incomplete documentation and the lack of diverse examples. I, myself struggled to make the layout I wanted and as easy as it sounds – to make it scroll the way I want to. This was the moment I decided to write this blog post, so it helps others 🙂
Maybe you want to scroll a Toolbar, so it hides completely and the only thing visible is the text? Or expand and collapse an image below the Toolbar? Or, doesn’t matter if the user is on the bottom of the layout, – you want to show him a Toolbar immediately on a scroll up action (there is a description of various scrolling techniques here). All of this is possible and easy to do with scroll flags!
Continue reading AppBarLayout scroll behavior with layout_scrollFlags
Some time ago I got interested in reactive programming and RxJava in particular. It’s gaining more popular in Android world and I often see RxJava as an obligatory skill for a Senior or Mid Android Developer position, that’s why learning it can be of a great benefit if you’re seeking a job 😉 But even if not, it can simplify your app development, especially if you have lots of UI fields which you fill in with some changing data or if you want to have an interactive search, or while using Retrofit for you HTTP requests. There are even smaller libs for a particular task, like RxWear, RxNotifications or RxAndroidBle (find a full list of such libs here). Choosing the right one will depend on your needs 😉
And so today I just want to share a few resources which I found very useful while learning how RxJava and RxAndroid libraries work (and what are they at all :). I have basically reviewed what’s available on ReactiveX Tutorials list (which is huge!) and listed the most intuitive and easy to get below, as well as a few articles and tutorials I found on the Internet myself.
A separate and an absolutely must position is a RxJava for Android App Development free e-book. It’s very short (only 41 pages!), and it’s a piece of cake to read, believe me, because I read it before any other docs or tutorials, and it explained the most important principles just fine 🙂
Continue reading Best resources to learn RxJava
It’s been a long time since I talked about my app’s release, but finally this day came! Today, I want to present you Look Counter – a simple app for counting how many times a day you have turned on and unlocked your phone (or tablet). It counts this in background and displays the latest numbers on the main view. You, as a user, can delete this data at any moment of time (Clear all Data option, with a quick Undo if you change your mind).
I’ve put an About view, if somebody is confused with the minimalist design and doesn’t follow what those numbers in circles mean, or maybe, wants to contact me right away, and say that counting doesn’t work for him at all! 😛
Anyway, the source code is on GitHub, so you can check what’s inside and grab tasty pieces, as well as point me at my mistakes 😉
Continue reading Look Counter app and more!