Преглед изворни кода

change StandardStampAdapter constructor

cooperku_kdanmobile пре 5 година
родитељ
комит
eabf9cd524

+ 3 - 3
reader/src/main/java/com/kdanmobile/reader/screen/view/edit/CustomStampAdapter.kt

@@ -33,11 +33,11 @@ class CustomStampAdapter(private val context: Context, private val stampTypes: A
             }
         }
         holder.ivStamp.setImageResource(stampType.resourceId)
-        holder.ivSelectedBorder.visibility = when(position == selectedIndex) {
+        holder.ivSelectedBorder.visibility = when (position == selectedIndex) {
             true -> View.VISIBLE
             false -> View.INVISIBLE
         }
-        holder.ivSelectedArrow.visibility = when(position == selectedIndex) {
+        holder.ivSelectedArrow.visibility = when (position == selectedIndex) {
             true -> View.VISIBLE
             false -> View.INVISIBLE
         }
@@ -53,7 +53,7 @@ class CustomStampAdapter(private val context: Context, private val stampTypes: A
         return CustomStampViewHolder(view)
     }
 
-    fun setOnStampClickListener(onStampClickListener: OnStampClickListener) {
+    fun setOnStampClickListener(onStampClickListener: OnStampClickListener?) {
         this.onStampClickListener = onStampClickListener
     }
 }

+ 1 - 23
reader/src/main/java/com/kdanmobile/reader/screen/view/edit/StampTabView.kt

@@ -75,29 +75,7 @@ class StampTabView : ConstraintLayout {
                     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)
+                    val adapter = StandardStampAdapter(context, STANDARD_STAMP_RES.values())
                     adapter.setOnStampClickListener(object : OnStampClickListener {
                         override fun onStampClick(index: Int) {
                             selectedStandardStampIndex = index

+ 5 - 4
reader/src/main/java/com/kdanmobile/reader/screen/view/edit/StandardStampAdapter.kt

@@ -4,8 +4,9 @@ import android.content.Context
 import android.support.v7.widget.RecyclerView
 import android.view.ViewGroup
 import android.widget.ImageView
+import com.kdanmobile.kmpdfkit.annotation.stamp.StampConfig
 
-class StandardStampAdapter(private val context: Context, private val resourceIds: Array<Int>): RecyclerView.Adapter<StandardStampViewHolder>() {
+class StandardStampAdapter(private val context: Context, private val resourceIds: Array<StampConfig.STANDARD_STAMP_RES>): RecyclerView.Adapter<StandardStampViewHolder>() {
 
     private var selectedIndex = 0
     private var onStampClickListener: OnStampClickListener? = null
@@ -21,8 +22,8 @@ class StandardStampAdapter(private val context: Context, private val resourceIds
                 onStampClickListener?.onStampClick(selectedIndex)
             }
         }
-        holder.imageView.setImageResource(resourceIds[position])
-        holder.imageView.setBackgroundColor(when(position == selectedIndex) {
+        holder.imageView.setImageResource(resourceIds[position].resId)
+        holder.imageView.setBackgroundColor(when (position == selectedIndex) {
             true -> 0xff80ffff.toInt()
             false -> 0xffffffff.toInt()
         })
@@ -37,7 +38,7 @@ class StandardStampAdapter(private val context: Context, private val resourceIds
         return StandardStampViewHolder(view)
     }
 
-    fun setOnStampClickListener(onStampClickListener: OnStampClickListener) {
+    fun setOnStampClickListener(onStampClickListener: OnStampClickListener?) {
         this.onStampClickListener = onStampClickListener
     }
 }