https://kotlinlang.org logo
#feed
Title
# feed
p

Paul

03/19/2021, 11:44 AM
Hello everyone. I've just open-sourced a project that I've been working on for quite some time called Gamedge. The aim is to showcase the latest trends in Android development by utilizing the best practices, libraries, and tools to develop a fully-fledged Android application. It utilizes: • MVI/MVVM Architecture • Coroutines and Flow (including StateFlow) • Dagger Hilt • Jetpack DataStore (both preferences and protocol buffer versions) • MotionLayout • AssertJ, MockK, Turbine for unit and instrumentation tests • and lots of other libraries. If anyone want to take a look, here's a link to the GitHub.
👍🏽 1
😍 4
K 26
👍🏼 1
👍 17
t

therealbluepandabear

03/19/2021, 7:56 PM
Put it on the Google Play Store? I will download it.
😄 1
m

Michal Harakal

03/19/2021, 8:14 PM
@Paul your focus on tests is impressive, did you measured test coverage ?
p

Paul

03/19/2021, 8:23 PM
@Michal Harakal I did not measure it actually. My goal was to show how an app can be architected with testability in mind. The project has by no means 100% coverage, but more than enough examples that pave the way for more test coverage in the future.
👍 2
s

solidogen

03/23/2021, 3:31 PM
@Paul great project, really inspires to try out new things I have a question about BaseFragment view destroy check:
Copy code
final override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Prevent the view from recreation until onDestroy is called
        return if(isViewCreated) {
            viewBinding.root
        } else {
            super.onCreateView(inflater, container, savedInstanceState)
        }
    }
Could you explain why this is wanted? Is there ever a possibility that fragment’s view will be created twice, not being destroyed beforehand?
👍 1
p

Paul

03/23/2021, 4:13 PM
@solidogen Sure. The reason why this is needed is because most of the screens in the application are heavy, meaning they contains lots of views and whatnot. This means that due to screens' complexity, which causes view recreation to be an expensive process that happens every time a user navigates from screen to screen (as well as other issues like state restoration in some views), I find it much more easier to just retain the Fragment's view until Fragment's
onDestroy
method is called. The Fragment's view gets cleared inside
onDestroy
method, which means that up until that method is called, the Fragment always returns a cached-in view inside
onCreateView
. Therefore, it's not possible that Fragment's view will be created twice. Hope it helps.
👍 1
s

solidogen

03/23/2021, 4:22 PM
thanks a lot, I see. I’m using google’s multiple backstack hack for bottom navigation and immediately after switching tab view gets destroyed, then is restored later from saved state, this is why I experienced different behaviour
👍 1
t

Trần Hữu Phúc

04/19/2021, 5:02 AM
Perfect.
🙂 1
t

therealbluepandabear

04/19/2021, 10:17 AM
So many features in Android, gets a little overwhelming lol 🙂
p

Paul

04/19/2021, 2:19 PM
@therealbluepandabear It sure does.
3 Views