diff --git a/RxDemo/src/main/AndroidManifest.xml b/RxDemo/src/main/AndroidManifest.xml index 78fe11b8..3ad752fb 100644 --- a/RxDemo/src/main/AndroidManifest.xml +++ b/RxDemo/src/main/AndroidManifest.xml @@ -22,7 +22,9 @@ android:supportsRtl="true" android:theme="@style/AppTheme" tools:ignore="GoogleAppIndexingWarning"> - + + + diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityDemoData.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityDemoData.kt new file mode 100644 index 00000000..b7e9ecee --- /dev/null +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityDemoData.kt @@ -0,0 +1,39 @@ +package com.tamsiree.rxdemo.activity + +import android.os.Bundle +import com.tamsiree.rxdemo.R +import com.tamsiree.rxdemo.fragment.FragmentDemoDataBankCard +import com.tamsiree.rxdemo.fragment.FragmentDemoDataPersonInfo +import com.tamsiree.rxui.activity.ActivityBase +import com.tamsiree.rxui.adapter.AdapterFVP +import com.tamsiree.rxui.model.ModelFVP +import kotlinx.android.synthetic.main.activity_demo_data.* +import java.util.* + +class ActivityDemoData : ActivityBase() { + + private val modelFVPList: MutableList = ArrayList() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_demo_data) + } + + override fun initView() { + rxTitle.setLeftFinish(mContext) + + if (modelFVPList.isEmpty()) { + modelFVPList.add(ModelFVP("银行卡", FragmentDemoDataBankCard.newInstance())) + modelFVPList.add(ModelFVP("个人信息", FragmentDemoDataPersonInfo.newInstance())) + } + + viewPager.adapter = AdapterFVP(supportFragmentManager, modelFVPList) + tabLayout.setViewPager(viewPager) + + } + + override fun initData() { + + } + +} diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivitySVG.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivitySVG.kt index 8d0d37ca..47db5811 100644 --- a/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivitySVG.kt +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivitySVG.kt @@ -55,6 +55,10 @@ class ActivitySVG : ActivityBase() { } } } - animated_svg_view.start() + try { + animated_svg_view.start() + } catch (e: Exception) { + + } } } \ No newline at end of file diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityTStepperIndicator.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityTStepperIndicator.kt index e0049d42..ea181b30 100644 --- a/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityTStepperIndicator.kt +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityTStepperIndicator.kt @@ -2,7 +2,7 @@ package com.tamsiree.rxdemo.activity import android.os.Bundle import com.tamsiree.rxdemo.R -import com.tamsiree.rxdemo.adapter.PagerAdapter +import com.tamsiree.rxdemo.adapter.AdapterFP import com.tamsiree.rxui.activity.ActivityBase import com.tamsiree.rxui.view.indicator.TStepperIndicator import kotlinx.android.synthetic.main.activity_tstepper_indicator.* @@ -19,7 +19,7 @@ class ActivityTStepperIndicator : ActivityBase() { override fun initView() { rx_title.setLeftFinish(this) - pager.adapter = PagerAdapter(supportFragmentManager) + pager.adapter = AdapterFP(supportFragmentManager) val indicator: TStepperIndicator = findViewById(R.id.stepper_indicator) // We keep last page for a "finishing" page diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/adapter/PagerAdapter.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/adapter/AdapterFP.kt similarity index 72% rename from RxDemo/src/main/java/com/tamsiree/rxdemo/adapter/PagerAdapter.kt rename to RxDemo/src/main/java/com/tamsiree/rxdemo/adapter/AdapterFP.kt index 0e8c5c4b..c97461c8 100644 --- a/RxDemo/src/main/java/com/tamsiree/rxdemo/adapter/PagerAdapter.kt +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/adapter/AdapterFP.kt @@ -3,7 +3,7 @@ package com.tamsiree.rxdemo.adapter import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter -import com.tamsiree.rxdemo.fragment.PageFragment +import com.tamsiree.rxdemo.fragment.FragmentPage /** * @ClassName PagerAdapter @@ -13,13 +13,13 @@ import com.tamsiree.rxdemo.fragment.PageFragment * @Version 1.0 */ -internal class PagerAdapter(fm: FragmentManager?) : FragmentPagerAdapter(fm!!) { +internal class AdapterFP(fm: FragmentManager?) : FragmentPagerAdapter(fm!!) { override fun getCount(): Int { return 5 } override fun getItem(position: Int): Fragment { - return PageFragment.newInstance(position + 1, position == count - 1) + return FragmentPage.newInstance(position + 1, position == count - 1) } override fun getPageTitle(position: Int): CharSequence { diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemo.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemo.kt index 5f6b6abe..2b68559c 100644 --- a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemo.kt +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemo.kt @@ -35,11 +35,15 @@ class FragmentDemo : FragmentLazy, OnRefreshListener { this.demo_type = demo_type } - override fun initViews(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View { + override fun inflateView(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View { val view = layoutInflater.inflate(R.layout.fragment_demo, viewGroup, false) return view } + override fun initView() { + + } + override fun initData() { init() loadData() @@ -114,6 +118,7 @@ class FragmentDemo : FragmentLazy, OnRefreshListener { mDemoList!!.add(ModelDemo("PULL解析XML", R.drawable.circle_swap_vert, ActivityXmlParse::class.java)) mDemoList!!.add(ModelDemo("支付宝支付Demo", R.drawable.circle_alipay, ActivityAliPay::class.java)) mDemoList!!.add(ModelDemo("Hold住崩溃界面", R.drawable.crash_logo, ActivityOnCrash::class.java)) + mDemoList!!.add(ModelDemo("随机生成测试数据", R.drawable.crash_logo, ActivityDemoData::class.java)) mDemoList!!.add(ModelDemo("app检测更新与安装", R.mipmap.ic_launcher, ActivitySplash::class.java)) } diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoDataBankCard.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoDataBankCard.kt new file mode 100644 index 00000000..e90e375a --- /dev/null +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoDataBankCard.kt @@ -0,0 +1,135 @@ +package com.tamsiree.rxdemo.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.tamsiree.rxdemo.R +import com.tamsiree.rxkit.RxDataTool +import com.tamsiree.rxkit.demodata.bank.BankCardNumberGenerator +import com.tamsiree.rxkit.demodata.bank.BankCardNumberValidator +import com.tamsiree.rxkit.demodata.bank.BankCardTypeEnum +import com.tamsiree.rxkit.demodata.bank.BankNameEnum +import com.tamsiree.rxkit.view.RxToast +import com.tamsiree.rxui.fragment.FragmentLazy +import kotlinx.android.synthetic.main.fragment_demo_data_bank_card.* + +class FragmentDemoDataBankCard : FragmentLazy() { + + override fun inflateView(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View { + val view = layoutInflater.inflate(R.layout.fragment_demo_data_bank_card, viewGroup, false) + return view + } + + override fun initView() { + + } + + override fun initData() { + checkboxFormatCard.setOnCheckedChangeListener { buttonView, isChecked -> + val value0 = tvBankCardNumber0.text.toString() + val value = tvBankCardNumber.text.toString() + val value1 = tvBankCardNumberICBC.text.toString() + val value2 = tvBankCardNumberICBC1.text.toString() + val value3 = tvBankCardNumber1.text.toString() + if (isChecked) { + if (!RxDataTool.isContainSpace(value)) { + tvBankCardNumber.text = RxDataTool.formatCard(value) + } + if (!RxDataTool.isContainSpace(value)) { + tvBankCardNumber0.text = RxDataTool.formatCard(value0) + } + if (!RxDataTool.isContainSpace(value1)) { + tvBankCardNumberICBC.text = RxDataTool.formatCard(value1) + } + if (!RxDataTool.isContainSpace(value2)) { + tvBankCardNumberICBC1.text = RxDataTool.formatCard(value2) + } + if (!RxDataTool.isContainSpace(value3)) { + tvBankCardNumber1.text = RxDataTool.formatCard(value3) + } + } else { + tvBankCardNumber0.text = RxDataTool.cleanSpace(value0) + tvBankCardNumber.text = RxDataTool.cleanSpace(value) + tvBankCardNumberICBC.text = RxDataTool.cleanSpace(value1) + tvBankCardNumberICBC1.text = RxDataTool.cleanSpace(value2) + tvBankCardNumber1.text = RxDataTool.cleanSpace(value3) + } + } + + btnBankCardNumber0.setOnClickListener { + //银行 + val bankCardNo: String = BankCardNumberGenerator.instance.generate() + if (checkboxFormatCard.isChecked) { + tvBankCardNumber0.text = RxDataTool.formatCard(bankCardNo) + } else { + tvBankCardNumber0.text = bankCardNo + } + } + + btnBankCardNumber.setOnClickListener { + //华润银行 + val bankCardNo: String = BankCardNumberGenerator.generate(BankNameEnum.CR, null) + if (checkboxFormatCard.isChecked) { + tvBankCardNumber.text = RxDataTool.formatCard(bankCardNo) + } else { + tvBankCardNumber.text = bankCardNo + } + } + + + + btnBankCardNumberICBC.setOnClickListener { + //中国工商银行 信用卡/贷记卡 + val bankCardNo: String = BankCardNumberGenerator.generate(BankNameEnum.ICBC, BankCardTypeEnum.CREDIT) + if (checkboxFormatCard.isChecked) { + tvBankCardNumberICBC.text = RxDataTool.formatCard(bankCardNo) + } else { + tvBankCardNumberICBC.text = bankCardNo + } + } + + btnBankCardNumberICBC1.setOnClickListener { + //中国工商银行 借记卡/储蓄卡 + val bankCardNo: String = BankCardNumberGenerator.generate(BankNameEnum.ICBC, BankCardTypeEnum.DEBIT) + if (checkboxFormatCard.isChecked) { + tvBankCardNumberICBC1.text = RxDataTool.formatCard(bankCardNo) + } else { + tvBankCardNumberICBC1.text = bankCardNo + } + } + + btnBankCardNumber1.setOnClickListener { + val prefix = edBankCardNumber1.text.toString() + if (edBankCardNumber1.text.length == 6 && RxDataTool.isInteger(edBankCardNumber1.text.toString())) { + //根据给定前六位生成卡号 + val bankCardNo: String = BankCardNumberGenerator.generateByPrefix(prefix.toInt()) + if (checkboxFormatCard.isChecked) { + tvBankCardNumber1.text = RxDataTool.formatCard(bankCardNo) + } else { + tvBankCardNumber1.text = bankCardNo + } + } else { + RxToast.error("银行卡前缀格式输入有误") + } + } + + btnBankCardNumberV.setOnClickListener { + val value = edBankCardNumberV.text.toString() + + if (BankCardNumberValidator.validate(value)) { + tvBankCardNumberV.text = "合法" + } else { + tvBankCardNumberV.text = "不合法" + } + } + } + + companion object { + fun newInstance(): FragmentDemoDataBankCard { + return FragmentDemoDataBankCard() + } + } + + +} \ No newline at end of file diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoDataPersonInfo.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoDataPersonInfo.kt new file mode 100644 index 00000000..ee8d3973 --- /dev/null +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoDataPersonInfo.kt @@ -0,0 +1,97 @@ +package com.tamsiree.rxdemo.fragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.tamsiree.rxdemo.R +import com.tamsiree.rxkit.demodata.* +import com.tamsiree.rxui.fragment.FragmentLazy +import com.tamsiree.rxui.model.ModelFVP +import kotlinx.android.synthetic.main.fragment_demo_data_person_info.* +import java.util.* + +class FragmentDemoDataPersonInfo : FragmentLazy() { + + private val modelFVPList: MutableList = ArrayList() + + override fun inflateView(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View { + val view = layoutInflater.inflate(R.layout.fragment_demo_data_person_info, viewGroup, false) + return view + } + + override fun initView() { + btnName.setOnClickListener { + //生成常见姓名 + val name: String = ChineseNameGenerator.instance.generate() + tvName.text = name + } + + btnName1.setOnClickListener { + //生成带有生僻名字部分的姓名 + val name: String = ChineseNameGenerator.instance.generateOdd() + tvName1.text = name + } + btnEnglishName.setOnClickListener { + //生成英文名 + val name: String = EnglishNameGenerator.instance.generate() + tvEnglishName.text = name + } + + btnAddress.setOnClickListener { + //生成地址 + val address: String = ChineseAddressGenerator.instance.generate() + tvAddress.text = address + } + + btnIDOffice.setOnClickListener { + //生成签发机关 + val idOffice: String = ChineseIDCardNumberGenerator.generateIssueOrg() + tvIDOffice.text = idOffice + } + btnIDDate.setOnClickListener { + //生成有效期限 + val idOffice: String = ChineseIDCardNumberGenerator.generateValidPeriod() + tvIDDate.text = idOffice + } + + btnID1.setOnClickListener { + //生成身份证 + val id: String = ChineseIDCardNumberGenerator.instance.generate() + tvID.text = id + + if (id[id.length - 2].toInt() % 2 == 0) { + tvGender.text = "女" + } else { + tvGender.text = "男" + } + } + + btnMobile.setOnClickListener { + //生成手机号码 + val mobile: String = ChineseMobileNumberGenerator.instance.generate() + tvMobile.text = mobile + } + + btnMobileFake.setOnClickListener { + //生成虚假手机号码 + val mobile: String = ChineseMobileNumberGenerator.instance.generateFake() + tvMobileFake.text = mobile + } + btnEmail.setOnClickListener { + //生成虚假手机号码 + val email: String = EmailAddressGenerator.instance.generate() + tvEmail.text = email + } + } + + override fun initData() { + + } + + companion object { + fun newInstance(): FragmentDemoDataPersonInfo { + return FragmentDemoDataPersonInfo() + } + } +} \ No newline at end of file diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoType.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoType.kt index f0651125..b5e46571 100644 --- a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoType.kt +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemoType.kt @@ -15,11 +15,15 @@ class FragmentDemoType : FragmentLazy() { private val modelFVPList: MutableList = ArrayList() - override fun initViews(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View { + override fun inflateView(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View { val view = layoutInflater.inflate(R.layout.fragment_demo_type, viewGroup, false) return view } + override fun initView() { + + } + override fun initData() { if (modelFVPList.isEmpty()) { diff --git a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentLoadingDemo.kt b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentLoadingDemo.kt index fe1793af..ac24ed0f 100644 --- a/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentLoadingDemo.kt +++ b/RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentLoadingDemo.kt @@ -5,51 +5,55 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.Button -import android.widget.ImageView -import android.widget.ProgressBar -import android.widget.TextView -import androidx.fragment.app.Fragment import com.tamsiree.rxdemo.R +import com.tamsiree.rxui.fragment.FragmentLazy import com.tamsiree.rxui.view.loadingview.style.Circle import com.tamsiree.rxui.view.loadingview.style.CubeGrid import com.tamsiree.rxui.view.loadingview.style.DoubleBounce import com.tamsiree.rxui.view.loadingview.style.Wave +import kotlinx.android.synthetic.main.fragment_page2.* /** * Created by Tamsiree. * @author tamsiree */ -class FragmentLoadingDemo : Fragment() { +class FragmentLoadingDemo : FragmentLazy() { + var colors = intArrayOf( Color.parseColor("#89CFF0"), Color.parseColor("#2B3E51")) + private var mWaveDrawable: Wave? = null private var mCircleDrawable: Circle? = null private var mChasingDotsDrawable: CubeGrid? = null - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { - return inflater.inflate(R.layout.fragment_page2, null) + + + override fun inflateView(layoutInflater: LayoutInflater, viewGroup: ViewGroup?, savedInstanceState: Bundle?): View { + val view = layoutInflater.inflate(R.layout.fragment_page2, viewGroup, false) + return view } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) + override fun initView() { + + } + override fun initData() { //ProgressBar - val progressBar = view.findViewById(R.id.progress) + val progressBar = progress val doubleBounce = DoubleBounce() doubleBounce.setBounds(0, 0, 100, 100) doubleBounce.color = colors[0] progressBar.indeterminateDrawable = doubleBounce //Button - val button = view.findViewById