Skip to content

Commit

Permalink
add DemoData.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamsiree committed Apr 1, 2020
1 parent f804a50 commit dcf01a2
Show file tree
Hide file tree
Showing 45 changed files with 3,340 additions and 65 deletions.
4 changes: 3 additions & 1 deletion RxDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".activity.ActivityTMarker"></activity>
<activity android:name=".activity.ActivityDemoDataBankCard"></activity>
<activity android:name=".activity.ActivityDemoData" />
<activity android:name=".activity.ActivityTMarker" />
<activity android:name=".activity.ActivityTLoadingView" />
<activity android:name=".activity.ActivityTStepperIndicator" />
<activity android:name=".activity.ActivityTCardGallery" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ModelFVP> = 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() {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class ActivitySVG : ActivityBase() {
}
}
}
animated_svg_view.start()
try {
animated_svg_view.start()
} catch (e: Exception) {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}


}
Original file line number Diff line number Diff line change
@@ -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<ModelFVP> = 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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ class FragmentDemoType : FragmentLazy() {

private val modelFVPList: MutableList<ModelFVP> = 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()) {
Expand Down
Loading

0 comments on commit dcf01a2

Please sign in to comment.