immuni-app / immuni-app-android

Official repository for the Android version of the immuni application
GNU Affero General Public License v3.0
860 stars 145 forks source link

[FEAT] Alternate constructor to provide a default layout for Fragments #49

Closed nicopasso closed 2 years ago

nicopasso commented 4 years ago

Code conciseness Using androidx.Fragment, it's possible to clean up a bit each Fragment class by removing the onCreateView method with the layout inflation in favor of the alternate Fragment constructor that allows providing the default layout.

Androidx Fragment releases page

Screenshot 2020-05-26 11 24 35

Example Instead of writing

class MyFragment: Fragment() {

// ...

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.my_fragment, container, false)
    }
}

it's now possible to simplify it with:

class MyFragment: Fragment(R.layout.my_fragment) {
    // onCreateView no longer needed
}
spectrumIG commented 4 years ago

@nicopasso Are you sure they are not using it already? I thought I saw that in a Fragment base class of some sort...

nicopasso commented 4 years ago

@spectrumIG I've checked most of the Fragments in the app and all have onCreateView. The layout in the constructor is used only for DialogFragments that extend BaseStateDialogFragment

spectrumIG commented 4 years ago

Ah ok...yes, correct. I get what you mean , now.

Il mar 26 mag 2020, 12:54 Niccolò Passolunghi notifications@github.com ha scritto:

@spectrumIG https://github.com/spectrumIG I've checked most of the Fragments in the app and all have onCreateView. The layout in the constructor is used only for DialogFragments that extend BaseStateDialogFragment

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/immuni-app/immuni-app-android/issues/49#issuecomment-633953687, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHXDJKBA2J3VV5KFAGJXULRTONXRANCNFSM4NKEMCRQ .

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.