|
@@ -0,0 +1,131 @@
|
|
|
+package com.kdanmobile.reader.screen.view.edit
|
|
|
+
|
|
|
+import android.content.Context
|
|
|
+import android.support.constraint.ConstraintLayout
|
|
|
+import android.support.v4.view.PagerAdapter
|
|
|
+import android.support.v7.widget.GridLayoutManager
|
|
|
+import android.support.v7.widget.LinearLayoutManager
|
|
|
+import android.util.AttributeSet
|
|
|
+import android.view.LayoutInflater
|
|
|
+import android.view.View
|
|
|
+import android.view.ViewGroup
|
|
|
+import com.kdanmobile.kmpdfkit.annotation.stamp.StampConfig.STANDARD_STAMP_RES
|
|
|
+import com.kdanmobile.reader.R
|
|
|
+import kotlinx.android.synthetic.main.view_viewer_edit_item_stamp_custom.view.*
|
|
|
+import kotlinx.android.synthetic.main.view_viewer_edit_item_stamp_standard.view.*
|
|
|
+import kotlinx.android.synthetic.main.view_viewer_edit_tab_stamp.view.*
|
|
|
+import java.text.SimpleDateFormat
|
|
|
+import java.util.*
|
|
|
+
|
|
|
+class StampTabView : ConstraintLayout {
|
|
|
+
|
|
|
+ private var selectedCustomStampIndex = 0
|
|
|
+ private var selectedStandardStampIndex = 0
|
|
|
+
|
|
|
+ constructor(context: Context) : super(context) {
|
|
|
+ initView()
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
|
|
+ initView()
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
|
|
|
+ initView()
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun initView() {
|
|
|
+ LayoutInflater.from(context).inflate(R.layout.view_viewer_edit_tab_stamp, this)
|
|
|
+
|
|
|
+ titleButton_stamp.onButtonClickListener = OnClickListener { _ ->
|
|
|
+ println("onButtonClick\tpage = ${viewPager.currentItem}\tselectedIndex = ${when(viewPager.currentItem == 0) { true -> selectedCustomStampIndex; false -> selectedStandardStampIndex }}")
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ viewPager.adapter = StampViewPagerAdapter(arrayListOf("Custom", "Standard"))
|
|
|
+ tabLayout.setupWithViewPager(viewPager)
|
|
|
+ }
|
|
|
+
|
|
|
+ private inner class StampViewPagerAdapter(private val tabs: ArrayList<String>): PagerAdapter() {
|
|
|
+ private val layoutInflater = LayoutInflater.from(context)
|
|
|
+
|
|
|
+ override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
|
|
+ val view = when (position) {
|
|
|
+ 0 -> {
|
|
|
+ val customStampView = layoutInflater.inflate(R.layout.view_viewer_edit_item_stamp_custom, container, false)
|
|
|
+
|
|
|
+ val date = Date()
|
|
|
+ customStampView.cb_date.text = SimpleDateFormat("yyyy/MM/dd").format(date)
|
|
|
+ customStampView.cb_time.text = SimpleDateFormat("hh:mm:ss a").format(date).toLowerCase(Locale.US)
|
|
|
+
|
|
|
+ val recyclerView = customStampView.recyclerView_shapeCustom
|
|
|
+ recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
|
|
+ val adapter = CustomStampAdapter(context, CustomStampType.values())
|
|
|
+ adapter.setOnStampClickListener(object : OnStampClickListener {
|
|
|
+ override fun onStampClick(index: Int) {
|
|
|
+ selectedCustomStampIndex = index
|
|
|
+ }
|
|
|
+ })
|
|
|
+ recyclerView.adapter = adapter
|
|
|
+ recyclerView.setHasFixedSize(true)
|
|
|
+ customStampView
|
|
|
+ }
|
|
|
+ else -> {
|
|
|
+ val standardStampView = layoutInflater.inflate(R.layout.view_viewer_edit_item_stamp_standard, container, false)
|
|
|
+ val recyclerView = standardStampView.recyclerView_shapeStandard
|
|
|
+ recyclerView.layoutManager = GridLayoutManager(context, 3)
|
|
|
+ val resourceIds = arrayOf(
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_APPROVED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_NOTAPPROVED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_DRAFT.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_FINAL.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_COMPLETED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_CONFIDENTIAL.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_FORPUBLICRELEASE.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_NOTFORPUBLICRELEASE.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_FORCOMMENT.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_VOID.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_PRELIMINARYRESULTS.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_INFORMATIONONLY.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_WITNESS.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_INITIALHERE.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_SIGNHERE.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_REVISED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_ACCEPTED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_REJECTED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_PRIVATEACCEPTED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_PRIVATEREJECTED.resId,
|
|
|
+ STANDARD_STAMP_RES.PDF_STAMP_PRIVATERADIOMARK.resId)
|
|
|
+ val adapter = StandardStampAdapter(context, resourceIds)
|
|
|
+ adapter.setOnStampClickListener(object : OnStampClickListener {
|
|
|
+ override fun onStampClick(index: Int) {
|
|
|
+ selectedStandardStampIndex = index
|
|
|
+ }
|
|
|
+ })
|
|
|
+ recyclerView.adapter = adapter
|
|
|
+ recyclerView.setHasFixedSize(true)
|
|
|
+ standardStampView
|
|
|
+ }
|
|
|
+ }
|
|
|
+ container.addView(view)
|
|
|
+ return view
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun destroyItem(container: ViewGroup, position: Int, obj: Any) {
|
|
|
+ container.removeView(obj as View)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun getCount(): Int {
|
|
|
+ return tabs.size
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun isViewFromObject(view: View, obj: Any): Boolean {
|
|
|
+ return view == obj
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun getPageTitle(position: Int): CharSequence? {
|
|
|
+ return tabs[position]
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|