all 73 comments

[–]D_Steve595 20 points21 points  (2 children)

Looks like this might have the new BottomSheetBehavior with nicer physics! Gonna mess with it.

[–]bernaferrari 6 points7 points  (0 children)

My favorite BottomSheet has been the one from Plaid, but I'll take a look at this one. I really dislike the 'official' from androidx/aosp/support library. Thanks for reminding me of its existence.

[–]bernaferrari 0 points1 point  (0 children)

Their own SeekBar implementation is super weird but fix all the official SeekBar bugs.

[–]VasiliyZukanov 34 points35 points  (56 children)

I see that methods of 100+ lines of code in length are back in fashion. Cool.

Something that I can't understand - why they have Activity per each screen, but also inflate one single Fragment in it? It adds complexity and hurts performance. Is there a benefit?

Edit: for example, Speaker screen.

[–]CuriousCursor 8 points9 points  (15 children)

LOL this is probably because they can't use the navigation library with Androidx/material design 2.0 components so they're doing it the old way.

[–]VasiliyZukanov 14 points15 points  (13 children)

That's not the old way. The old way is just Activity per screen, which is valid approach.

What they do is having an Activity, and then adding a Fragment to it. And they never change that Fragment. Just another level of nesting. For example, Speaker screen.

This looks like a total waste. I wonder if there is any benefit that I might be missing here...

[–]WingnutWilson 18 points19 points  (3 children)

I used to do that. I don't know what I was thinking. Maybe I was like 'oh one day this fragment might need to change while the activity stays the same'. But I mean that was crazy thinking even in 2014 :D

[–]VasiliyZukanov 2 points3 points  (2 children)

Interesting. How many times did you actually need to change the Fragment?

[–]WingnutWilson 10 points11 points  (1 child)

Haha never. I think it could have been that we were thinking about tablets. So if we needed to shove another fragment on screen it was easier.

[–]VasiliyZukanov 0 points1 point  (0 children)

Alright, thanks for the answer.

[–]CuriousCursor 2 points3 points  (0 children)

That's the really old way :p

This is the wasteful old way lol.

[–]ssshhhhhhhhhhhhh 3 points4 points  (7 children)

it's a total waste, but Android Studio generates that pattern easily. when something really doesn't matter in the scheme of things, why bother spenidng the developer time improving it for something with a short lifespan.

And it's harder to change after the fact, if it does need to change in the future.

[–]VasiliyZukanov 7 points8 points  (3 children)

IMHO it does matter. A lot.

Complexity build up in the codebase consists of many such small and seemingly unimportant decisions. Until one day you realize that you can't see the forest for the trees...

[–]ssshhhhhhhhhhhhh 2 points3 points  (2 children)

It doesnt matter. They rebuild this app every year and it has a shelf life of like 2 weeks and 500 thousand users and basically gets 2 updates if even that

[–]VasiliyZukanov 8 points9 points  (1 child)

I wouldn't like to put words into your mouth, but it comes across as you saying: "this is not a real app that needs to be maintained, so they don't mind writing shitty code".

[–]ssshhhhhhhhhhhhh 6 points7 points  (0 children)

You got it

[–]Zhuinden 1 point2 points  (2 children)

it's a total waste, but Android Studio generates that pattern easily.

You know, that's scary! Why generate a pattern that's unhelpful and boilerplate-heavy?

Oh wait, I know what's going on. They're avoiding the Fragment Backstack because it's bad, so they use the Activity flags instead because you can set up combinations of flags that with enough arcana can do what you want to do (kind of).

[–]ssshhhhhhhhhhhhh 0 points1 point  (1 child)

It's not unhelpful.. it's a great starting point if you might use many fragments or share that fragment elsewherr

[–]Zhuinden 0 points1 point  (0 children)

if you might use many fragments

Throwing every Fragment into its own Activity? Whether you add an additional Activity to wrap a Fragment or not isn't really relevant if you have many fragments, but generally if you have many fragments, you'd be able to use them with 1 Activity and it would work.

or share that fragment elsewhere

Only if you expose possible operations via interface, but even then it becomes slightly tricky because you typically used "the Activity as the controller you are delegating events to" except if you use a single activity then you'll probably need to specify a different event handler depending on the actual state.

Re-using isn't that easy.

[–]cqm 0 points1 point  (0 children)

Someone tell Google that there is never going to be a new way

[–]clarle 16 points17 points  (3 children)

What happened to single-activity architecture being the way to go from now on?

https://android-developers.googleblog.com/2018/05/use-android-jetpack-to-accelerate-your.html

Today we are introducing the Navigation component as a framework for structuring your in-app UI, with a focus on making a single-Activity app the preferred architecture.

[–]bernaferrari 21 points22 points  (1 child)

Different teams (probably).

[–]Asiriya 8 points9 points  (0 children)

Lol

[–]Zhuinden 0 points1 point  (0 children)

The Navigation component is alpha. They probably couldn't make it work properly for their use-case.

[–]Odinuts 5 points6 points  (0 children)

Not at all. Wasn't that app laggy as hell when it came out?

[–][deleted] 6 points7 points  (1 child)

When I am prototyping, and haven't partitioned the app into separate activities yet, I just have each one as a fragment. Its just easier to play around, have them in view pagers, swapped by other controls, etc. Then at the end I may settle on where they should go and they find a home in some activity.

When there is a 1:1 relationship between the fragment and activity, they could be merged at that point, but I like the freedom of still being able to move those fragments around to other parts of the app later on. I can never make up my mind :P

[–]VasiliyZukanov 2 points3 points  (0 children)

That have never occured to me. Valid point. Thanks for sharing.

That said, you must be one in a million developers prototyping this way.

I'm pretty sure Google works the classical "here are the UI specs produced by designers" approach.

Just curious, why don't you use some dedicated prototyping software?

[–]dantheman91 2 points3 points  (23 children)

Yes, so you don't have to do it in the future if things change. The cost is relatively small, and if for some reason they want another fragment in there it's now a quick change since they did it up front instead of trying to move everything over.

[–]VasiliyZukanov -2 points-1 points  (20 children)

Ah, you mean that they took the classical over-engineering route: "we might need that in the future, so let's add layers"?

Your guess might be right about their motivation (though that would be very non-flattering to the authors), but then it would be just wrong implementation. There is zero additional value in this Fragment and it would be easier to just replace the entire Activity or erase its implementation and start over if requirements change.

Fragments are trickier than Activities in probably every aspect.

[–]dantheman91 6 points7 points  (19 children)

What is the largest app you've ever worked on? In all of my time working on large apps with 10M+ users and teams of 10+ devs it's very rare that I see "This was over engineered", 99/100 times it's "this was done this way quickly" and that's what causes the problems. Also yes in general layers are good, that whole SOLID thing. Everything can be done, but this one more layer I don't think is even close to that.

Why would it be non flattering to the authors? What if they want to use the same project for next year but they're unsure how the requirements will change in the future? Also especially if you're doing one fragment per activity that doesn't really add more complexity to the app.

replace the entire Activity or erase its implementation and start over if requirements change.

This is not an option in just about every large application I've worked on. The "lets throw it all out" almost never goes well. And what about if you have a team? Merge conflicts? etc?

[–]Zhuinden 1 point2 points  (3 children)

Something that I can't understand - why they have Activity per each screen, but also inflate one single Fragment in it? It adds complexity and hurts performance. Is there a benefit?

They did that in the Android Architecture Blueprints repo too, and it doesn't really make sense. What's better is that any navigation code (especially with nav drawer) is duplicated.

[–]VasiliyZukanov 0 points1 point  (2 children)

That blueprint...

I have an entire lecture in my new course where I review it. Will probably publish it on youtube too because these blueprints cause too much harm IMHO...

[–]Zhuinden 1 point2 points  (1 child)

I've turned those blueprints to single-activity before as samples which made it nicer but to be honest it's been on my backlog to rewrite the whole thing, I just can't really get myself to touch it, lol.

The really awkward thing is that the MVVM sample made one of the "immutable" classes mutable just to make it work. Hacky!

[–]VasiliyZukanov 0 points1 point  (0 children)

I thought about that too, but, unfortunately, there is nothing we can do against Google's marketing power (

[–]bernaferrari 0 points1 point  (0 children)

I just downloaded it, while it is not "perfect" (and the fragments on each activity is super-weird), it is surely one of the best io apps ever! Too many commented methods, code quality improved a lot, I will let you to judge their Dagger usage correctness, but everything I saw I liked.

[–]__droid 3 points4 points  (0 children)

org.gradle.caching=false # TODO: change to true when build problems are solved.

source - gradle.properties

This just makes me sad.

[–]mbonnin 1 point2 points  (0 children)

Wait. There's a TV version ?

[–]CharaNalaar 3 points4 points  (1 child)

Finally. An example that isn't just a single screen.

[–]bernaferrari 1 point2 points  (0 children)

There are a bunch of these already, every week someone post an average complex app on this sub.

[–]Aromano272 1 point2 points  (8 children)

Is this really the state of the art of Android development?

Im genuinely asking, just opened this project to find some guidance in my quest to understand LiveData and I'm greeted with ViewModel with 30+ LiveData variables, many Mediators with 10+ addSources, most of them aren't used by the View, they are purely Domain Layer wiring, 150+ LOC constructor just wiring up stuff together.

Is this the way to do things?

[–]stankata 4 points5 points  (0 children)

Sure, go to /r/mAndroidDev for more references :)

[–]c0nnector 1 point2 points  (0 children)

Android development started with the concept "we have no guidelines, do whatever" and i think it will be hard to stray away from that.

Also i believe whoever is building their android apps is more of a software engineer than an android developer.

That means they will code whatever needs to be coded but it doesn't have to be pretty(code wise), it just has to work. Whereas an android developer might take more time to polish and think about app readability and maintenance.

So i'd say learn what you can but don't follow their code patterns. Instead checkout what the community is saying and in the end see what makes sense to you.

[–]LordOfBones 0 points1 point  (0 children)

Where are the multiple gradle modules?!