Skip to content

Commit

Permalink
released 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cinkhangin committed Aug 22, 2023
1 parent cb6ffb7 commit 3577a5c
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions app/src/main/java/com/naulian/glow/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
package com.naulian.glow

import android.os.Bundle
import android.widget.EditText
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.doAfterTextChanged
import com.naulian.anhance.readStringAsset
import com.naulian.glow.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
@Suppress("unused")
private val TAG = MainActivity::class.java.simpleName

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val textInput = findViewById<EditText>(R.id.textInput)
val textSource = findViewById<TextView>(R.id.textSource)
val textOutput = findViewById<TextView>(R.id.textOutput)
val binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

val filename = "sample.txt"
val language = ""

readStringAsset(filename) { result ->
result.onSuccess {
textInput.setText(it)
val highlighted = glowSyntax(it,language, CodeTheme.kotlinLight)
binding.apply {
readStringAsset(filename) { result ->
result.onSuccess {
textInput.setText(it)
val highlighted = glowSyntax(it,language, CodeTheme.kotlinLight)
textSource.text = highlighted.raw
textOutput.setCodeTheme(CodeTheme.kotlinLight.normal)
textOutput.text = highlighted.spanned
}
result.onFailure {
textOutput.text = it.message
}
}

textInput.doAfterTextChanged {
val text = it?.toString() ?: ""
val highlighted = glowSyntax(text,language, CodeTheme.kotlinLight)
textSource.text = highlighted.raw
textOutput.setCodeTheme(CodeTheme.kotlinLight.normal)
textOutput.text = highlighted.spanned
}
result.onFailure {
textOutput.text = it.message
}
}

textInput.doAfterTextChanged {
val text = it?.toString() ?: ""
val highlighted = glowSyntax(text,language, CodeTheme.kotlinLight)
textSource.text = highlighted.raw
textOutput.setCodeTheme(CodeTheme.kotlinLight.normal)
textOutput.text = highlighted.spanned
}
}
}

0 comments on commit 3577a5c

Please sign in to comment.