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
| data class Result(val result: String, val confidence: Float) |
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
| interface Classifier { | |
| fun recognizeImage(bitmap: Bitmap): Result | |
| } |
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
| class MainActivity : AppCompatActivity() { | |
| private lateinit var classifier: Classifier | |
| //other properties | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| checkPermissions() |
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
| object UriHelper { | |
| fun getUriFromFilePath(context: Context, filePath: String): Uri { | |
| val file = File(filePath) | |
| return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | |
| FileProvider.getUriForFile( | |
| context, | |
| context.applicationContext.packageName + ".uri", | |
| file) | |
| } else { |
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
| private const val REQUEST_PERMISSIONS = 1 | |
| private const val REQUEST_TAKE_PICTURE = 2 | |
| class MainActivity : AppCompatActivity() { | |
| private var photoFilePath = "" | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) |
NewerOlder