Skip to content

Commit 05a64a4

Browse files
feat(*): 简化Toast
1 parent 5d9d17b commit 05a64a4

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

lite/src/main/java/com/pengxh/kt/lite/extensions/String.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.pengxh.kt.lite.extensions
22

33
import android.content.Context
4-
import android.graphics.Color
5-
import android.widget.TextView
64
import android.widget.Toast
7-
import com.pengxh.kt.lite.R
85
import net.sourceforge.pinyin4j.PinyinHelper
96
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType
107
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
@@ -218,16 +215,5 @@ fun String.writeToFile(file: File) {
218215
}
219216

220217
fun String.show(context: Context) {
221-
val toast = Toast(context)
222-
val textView = TextView(context)
223-
textView.setBackgroundResource(R.drawable.toast_bg_layout)
224-
textView.setTextColor(Color.WHITE)
225-
textView.textSize = 16f
226-
textView.text = this
227-
textView.setPadding(
228-
20.dp2px(context), 10.dp2px(context), 20.dp2px(context), 10.dp2px(context)
229-
)
230-
toast.view = textView
231-
toast.duration = Toast.LENGTH_SHORT
232-
toast.show()
218+
Toast.makeText(context, this, Toast.LENGTH_SHORT).show()
233219
}

lite/src/main/res/drawable/toast_bg_layout.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)