Created
July 6, 2020 08:08
-
-
Save Div-e-Sepid/58ecf2f10e1832629d8044b5fda8a692 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class BaseActivity( | |
@LayoutRes private val layoutRes: Int? = null | |
): AppCompatActivity(), InterfaceOne, InterfaceTwo { | |
@Inject // now all my children have to use dagger, YAY! | |
lateinit var analytics: Analytics | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
if (layoutRes != null) { | |
setContentView(layoutRes) | |
if (foundToolbarWithSomeSpecificId) { | |
init(toolbar) | |
} | |
} | |
// hopefully it's injected by now! | |
analytics.sendAnalytics(this, "onCreate") | |
} | |
override fun onStart() { | |
super.onStart() | |
analytics.sendAnalytics(this, "onStart") | |
} | |
override fun methodFromInterfaceOne() { | |
if (onlyHalfOfTheTimeBasedOnGodKnowsWhat) { | |
// do something that should have been in the child class to begin with | |
} else { | |
// do something that can be removed right now! | |
} | |
} | |
override fun methodFromInterfaceTwo() { | |
// I wished it wasn't accessible by child classes ;( | |
} | |
open fun onWeirdCallbackOne() { | |
// some weird logic that is irrelevant 99% of the time | |
} | |
abstract fun getSomeWeirdTypeNoOneKnowsWhy(): Int | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment