AppBarLayout scroll behavior with layout_scrollFlags

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

Like and share:

Tutorial: How to use a Handler?

Hello,

Today I will show you how to benefit from Handlers in Android 🙂

First of all, Handlers aren’t some new concept, they were there long ago. How long? Well, from API level 1. Still, I always felt Android developers don’t use them enough, me included.

When I’ve discover the brilliance of Handlers, I was surprised how handy they are and how easy is to use them.

So, what does a Handler do? A few things, really.
Continue reading Tutorial: How to use a Handler?

Like and share:

Tutorial: Parse JSON with LoganSquare

Hi, guys!

Today I want to present you a new JSON-parsing library – LoganSquare, written by BlueLine Labs. It is told to be the fasted available and quite easy to use, so I couldn’t miss it 😉 Below you will find an example Android project, which serializes and parses some objects.

Also, I have run Logan’s Benchmark project myself and indeed, the results are good. Not as good, as on their GitHub’s page, but still. Just to make everything clear, I have used Nexus 5 running Android 6.0.1 (ART).

Logan Square benchmark results

As you can see, LoganSquare wins in every category. Lets check how we can use it in our project, shall we?
Continue reading Tutorial: Parse JSON with LoganSquare

Like and share:

Tutorial: Add SQLCipher to your Android app

Hi guys!

Today’s tutorial will be about SQLCipher and its integration in Android (with the means of Android Studio). Just to give some introduction, SQLCipher is used for a full database encryption. What full means is that the DB file is entirely encrypted, not only separate rows or tables. Zetetic, the company behind SQLCipher, provides Community and Commercial edition. You can use the former for commercial projects, though, just have to provide license doc in your app. Also, SQLCipher is not for Android only, it can be used on various platforms.

Regarding security features, SQLCipher uses 256-bit AES in CBC mode by default, with 1kB page size, and it derives the key data using PBKDF2 function. The difference in API that you instantly notice is the passphrase argument in getReadableDatabase() and getWritableDatabase() methods. Now, this passphrase should never be stored in the application, otherwise the whole point of encryption is wasted. One thing to keep in mind, is that the passphrase is not a key! Yes, the DB is encrypted using the key, but it is generated based on the passphrase (~ password) and also can be re-set using PRAGMA rekey command.
Continue reading Tutorial: Add SQLCipher to your Android app

Like and share: