Skip to content

Instantly share code, notes, and snippets.

@manijshrestha

manijshrestha/MainActivity.kt Secret

Created Oct 14, 2018
Embed
What would you like to do?
Kotlin Multiproject MainActivity.kt
package com.manijshrestha.kotlinmplogging
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.manijshrestha.kotlinmplogging.analytics.ButtonClickEvent
import com.manijshrestha.kotlinmplogging.analytics.ViewEvent
class MainActivity : AppCompatActivity() {
private val analyticsManager = AndroidAnalyticsManager()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun onResume() {
super.onResume()
analyticsManager.report(ViewEvent("Main Page"))
}
fun onButtonClick(view: View) {
when (view.id) {
R.id.red_button -> analyticsManager.report(ButtonClickEvent("Red"))
R.id.green_button -> analyticsManager.report(ButtonClickEvent("Green"))
R.id.blue_button -> analyticsManager.report(ButtonClickEvent("Blue"))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment