Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.13 KB | None | 0 0
  1. ...
  2. import kotlinx.android.synthetic.main.activity_main.*
  3. import kotlinx.android.synthetic.main.app_bar_main.*
  4. import kotlinx.android.synthetic.main.nav_header_main.*
  5.  
  6. class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
  7.  
  8.     override fun onCreate(savedInstanceState: Bundle?) {
  9.  
  10.         super.onCreate(savedInstanceState)
  11.  
  12.         val activityIntent: Intent
  13.         // go straight to main if a token is stored
  14.         if (!intent.hasExtra("email")) {
  15.             activityIntent = Intent(this, LoginActivity::class.java)
  16.             startActivity(activityIntent)
  17.             finish()
  18.         } else {
  19.             setContentView(R.layout.activity_main)
  20.             setSupportActionBar(toolbar)
  21.             val toggle = ActionBarDrawerToggle(
  22.                     this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
  23.             drawer_layout.addDrawerListener(toggle)
  24.             toggle.syncState()
  25.  
  26.             nav_view.setNavigationItemSelectedListener(this)
  27.             email.text = intent.getStringExtra("email")
  28.         }
  29.  
  30.     }
  31.  
  32. ....
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement