Image for post
Image for post

Since I started using Jetpack Compose I fell in love with it, there are so much new ways to create interactive UI’s with just a few lines of code, no need of boilerplate, NullPointers when binding views, and anything like we use to deal before.

After spending some time understanding the whole concept of compose to create declarative UI’s I started questioning myself how to handle navigation with it, then I just deg into reading the example apps and understanding how it's done, and in this post, I gonna show you how to use navigation before an official approach comes up. …


Image for post
Image for post
Image from : Linux: Changing the World One Line of Code at a Time

Have you ever dreamed about not needing to handle RecyclerView adapters logic to show a simple UI list without all the boilerplate code an adapter needs?

Keep reading, in this article we are gonna discover the power of Jetpack Compose to make a simple user list in just one line of code.

Since the alpha of Jetpack Compose came out few weeks ago I started learning about it and I fell in love with the ease of writing awesome UI components in no time.


Image for post
Image for post

Since ConcatAdapter has been announced at recyclerview:1.2.0-alpha04 now we can merge different types of our UI into one recyclerview.

This gives us the advantage to build up an entire view writing different components and then wrap them up in sequence, which makes it easier to build up complex UI’s with recyclerview.

You can read more about ConcatAdapter at the official announcement post from Florina Muntenescu here

How it works

Basically, we write individual adapters for our different views and then merge them with ConcatAdapter, the result is a sequence of views inside one recyclerview

val firstAdapter: FirstAdapter = …
val secondAdapter: SecondAdapter = …
val thirdAdapter: ThirdAdapter = …val concatAdapter = ConcatAdapter(firstAdapter, secondAdapter,
thirdAdapter)recyclerView.adapter …


Image for post
Image for post
Data from our DAO to beautiful data to our UI

If you are working with architecture like MVVM, this will for sure be a gamechanger for you, Transformations are really strong at converting data to one type to another, but, why we use it?

Why Transformations?

Basically Transformations are used to do one thing, and this is transforming data from our DAO to data that our UI needs to display the information, I know, this is not enough to understand the concept, so here is an example.

Imagine we have an E-commerce app with two fragments, a Parent fragment and a ChildFragment, here, the ChildFragment is a viewpager with two tabs, and each tab has its own list of products, so, we need to communicate each selected product from here to the ParentFragment, but the parent fragment needs also to show this product list and also edit/delete the products. …


Image for post
Image for post

A little while ago I was talking about how to do asynchronous calls with Firebase and Coroutines, you can check how to do one time operations to request data using Firestore here

I would recommend taking a look at that previous post to get in the context of what we are going to do, we are going to use one of the coolest features from Firebase, that is Realtime Data flow to our user screen.

If you were using Firebase before, you have worked with its realtime functionality through callbacks

For example, from the documentation we can listen to a reference and update our UI whenever this reference generates/updates/delete a new value, so we deliver that value to the user at the time the user is seeing the screen. …


Image for post
Image for post

After moving from MVP to MVVM, there was a lot of going on in my head on how to structure my code in a way that is understandable and scalable

Architecture is the first thing I think about when starting a new project and is this the main entry point that will define quality, testability, and maintainability of the project through its lifetime

I always wanted to work with asynchronous APIs in a synchronous way, because is more flexible and lets our code cleaner than nesting callbacks.

I was working with LiveData in my whole app, doing all my app reactive is not what I really wanted, I had to play with the LiveData states onActive() and onInactive() to structure some jobs, but this is not what I really wanted since it added lots of boilerplate code and also the code was not really clean. …


Image for post
Image for post

Recently Firebase has announced a new product called Extensions, extensions are pre-packaged solutions that save lots of time in development. We can see this as firebase functions packaged as plugins to install into our project.

This product offers bunch of different extensions to work within our project, and they offer the installation of this extensions within the firebase console, and also CLI, if we are just starting out, we can install extensions just by going to our console, but if we want to do it a little more programmatically, we can also use the Firebase CLI to deploy them.


Image for post
Image for post

When it comes to error handling in any asynchronous API, we always need to return an error message from the response to see what is happening and to let a friendly user message if any error occurs.

Usually when we tend to ignore the error responses from the server because we trust that the server will return what we are requesting, but this assumption is a really big mistake since we only test the feature in our own devices and we are not concern about connectivity problems or any other error our end-user could have.

This problem can be seen in the code like the following. …


Image for post
Image for post

I’m sure that if you have used Firebase realtime database or even Firebase Firestore you wanted to store data generated by the current user using your app inside one of those databases.

About

Gastón Saillén

Android & Firebase GDE

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store