Júlio Cotta

1.5K posts

Júlio Cotta banner
Júlio Cotta

Júlio Cotta

@JulioCotta

Barcelona, Spain เข้าร่วม Nisan 2009
225 กำลังติดตาม186 ผู้ติดตาม
Júlio Cotta
Júlio Cotta@JulioCotta·
@marcinmoskala to forward events from within the Fragment to outside, you probably could have used FragmentManagerResult API with a DisposableEffect in Compose... that keeps the "android way" of doing things
English
0
0
1
27
Marcin Moskała
Marcin Moskała@marcinmoskala·
The simplest way to display Android fragment in Compose is using AndroidFragment, which looks amazing, but has two dirty secrets you must know before using it. 🤫
Marcin Moskała tweet media
English
2
11
48
2.6K
Júlio Cotta
Júlio Cotta@JulioCotta·
By the way, your ETA for tramvias to get to my station in Barcelona is never correct, can't you integrate property with @tmb
English
0
0
0
37
Júlio Cotta
Júlio Cotta@JulioCotta·
@googlemaps , why your ETA is always so optimistic? I am never able to get to places I want to go with at least 10 min delay...
English
2
0
0
48
Marcin Moskała
Marcin Moskała@marcinmoskala·
Android Activities support starting another activity for result. Compose Navigation… does not support that. There is a way to implement it, by saving value to savedStateHandle from previousBackStackEntry, then popping back, and reading it in currentBackStackEntry, but it is a bit of a hack, and I generally do not recommend it.
Marcin Moskała tweet media
English
6
8
105
12.1K
Alex Styl
Alex Styl@alexstyl·
I feel so defeated every time I use the Android emulator. You boot it up and try to use the soft keyboard but it doesn’t show for whatever reason. The checking online shows you how the way to bring it back has changed so I have no clue what is going on. Why do I need to deal with this man?
English
9
1
17
2.1K
Júlio Cotta
Júlio Cotta@JulioCotta·
@firefox can we have a gesture to switch tabs on mobile? Or some shortcut in the navbar?
English
0
0
0
9
Júlio Cotta
Júlio Cotta@JulioCotta·
@marcinmoskala If you have a search input, you may want to cancel previous calls to save network and to avoid concurrency issues
English
1
0
1
41
Marcin Moskała
Marcin Moskała@marcinmoskala·
@JulioCotta Nice catch with CancellationException, but in this case I believe it wouldn’t do any difference. Do you often need to cancel such calls? It gets cancelled when scope gets cancelled.
English
1
0
1
386
Marcin Moskała
Marcin Moskała@marcinmoskala·
Android devs, what do you think about my simple util to turn suspending calls into StateFlow with loading?
Marcin Moskała tweet media
English
10
6
104
8.1K
Júlio Cotta
Júlio Cotta@JulioCotta·
@marcinmoskala Also, you create a new Flow every time you call it, maybe you should make it an extension function in an existing Flow..
English
0
0
4
79
Júlio Cotta
Júlio Cotta@JulioCotta·
@marcinmoskala 1) Not rethrowing CancellationException? 2) Not possible to cancel the current job Apart from 1) and 2), it's fine, I guess
English
2
0
5
671
Júlio Cotta
Júlio Cotta@JulioCotta·
@Zhuinden Now repeat that for B, C, D and it's dependencies and you will come with an idea of something to handle that for you automatically doing a full circle on the DI topic.
English
1
0
0
57
Júlio Cotta
Júlio Cotta@JulioCotta·
@theapache64 Not to shit on your impl, but iny experience with interacting with Google Sheet using APIs, Google services are often down and sometimes we reached some API limits... So scalability may be a concern...
English
1
0
2
75
Júlio Cotta
Júlio Cotta@JulioCotta·
@Zhuinden @winklerino Why working ina low hanging fruit is a waist of time? That size argument is doing nothing? That may be because of a shadowing problem or you added and forgit to use. Warmings are not bad, we just need to know how to interpret and the help we get.
English
0
0
0
7
Gabor Varadi
Gabor Varadi@Zhuinden·
@JulioCotta @winklerino The problem is that it wastes time on "low hanging fruit" warnings, distracting from actual real problems. Same issue happens with Kotlin compiler warnings, like: - W: parameter `size` can be renamed to `_` Kotlin my guy, this is not a warning. This is just aimless nitpicking.
English
1
0
1
25
Gabor Varadi
Gabor Varadi@Zhuinden·
Sonar is such a scam, but some companies are forced to use it just to seem "more secure". And then you have to write all sorts of silly workarounds in your code, like public static final int ZERO = 0; because you can't just suppress a warning, nope you gotta "fix" the code. 😵
Gabor Varadi@Zhuinden

@PetarLjubic92 @ryanels Even when in an environment requiring security, it barely reports anything other than nonsense like "code smell: self-assignment" (if you call setX(getX());), or "code smell: using numerical constant in expression". I literally had to create public static final ZERO = 0; once 🤦

English
2
0
24
2.3K
Júlio Cotta
Júlio Cotta@JulioCotta·
@Zhuinden Define "better", by using the android framework communication APIs we get listeners that are bound to your screen lifecycle which can save resources. It can be less code to the vm listening, but that is conflating less code with better code.
English
1
0
1
73
Gabor Varadi
Gabor Varadi@Zhuinden·
@JulioCotta It's actually a significantly better idea than roundtripping through the Fragment to do it, which is how people would "normally" do it; Assuming they even know about the ability of creating a NavGraph-scoped ViewModel, instead of just making it app-global (e.g. Activity-scoped).
English
1
0
5
349
Gabor Varadi
Gabor Varadi@Zhuinden·
Today's forbidden Android dev knowledge that the /r/androiddev mods don't want you to know: how to inject a ViewModel into a ViewModel using Hilt? Solution: use HiltViewModelExtensions.withCreationCallback() This way, you can pass ParentViewModel to ChildViewModel. #androiddev
Gabor Varadi tweet media
English
4
7
109
6.3K
Júlio Cotta
Júlio Cotta@JulioCotta·
@Zhuinden @winklerino So your problems are not with sonar, saying bold statements like that makes no favours anyone.
English
1
0
2
83
Gabor Varadi
Gabor Varadi@Zhuinden·
@winklerino Not when you're working with the kind of people who are more equal than others, lol
English
1
0
0
244
Júlio Cotta
Júlio Cotta@JulioCotta·
@Spotify , an ad promised 2 months free if I filled a survey, but when I clicked in the ad, this is what I got, how about those free months for the bug report? 😁
Júlio Cotta tweet media
English
0
0
0
38
Júlio Cotta
Júlio Cotta@JulioCotta·
@Zhuinden @marcinmoskala Or you could use that info to trigger the loading event in the vm's constructor. Again, you are being too black or white when things are way more nuanced. You should know how to use the tools you have at hand, and for many occasions, storing the data in a bundle is the correct.
English
0
0
1
99
Gabor Varadi
Gabor Varadi@Zhuinden·
@JulioCotta @marcinmoskala Storing all UI state in a single MutableStateFlow (Orbit-MVI does this, and it's a major design flaw) is a 100% recipe for disaster. All you need is accidentally persisting an "isLoading", & you have infinite loading after process death. Or, save a full list from DB, and crash.
English
3
3
6
743
Marcin Moskała
Marcin Moskała@marcinmoskala·
One big discussion that we have in Android is between passing individual functions to composables that need to make action, or passing uiAction with a sealed class of possible actions. Using individual functions for actions is: 👉 Simple, as we need no extra classes. 👉 Safer, as each composable receives only what is needs. 😨 Can badly scale, as every new action might require passing it through many components, and every argument change might require changes in many signatures. On the other hand using uiAction: 👉 Scales better, as we do not need to pass all functions separately, and maintain their definitions. 👉 Aggregates all actions in one place. 😨 Adds a lot of new classes to our project. 😨 Reduces safety, as many composables receive functions that allow making actions they do not need. That problem can be mitigated by using sealed interfaces to define groups of actions, but that adds even more actions, what makes project harder to understand and reason about. 💡 It is often recommended to choose the first option when we expect simple screens, and the second one for complex, evolving screens. Which one do you prefer❓ Which one do you use❓ Neither of those two approaches deals well with screens that have a lot of state-dependent actions.
Marcin Moskała tweet media
English
10
12
71
5.6K
Júlio Cotta
Júlio Cotta@JulioCotta·
@Zhuinden @marcinmoskala It is no "unlikely" and there is no need of multiple flows, you are just trying to justify your choices man. You can totally have one parceble state class with all form fields, for instance, this is very common situation that we all as android devs should account for.
English
2
0
4
340
Gabor Varadi
Gabor Varadi@Zhuinden·
@JulioCotta @marcinmoskala It's unlikely you can just directly "bundle your state" in the first place. All of those properties (when using ViewModel) should have come from separate StateFlows each obtained from SavedStateHandle, and then combined together on changes to actually build the UiState instance.
English
1
1
6
859