как использовать библиотеку DragDropSwipeRecyclerview - PullRequest
0 голосов
/ 12 января 2020

Я работаю с этой библиотекой DragDropSwipeRecyclerview

https://github.com/ernestoyaquello/DragDropSwipeRecyclerview

, и я не могу понять, как использовать этот забавный getBehindSwipedItemLayoutId, который позволит вам получить доступ Ваш пользовательский макет для настройки внутри onBindViewHolder () через holder.behindSwipedItemLayout.

, поэтому, если кто-то уже использовал его, пожалуйста, помогите мне, спасибо

это мой код адаптера:

class MyAdapter(val context:Context): DragDropSwipeAdapter<SurveyResultDataBaseModule, MyAdapter.ViewHolder>() {

     inner class ViewHolder(itemView: View) : DragDropSwipeAdapter.ViewHolder(itemView) {

      val nameOfInvestigator:TextView  = itemView.findViewById(R.id.NameOfInvestigator)
      val phoneNumberOfInvestigator:TextView  = itemView.findViewById(R.id.PhoneNumberOfInvestigator)
      val brandOfInvestigator:ImageView   = itemView.findViewById(R.id.ivBrandOfInvestigator)
      val carModulOfInvestigator:TextView = itemView.findViewById(R.id.tvCarOfInvestigator)
      val ivRimSizeOfInvestigator:ImageView = itemView.findViewById(R.id.ivRimSizeOfInvestigator)
      val rimSizeOfInvestigator:TextView  = itemView.findViewById(R.id.tvRimeSize)

        var pos=0

        fun setDATA(pos: Int, nameOfInvestigator:String, phoneNumberOfInvestigator:String, brandOfInvestigator:String, carModulOfInvestigator:String, rimSizeOfInvestigator:String){

            this.pos=pos

            this.nameOfInvestigator.text=nameOfInvestigator
            this.phoneNumberOfInvestigator.text=phoneNumberOfInvestigator
            when (brandOfInvestigator){
                "0" ->  this.brandOfInvestigator.setImageResource(R.drawable.audi)
                "1" ->  this.brandOfInvestigator.setImageResource(R.drawable.bmw)
                "31" -> this.brandOfInvestigator.setImageResource(R.drawable.other)
            }

            this.carModulOfInvestigator.text=carModulOfInvestigator
            this.ivRimSizeOfInvestigator.setImageResource(R.drawable.cartyers)
            this.rimSizeOfInvestigator.text=rimSizeOfInvestigator
        }

        fun setListener() {
            itemView.setOnClickListener {
              val intent= Intent(context,SingleSurveyResult::class.java)
                intent.putExtra(IrisTyres.DataBaseTableEntry.COLUMN_ID,dataSet[pos].id)
                (context as Activity).startActivityForResult(intent,2)
            }
        }

    }

     override fun getViewHolder(itemView: View) = ViewHolder(itemView)

     override fun getViewToTouchToStartDraggingItem(item: SurveyResultDataBaseModule, viewHolder: ViewHolder, position: Int): View? {
         return viewHolder.ivRimSizeOfInvestigator     }

     override fun onBindViewHolder(item: SurveyResultDataBaseModule, viewHolder: ViewHolder, position: Int) {
         val singleFinished=dataSet[position]
         viewHolder.setDATA(
                 position,
                 singleFinished.I1,
                 singleFinished.I2,
                 singleFinished.Q2,
                 singleFinished.Q3,
                 singleFinished.Q3A
         )
         viewHolder.setListener()

         val behindSwipedItemLayout = viewHolder.behindSwipedItemLayout //error

     }

     fun setFinishedSurveyResult(FinishedSurveyResult: ArrayList<SurveyResultDataBaseModule>) {
         dataSet=FinishedSurveyResult
         notifyDataSetChanged()
     }

     override fun getBehindSwipedItemLayoutId(item: SurveyResultDataBaseModule, viewHolder: ViewHolder, position: Int): Int? {
         return R.layout.swiped_item_main_direction_layout
     }
 }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...