Last active
August 17, 2019 18:14
-
-
Save yogacp/f8f9fd24c2d017a49c662888324a9f16 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
/** | |
* High Order Functions | |
* that execute function only in debug build variant | |
*/ | |
fun debugMode(function: () -> Unit) { | |
if (BuildConfig.DEBUG) { | |
function() | |
} | |
} | |
/** | |
* How to use the code above | |
*/ | |
class MyActivity : Activity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
debugMode { | |
addInterceptor(loggingInterceptor) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment