1
1
package com.pengxh.kt.lite.extensions
2
2
3
3
import android.content.Context
4
- import android.graphics.Color
5
- import android.os.Build
6
- import android.widget.TextView
7
4
import android.widget.Toast
8
- import com.pengxh.kt.lite.R
9
5
import net.sourceforge.pinyin4j.PinyinHelper
10
6
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType
11
7
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
@@ -219,21 +215,5 @@ fun String.writeToFile(file: File) {
219
215
}
220
216
221
217
fun String.show (context : Context ) {
222
- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .S ) {
223
- Toast .makeText(context, this , Toast .LENGTH_SHORT ).show()
224
- } else {
225
- val toast = Toast (context)
226
- val textView = TextView (context)
227
- textView.setBackgroundResource(R .drawable.toast_bg_layout)
228
- textView.setTextColor(Color .WHITE )
229
- textView.textSize = 16f
230
- textView.text = this
231
- textView.setPadding(
232
- 20 .dp2px(context), 10 .dp2px(context), 20 .dp2px(context), 10 .dp2px(context)
233
- )
234
- toast.view = textView
235
- toast.duration = Toast .LENGTH_SHORT
236
- toast.show()
237
- Toast .makeText(context, this , Toast .LENGTH_SHORT ).show()
238
- }
218
+ Toast .makeText(context, this , Toast .LENGTH_SHORT ).show()
239
219
}
0 commit comments