-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainActivity.kt
48 lines (38 loc) · 1.77 KB
/
MainActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.eemmez.localizationmanagersample
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.eemmez.localization.LocalizationManager
class MainActivity : AppCompatActivity() {
private val localizationManager = LocalizationManager(this)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
getTextView(R.id.tvNormalString).text = localizationManager.getString(R.string.normal_string)
getTextView(R.id.tvBoldString).text = localizationManager.getSpannable(R.string.bold_string)
getTextView(R.id.tvStringWithGenericId).text = localizationManager.getStringByGenericId("string_with_generic_id", R.string::class.java)
getTextView(R.id.tvGenericString).text =
localizationManager.getGenericSpannable(
resId = R.string.generic_string_with_multiple_parameter,
"number" to "0123456789",
"name" to "Emirhan"
)
getTextView(R.id.tvLinkedString).apply {
text = localizationManager.getClickableText(
resId = R.string.linked_string,
clickableTextColor = android.R.color.holo_red_dark,
textView = this,
"number" to {
Toast.makeText(this@MainActivity, "Number text clicked!", Toast.LENGTH_SHORT)
.show()
},
"name" to {
Toast.makeText(this@MainActivity, "Name text clicked!", Toast.LENGTH_SHORT)
.show()
}
)
}
}
private fun getTextView(resId: Int): TextView = findViewById(resId)
}