@@ -7,28 +7,28 @@ import android.content.Intent
77import android.os.Bundle
88import android.text.method.ScrollingMovementMethod
99import android.view.View
10- import android.widget.TextView
1110import androidx.appcompat.app.AppCompatActivity
12- import androidx.appcompat.widget.AppCompatTextView
13- import com.google.android.material.button.MaterialButton
1411import com.google.android.material.snackbar.Snackbar
12+ import com.haroldadmin.whatthestack.databinding.ActivityWhatTheStackBinding
1513import dev.chrisbanes.insetter.Insetter
1614import dev.chrisbanes.insetter.Side
17- import kotlinx.android.synthetic.main.activity_what_the_stack.*
1815
1916/* *
2017 * An Activity which displays various pieces of information regarding the exception which
2118 * occurred.
2219 */
2320class WhatTheStackActivity : AppCompatActivity () {
2421
22+ private lateinit var binding: ActivityWhatTheStackBinding
23+
2524 private val clipboardManager: ClipboardManager by lazy {
2625 getSystemService(Context .CLIPBOARD_SERVICE ) as ClipboardManager
2726 }
2827
2928 override fun onCreate (savedInstanceState : Bundle ? ) {
3029 super .onCreate(savedInstanceState)
31- setContentView(R .layout.activity_what_the_stack)
30+ binding = ActivityWhatTheStackBinding .inflate(layoutInflater)
31+ setContentView(binding.root)
3232
3333 window.decorView.systemUiVisibility =
3434 View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View .SYSTEM_UI_FLAG_LAYOUT_STABLE
@@ -42,33 +42,33 @@ class WhatTheStackActivity : AppCompatActivity() {
4242 val message = intent.getStringExtra(KEY_EXCEPTION_MESSAGE )
4343 val stackTrace = intent.getStringExtra(KEY_EXCEPTION_STACKTRACE )
4444
45- findViewById< TextView >( R .id. stacktrace) .apply {
45+ binding. stacktrace.apply {
4646 text = stackTrace
4747 setHorizontallyScrolling(true )
4848 movementMethod = ScrollingMovementMethod ()
4949 }
5050
51- findViewById< AppCompatTextView >( R .id. exceptionName) .apply {
51+ binding. exceptionName.apply {
5252 text = getString(R .string.exception_name, type)
5353 }
5454
55- findViewById< AppCompatTextView >( R .id. exceptionCause) .apply {
55+ binding. exceptionCause.apply {
5656 text = getString(R .string.exception_cause, cause)
5757 }
5858
59- findViewById< AppCompatTextView >( R .id. exceptionMessage) .apply {
59+ binding. exceptionMessage.apply {
6060 text = getString(R .string.exception_message, message)
6161 }
6262
63- findViewById< MaterialButton >( R .id. copyStacktrace) .apply {
63+ binding. copyStacktrace.apply {
6464 setOnClickListener {
6565 val clipping = ClipData .newPlainText(" stacktrace" , stackTrace)
6666 clipboardManager.setPrimaryClip(clipping)
6767 snackbar { R .string.copied_message }
6868 }
6969 }
7070
71- findViewById< MaterialButton >( R .id. shareStacktrace) .apply {
71+ binding. shareStacktrace.apply {
7272 setOnClickListener {
7373 val sendIntent: Intent = Intent ().apply {
7474 this .action = Intent .ACTION_SEND
@@ -81,7 +81,7 @@ class WhatTheStackActivity : AppCompatActivity() {
8181 }
8282 }
8383
84- findViewById< MaterialButton >( R .id. launchApplication) .apply {
84+ binding. launchApplication.apply {
8585 setOnClickListener {
8686 context.packageManager.getLaunchIntentForPackage(applicationContext.packageName)?.let {
8787 it.flags = Intent .FLAG_ACTIVITY_NEW_TASK or Intent .FLAG_ACTIVITY_CLEAR_TASK
@@ -92,6 +92,6 @@ class WhatTheStackActivity : AppCompatActivity() {
9292 }
9393
9494 private inline fun snackbar (messageProvider : () -> Int ) {
95- Snackbar .make(nestedScrollRoot, messageProvider(), Snackbar .LENGTH_SHORT ).show()
95+ Snackbar .make(binding. nestedScrollRoot, messageProvider(), Snackbar .LENGTH_SHORT ).show()
9696 }
9797}
0 commit comments