I’m starting to like MVVM more and more. Though I don’t regret using MVP (we’re rocking the architecture), it’s impossible to not appreciate the simplicity of the things that come with MVVM. Today I discovered MediatorLiveData, where I’ve used it is for validating data, but the use-cases are many! This is the code block:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
val isPersonValid = MediatorLiveData<Boolean>() val socialSecurityNumber = MutableLiveData<String>() val name = MutableLiveData<String>() init { isPersonValid.addSource(socialSecurityNumber) { isPersonValid() } isPersonValid.addSource(name) { isPersonValid() } } fun isPersonValid(): Boolean { val isSsnValid = socialSecurityNumber.value?.length ?: 0 == 9 val isNameValid = name.value.length?.isNotEmpty() == true return isSsnValid && isNameValid } |
[…]
By: Adrian Coman Category: Uncategorized
Working closer with MVVM, I got to the point where I got to use Transformations.
1 2 3 4 5 |
val phoneNumber = MutableLiveData<string>() val isPhoneNumberValid: LiveData = Transformations.map(phoneNumber) { phone -> phone.isPhoneNumberValid() } </string> |
What this basically does is: Whenever the phoneNumber variable changed, the function from the Transformation.map is triggered and isPhoneNumberValid changes. Basically if isPhoneNumberValid is observed (and only if it’s observed), it will change to true or false based on […]
By: Adrian Coman Category: Uncategorized
Some time ago we got to the conclusion that we should migrate from our MVP architecture to a MVVM one. There were a lot of things to learn and discover. Expect that the following bytes will focus more on this. One of the problems that I faced was that sometimes I would like the View […]
By: Adrian Coman Category: Uncategorized
Some time ago, a tweet caught my attention in which someone said they created an Android app with no “Base” activity/fragment class. Looking at my apps, I thought that was impossible to do because of the duplicate code you would have. It would have been a nightmare even only for the analytics functions that I […]
By: Adrian Coman Category: Uncategorized
Working as a developer one of the things that helped me grow was the ability to discover what’s blocking me from achieving my goals and constantly assessing how to have a continuous stream of work. I’m a freelancer and I get paid by the hour, so an hour of waiting for someone to answer a […]
By: Adrian Coman Category: Uncategorized
Some time ago I had some free time and was looking over the codebase of one of the apps I’m working on and something caught my eye, the constructor looked something like:
1 2 3 4 5 |
class SomeScreen( val fromOnboarding: Boolean, val fromSignup: Boolean, val fromLogin: Boolean ) |
From this code, you would get the impression that you could have 8 possible states of the class, but that wasn’t the […]
By: Adrian Coman Category: Uncategorized
I recently started to use MotionLayout in a more extensive way in one of the apps I’m working on. One of the issues I faced was that once I released my finger from the view the snapping animation was too slow and I needed it to be way faster. GIF It’s not very intuitive, but […]
By: Adrian Coman Category: Uncategorized
Stii sa scrii was my first app that I build for Android. And we’ve finally launched it again! New design, new game mode, new questions. It’s basically an app that tests your Romanian grammar knowledge. It has only one pack available at the moment with 50 types of questions and 150 different questions. We already have a […]
By: Adrian Coman Category: Uncategorized
La fiecare loc de muncă am avut exemple negative. Persoana mediocră care a venit pentru bani și nu vrea să facă nimic în plus. Persoana care nu poate să fie responsabilă și aruncă în permanență vina. Genul de persoană pe care o ia gura pe dinainte. Dă o estimare de 10 ore la ceva ce […]
By: Adrian Coman Category: Uncategorized
Tehnologia avansează extrem de rapid! În absolut toate domeniile. Din păcate, în ultimele două luni am fost atât de ocupat cu nunțile, cu proiectele și cu nimicurile că nu am mai avut timp să mă mai documentez de noile apariții din domeniu. Probabil aș fi mers în derivă, dacă un coleg nu mi-ar fi trimis […]
By: Adrian Coman Category: Uncategorized