Skip to content

Instantly share code, notes, and snippets.

@erdalkaymak
Created January 25, 2021 08:29
Show Gist options
  • Select an option

  • Save erdalkaymak/d20478d05c7d6565b4a0a8f70a81eb5f to your computer and use it in GitHub Desktop.

Select an option

Save erdalkaymak/d20478d05c7d6565b4a0a8f70a81eb5f to your computer and use it in GitHub Desktop.
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
MLApplication.getInstance().apiKey = ""
val adapterTo = ArrayAdapter(this, android.R.layout.simple_spinner_item, toLanguageList)
toSpinner.adapter = adapterTo
toSpinner.onItemSelectedListener = object :
AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
languageCode=setLanguage(toLanguageList[position])
if(isEntered){
detectedText?.let { detectAndTranslateLanguage(it, txt_translation,
languageCode!!,applicationContext
) }
}
}
override fun onNothingSelected(parent: AdapterView<*>) {
}
}
take_picture_icon.setOnClickListener {
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(arrayOf(Manifest.permission.CAMERA), myCameraRequestCode)
} else {
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(intent, 100)
}
}
pick_image_icon.setOnClickListener {
if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
myStorageRequestCode
)
} else {
val intent = Intent(
Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI
)
startActivityForResult(intent, 200)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment