abhishekti7 / UnicornFilePicker

:eyes: A simple, documented, and contribution-friendly File Picker for Android.
Apache License 2.0
69 stars 13 forks source link

REQUEST_CODE_CHOOSE constant unresolved in Kotlin translation #2

Closed bettinasmid closed 3 years ago

bettinasmid commented 3 years ago

Hi, I'm writing my program in Kotlin, so I had it translated by AndroidStudio, but the IDE cannot recognize this constant. Where do I find the declaration? The Kotlin adaptation of the function is below:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == _REQUEST_CODECHOOSE && resultCode == RESULT_OK) { val files = data?.getStringArrayListExtra("filePaths") for (file in files!!) { Log.e("tag",file) } } }

Thanks a lot in advance!

abhishekti7 commented 3 years ago

If you look at the function in the file MainActivity.java, the constant is actually named as _REQ_UNICORNFILE which is defined in the file Constants.java

Just replace the variable REQUEST_CODE_CHOOSE in your kotlin code with REQ_UNICORN_FILE ( don't forget to import the variable).

bettinasmid commented 3 years ago

Thanks a lot! Then the description in the Readme might be inaccurate? image

abhishekti7 commented 3 years ago

Actually, the request code in the readme demonstrates that you can put whatever integer constant you want in place. Glad I could be of help. I will be closing this issue now. Thank you.