Skip to content

kimyuhyun/KyhImagePicker2

Repository files navigation

KyhImagePicker2

instagram style image picker

KakaoTalk_Photo_2022-08-09-10-56-40 002 KakaoTalk_Photo_2022-08-09-10-56-39 001

  • The image returns uri path as a cropped shooting image.
dependencyResolutionManagement {
    repositories {
        ...
        maven("https://jitpack.io")
    }
}
dependencies {
    implementation ("com.github.kimyuhyun:KyhImagePicker2:1.0.4")
}
  • Insert the code below into the button to run the image picker.
findViewById<Button>(R.id.btn_open_gallery).setOnClickListener {
    CoroutineScope(Dispatchers.Main).launch {
        val result = KyhImagePicker2.of(this@MainActivity)
            .setTitle("Title")
            .setLimitCount(5)
            .setLimitMessage("Limit")
            .setNoSelectedMessage("no selected")
            .open()
        Log.d("####", "$result")

        if (result != null) {
            for (i in result.indices) {
                when (i) {
                    0 -> findViewById<ImageView>(R.id.iv_0).setImageURI(result[i])
                    1 -> findViewById<ImageView>(R.id.iv_1).setImageURI(result[i])
                    2 -> findViewById<ImageView>(R.id.iv_2).setImageURI(result[i])
                    3 -> findViewById<ImageView>(R.id.iv_3).setImageURI(result[i])
                    4 -> findViewById<ImageView>(R.id.iv_4).setImageURI(result[i])
                }
            }
        }
    }
}