Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.58 KB

이미지 슬라이드 + 이미지 상세.md

File metadata and controls

59 lines (45 loc) · 1.58 KB
class ImageSliderFragment(private val imageUrl: String, val itemClicked:() -> Unit) :
    UtilityBase.BaseFragment<FragmentPartnershipImageSliderBinding>(R.layout.fragment_partnership_image_slider) {

    override fun FragmentPartnershipImageSliderBinding.onViewCreated() {
        initView()
        setListener()
    }

    override fun initView() {
        binding.ivImage.apply {
            Glide.with(this.context)
                .load(imageUrl)
                .into(this)
        }
    }

    override fun setListener() {
        binding.ivImage.setOnClickListener { itemClicked.invoke() }
    }
}
class ImageSlidePagerAdapter(
    fragmentActivity: FragmentActivity,
    var imageUrlArray: ArrayList<String>,
    val itemClicked: (Int) -> Unit
) :
    FragmentStateAdapter(fragmentActivity) {

    override fun getItemCount(): Int {
        return imageUrlArray.size
    }

    override fun createFragment(position: Int): Fragment {
        return ImageSliderFragment(imageUrlArray[position]){
            itemClicked(position)
        }
    }

}
viewPagerImage.adapter =
                    ImageSlidePagerAdapter(this@CommunityDetailActivity, community.images!!){ position ->
                        val intent = Intent(this@CommunityDetailActivity, ViewAllImageActivity::class.java)
                        intent.putExtra(ViewAllImageActivity.TYPE_IMAGE_POSITION, position)
                        intent.putStringArrayListExtra(ViewAllImageActivity.TYPE_IMAGE_LIST, community.images!!)
                        startActivity(intent)

                    }