Created
January 25, 2021 08:29
-
-
Save erdalkaymak/d20478d05c7d6565b4a0a8f70a81eb5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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