@@ -3,49 +3,26 @@ package com.tamsiree.rxfeature.activity
33import android.graphics.Color
44import android.os.Bundle
55import android.view.View
6- import android.widget.EditText
7- import android.widget.ImageView
8- import android.widget.LinearLayout
9- import androidx.core.widget.NestedScrollView
106import com.tamsiree.rxfeature.R
117import com.tamsiree.rxfeature.tool.RxBarCode
128import com.tamsiree.rxfeature.tool.RxQRCode
139import com.tamsiree.rxkit.*
1410import com.tamsiree.rxkit.view.RxToast
1511import com.tamsiree.rxui.activity.ActivityBase
16- import com.tamsiree.rxui.view.RxTitle
1712import com.tamsiree.rxui.view.ticker.RxTickerUtils
18- import com.tamsiree.rxui.view.ticker.RxTickerView
13+ import kotlinx.android.synthetic.main.activity_code_tool.*
1914
2015/* *
2116 * @author tamsiree
2217 */
2318class ActivityCodeTool : ActivityBase () {
24- private var mRxTitle: RxTitle ? = null
25- private var mEtQrCode: EditText ? = null
26- private var mIvCreateQrCode: ImageView ? = null
27- private var mIvQrCode: ImageView ? = null
28- private var mActivityCodeTool: LinearLayout ? = null
29- private var mLlCode: LinearLayout ? = null
30- private var mLlQrRoot: LinearLayout ? = null
31- private var mEtBarCode: EditText ? = null
32- private var mIvCreateBarCode: ImageView ? = null
33- private var mIvBarCode: ImageView ? = null
34- private var mLlBarCode: LinearLayout ? = null
35- private var mLlBarRoot: LinearLayout ? = null
36- private var mLlScaner: LinearLayout ? = null
37- private var mLlQr: LinearLayout ? = null
38- private var mLlBar: LinearLayout ? = null
39- private var mRxTickerViewMade: RxTickerView ? = null
40- private var mRxTickerViewScan: RxTickerView ? = null
41- private var nestedScrollView: NestedScrollView ? = null
19+
4220 override fun onCreate (savedInstanceState : Bundle ? ) {
4321 super .onCreate(savedInstanceState)
4422 RxBarTool .noTitle(this )
4523 RxBarTool .setTransparentStatusBar(this )
4624 setContentView(R .layout.activity_code_tool)
4725 RxDeviceTool .setPortrait(this )
48-
4926 }
5027
5128 override fun onResume () {
@@ -54,26 +31,8 @@ class ActivityCodeTool : ActivityBase() {
5431 }
5532
5633 override fun initView () {
57- mRxTitle = findViewById(R .id.rx_title)
58- mEtQrCode = findViewById(R .id.et_qr_code)
59- mIvCreateQrCode = findViewById(R .id.iv_create_qr_code)
60- mIvQrCode = findViewById(R .id.iv_qr_code)
61- mActivityCodeTool = findViewById(R .id.activity_code_tool)
62- mLlCode = findViewById(R .id.ll_code)
63- mLlQrRoot = findViewById(R .id.ll_qr_root)
64- nestedScrollView = findViewById(R .id.nestedScrollView)
65- mEtBarCode = findViewById(R .id.et_bar_code)
66- mIvCreateBarCode = findViewById(R .id.iv_create_bar_code)
67- mIvBarCode = findViewById(R .id.iv_bar_code)
68- mLlBarCode = findViewById(R .id.ll_bar_code)
69- mLlBarRoot = findViewById(R .id.ll_bar_root)
70- mLlScaner = findViewById(R .id.ll_scaner)
71- mLlQr = findViewById(R .id.ll_qr)
72- mLlBar = findViewById(R .id.ll_bar)
73- mRxTickerViewScan = findViewById(R .id.ticker_scan_count)
74- mRxTickerViewScan?.setCharacterList(NUMBER_LIST )
75- mRxTickerViewMade = findViewById(R .id.ticker_made_count)
76- mRxTickerViewMade?.setCharacterList(NUMBER_LIST )
34+ ticker_scan_count.setCharacterList(NUMBER_LIST )
35+ ticker_made_count.setCharacterList(NUMBER_LIST )
7736 updateMadeCodeCount()
7837 }
7938
@@ -82,64 +41,64 @@ class ActivityCodeTool : ActivityBase() {
8241 }
8342
8443 private fun updateScanCodeCount () {
85- mRxTickerViewScan !! .setText(RxDataTool .stringToInt(RxSPTool .getContent(mContext.baseContext!! , RxConstants .SP_SCAN_CODE )).toString() + " " , true )
44+ ticker_scan_count !! .setText(RxDataTool .stringToInt(RxSPTool .getContent(mContext.baseContext!! , RxConstants .SP_SCAN_CODE )).toString() + " " , true )
8645 }
8746
8847 private fun updateMadeCodeCount () {
89- mRxTickerViewMade !! .setText(RxDataTool .stringToInt(RxSPTool .getContent(mContext.baseContext!! , RxConstants .SP_MADE_CODE )).toString() + " " , true )
48+ ticker_made_count .setText(RxDataTool .stringToInt(RxSPTool .getContent(mContext.baseContext!! , RxConstants .SP_MADE_CODE )).toString() + " " , true )
9049 }
9150
9251 private fun initEvent () {
93- mRxTitle !! .isLeftIconVisibility = true
94- mRxTitle !! .titleColor = Color .WHITE
95- mRxTitle !! .titleSize = RxImageTool .dp2px(20f )
96- mRxTitle !! .setLeftFinish(mContext)
97- mRxTickerViewScan !! .animationDuration = 500
98- mIvCreateQrCode !! .setOnClickListener {
99- val str = mEtQrCode !! .text.toString()
52+ rx_title.setLeftIconVisibility( true )
53+ rx_title.setTitleColor( Color .WHITE )
54+ rx_title.setTitleSize( RxImageTool .dp2px(20f ) )
55+ rx_title .setLeftFinish(mContext)
56+ ticker_scan_count !! .animationDuration = 500
57+ iv_create_qr_code .setOnClickListener {
58+ val str = et_qr_code .text.toString()
10059 if (RxDataTool .isNullString(str)) {
10160 RxToast .error(" 二维码文字内容不能为空!" )
10261 } else {
103- mLlCode !! .visibility = View .VISIBLE
62+ ll_code !! .visibility = View .VISIBLE
10463
10564 // 二维码生成方式一 推荐此方法
106- RxQRCode .builder(str).backColor(- 0x1 ).codeColor(- 0x1000000 ).codeSide(600 ).codeLogo(resources.getDrawable(R .drawable.faviconhandsome)).codeBorder(1 ).into(mIvQrCode )
65+ RxQRCode .builder(str).backColor(- 0x1 ).codeColor(- 0x1000000 ).codeSide(600 ).codeLogo(resources.getDrawable(R .drawable.faviconhandsome)).codeBorder(1 ).into(iv_qr_code )
10766
10867 // 二维码生成方式二 默认宽和高都为800 背景为白色 二维码为黑色
109- // RxQRCode.createQRCode(str,mIvQrCode );
110- mIvQrCode !! .visibility = View .VISIBLE
68+ // RxQRCode.createQRCode(str,iv_qr_code );
69+ iv_qr_code !! .visibility = View .VISIBLE
11170 RxToast .success(" 二维码已生成!" )
11271 RxSPTool .putContent(mContext.baseContext!! , RxConstants .SP_MADE_CODE , (RxDataTool .stringToInt(RxSPTool .getContent(mContext.baseContext!! , RxConstants .SP_MADE_CODE )) + 1 ).toString())
11372 updateMadeCodeCount()
11473 nestedScrollView!! .computeScroll()
11574 }
11675 }
117- mIvCreateBarCode !! .setOnClickListener {
118- val str1 = mEtBarCode !! .text.toString()
76+ iv_create_bar_code !! .setOnClickListener {
77+ val str1 = et_bar_code !! .text.toString()
11978 if (RxDataTool .isNullString(str1)) {
12079 RxToast .error(" 条形码文字内容不能为空!" )
12180 } else {
122- mLlBarCode !! .visibility = View .VISIBLE
81+ ll_bar_code !! .visibility = View .VISIBLE
12382
12483 // 条形码生成方式一 推荐此方法
125- RxBarCode .builder(str1).backColor(0x00000000 ).codeColor(- 0x1000000 ).codeWidth(1000 ).codeHeight(300 ).into(mIvBarCode )
84+ RxBarCode .builder(str1).backColor(0x00000000 ).codeColor(- 0x1000000 ).codeWidth(1000 ).codeHeight(300 ).into(iv_bar_code )
12685
12786 // 条形码生成方式二 默认宽为1000 高为300 背景为白色 二维码为黑色
128- // mIvBarCode .setImageBitmap(RxBarCode.createBarCode(str1, 1000, 300));
129- mIvBarCode !! .visibility = View .VISIBLE
87+ // iv_bar_code .setImageBitmap(RxBarCode.createBarCode(str1, 1000, 300));
88+ iv_bar_code !! .visibility = View .VISIBLE
13089 RxToast .success(" 条形码已生成!" )
13190 RxSPTool .putContent(mContext.baseContext!! , RxConstants .SP_MADE_CODE , (RxDataTool .stringToInt(RxSPTool .getContent(mContext.baseContext!! , RxConstants .SP_MADE_CODE )) + 1 ).toString())
13291 updateMadeCodeCount()
13392 }
13493 }
135- mLlScaner !! .setOnClickListener { RxActivityTool .skipActivity(mContext, ActivityScanerCode ::class .java) }
136- mLlQr !! .setOnClickListener {
137- mLlQrRoot !! .visibility = View .VISIBLE
138- mLlBarRoot !! .visibility = View .GONE
94+ ll_scaner !! .setOnClickListener { RxActivityTool .skipActivity(mContext, ActivityScanerCode ::class .java) }
95+ ll_qr !! .setOnClickListener {
96+ ll_qr_root !! .visibility = View .VISIBLE
97+ ll_bar_root !! .visibility = View .GONE
13998 }
140- mLlBar !! .setOnClickListener {
141- mLlBarRoot !! .visibility = View .VISIBLE
142- mLlQrRoot !! .visibility = View .GONE
99+ ll_bar !! .setOnClickListener {
100+ ll_bar_root !! .visibility = View .VISIBLE
101+ ll_qr_root !! .visibility = View .GONE
143102 }
144103 }
145104
0 commit comments