SHARE
TWEET

Untitled

a guest Aug 25th, 2019 65 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top