| | |
| | | private val years = arrayListOf<Int>() |
| | | private val months = arrayListOf<Int>() |
| | | |
| | | private val data by lazy { arguments?.getString("data") } |
| | | |
| | | override fun onCreateView( |
| | | inflater: LayoutInflater, |
| | | container: ViewGroup?, |
| | |
| | | wv_4.gone() |
| | | wv_5.gone() |
| | | |
| | | setYear() |
| | | setYear(true) |
| | | setMonth(true) |
| | | setDay(true) |
| | | |
| | | wv_1.setOnWheelViewListener { _, item -> |
| | | wv_1.setOnWheelViewListener { _, _ -> |
| | | setMonth() |
| | | setDay() |
| | | } |
| | |
| | | dismiss() |
| | | } |
| | | tv_action.setOnClickListener { |
| | | callback?.onOk("%s.%s.%s".format(wv_1.seletedItem,wv_2.seletedItem,wv_3.seletedItem)) |
| | | callback?.onOk("%s-%s-%s".format(wv_1.seletedItem,wv_2.seletedItem,wv_3.seletedItem)) |
| | | dismiss() |
| | | } |
| | | } |
| | | |
| | | private fun setYear() { |
| | | private fun setYear(isFirst:Boolean = false) { |
| | | val year = Calendar.getInstance().get(Calendar.YEAR) |
| | | years.addAll((1970..year)) |
| | | years.addAll((1960..year)) |
| | | wv_1.setItems(years.map { |
| | | it.toString() |
| | | }) |
| | | wv_1.setSeletion(years.lastIndex) |
| | | if (isFirst && !data.isNullOrEmpty()){ |
| | | wv_1.setSeletion(years.indexOf(data!!.split("-")[0].toInt())) |
| | | |
| | | }else |
| | | wv_1.setSeletion(years.lastIndex) |
| | | } |
| | | |
| | | private fun setMonth(isFirst:Boolean = false) { |
| | |
| | | String.format("%02d",it) |
| | | } |
| | | wv_2.setItems(list) |
| | | wv_2.setSeletion(if (isFirst) list.lastIndex else 0) |
| | | wv_2.setSeletion(if (isFirst){ |
| | | if (!data.isNullOrEmpty()) |
| | | months.indexOf(data!!.split("-")[1].toInt()) |
| | | else |
| | | list.lastIndex |
| | | } else 0) |
| | | } |
| | | |
| | | private fun setDay(isFirst:Boolean = false) { |
| | |
| | | String.format("%02d",it) |
| | | } |
| | | wv_3.setItems(list) |
| | | wv_3.setSeletion(if (isFirst) list.lastIndex else 0) |
| | | wv_3.setSeletion(if (isFirst){ |
| | | if (!data.isNullOrEmpty()) |
| | | list.indexOf(data!!.split("-")[2]) |
| | | else |
| | | list.lastIndex |
| | | } else 0) |
| | | } |
| | | |
| | | interface Callback { |