Closed veyndan closed 4 years ago
Why do we use activity?.intent?
in app/src/main/java/com/github/pockethub/android/ui/gist/GistFileFragment.kt
but activity.intent
in app/src/main/java/com/github/pockethub/android/ui/commit/CommitCompareListFragment.kt
?
In the original app/src/main/java/com/github/pockethub/android/ui/gist/GistFileFragment.kt
we don't assert that the activity should be non-nullable, so I have kept the logic the same by using activity?
. In the original app/src/main/java/com/github/pockethub/android/ui/commit/CommitCompareListFragment.kt
we assert that activity
should never be null, so in the later lines activity
is never null. I haven't changed the nullability contract in this PR.
Alright, that makes sense. I'll check this in a bit.
Inline
Intent.get___Extra(String)
methods as:BaseFragment
andBaseActivity
to continue using this approach, reducing code maintainability.BaseFragment
always uses the null permissiblegetActivity()
when the logical flow may require the use of the non-null assertiverequireActivity()
.getIntent().get___Extra(String)
is a pretty standard practice, and makes it known that theget___Extra(String)
is being obtained by the intent that the started the activity.BaseActivity#getIntExtra(name: String)
returns-1
if the extraname
is absent. By covering this up in a layer of abstraction is a potential source of difficult to find bugs.