| | |
| | | package com.dollearn.student.ui.home.adapter |
| | | |
| | | import android.view.View |
| | | import androidx.constraintlayout.widget.ConstraintLayout |
| | | import cn.sinata.xldutils.activity.ImagePagerActivity |
| | | import cn.sinata.xldutils.adapter.HFRecyclerAdapter |
| | | import cn.sinata.xldutils.adapter.util.ViewHolder |
| | | import cn.sinata.xldutils.gone |
| | |
| | | import com.dollearn.student.utils.extention.clickDelay |
| | | import com.facebook.drawee.view.SimpleDraweeView |
| | | import kotlinx.android.synthetic.main.fragment_q_a.* |
| | | import org.jetbrains.anko.dip |
| | | import org.jetbrains.anko.startActivity |
| | | import java.util.ArrayList |
| | | |
| | | class CardAdapter(list: ArrayList<Card>):HFRecyclerAdapter<Card>(list, R.layout.item_card) { |
| | | private val act by lazy { context as MemoryActivity } |
| | | var height:Int = 200 //行高 |
| | | var widgh:Int = 300 //行宽 |
| | | |
| | | //第一次翻开的 |
| | | var position1 = -1 |
| | | private var p1View:View? = null |
| | | var p1View:View? = null |
| | | private var f1View:View? = null |
| | | private var b1View:View? = null |
| | | |
| | | //第2次翻开的 |
| | | var position2 = -1 |
| | | private var p2View:View? = null |
| | | var p2View:View? = null |
| | | private var f2View:View? = null |
| | | private var b2View:View? = null |
| | | |
| | |
| | | val front = holder.bind<View>(R.id.front) |
| | | val rlVoice = holder.bind<View>(R.id.rl_voice) |
| | | val ivImg = holder.bind<SimpleDraweeView>(R.id.iv_img) |
| | | |
| | | val iv_play = holder.bind<View>(R.id.iv_play) |
| | | val layoutParams = frame.layoutParams as ConstraintLayout.LayoutParams |
| | | layoutParams.height = height - act.dip(12) |
| | | layoutParams.width = height*3/2 |
| | | if (layoutParams.width > widgh){ |
| | | layoutParams.width = widgh - act.dip(10) |
| | | layoutParams.height = (widgh- act.dip(10))*2/3 |
| | | } |
| | | frame.layoutParams = layoutParams |
| | | if(data.type == 1){ |
| | | rlVoice.gone() |
| | | ivImg.visible() |
| | |
| | | rlVoice.visible() |
| | | ivImg.gone() |
| | | } |
| | | |
| | | iv_play.clickDelay { |
| | | if (!act.playing&&position2 == -1){ |
| | | act.index = position |
| | | act.handler?.sendEmptyMessage(act.PLAY_VOICE) |
| | | } |
| | | } |
| | | frame.clickDelay { |
| | | if(data.isBack){ |
| | | if(!act.playing&&data.isBack){ |
| | | if(position1 == -1) |
| | | position1 = position |
| | | else if(position2 == -1) |