Guest User

Untitled

a guest
Aug 25th, 2019
66
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * High Order Functions
  3. * that execute function only in debug build variant
  4. */
  5. fun debugMode(function: () -> Unit) {
  6. if (BuildConfig.DEBUG) {
  7. function()
  8. }
  9. }
  10.  
  11. /**
  12. * How to use the code above
  13. */
  14. class MyActivity : Activity() {
  15. override fun onCreate(savedInstanceState: Bundle?) {
  16. super.onCreate(savedInstanceState)
  17. setContentView(R.layout.activity_main)
  18.  
  19. debugMode {
  20. addInterceptor(loggingInterceptor)
  21. }
  22. }
  23. }
RAW Paste Data