This file contains 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 fun pickImage() { | |
val intent = Intent() | |
intent.type = "image/*" | |
intent.action = Intent.ACTION_GET_CONTENT | |
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE) | |
} |
This file contains 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
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
if (resultCode != RESULT_CANCELED) { | |
if (requestCode == PICK_IMAGE) { | |
data?.data?.let { | |
bitmap = null | |
bitmap = getBitmapFromUri(it) | |
Glide.with(this) | |
.load(bitmap) |
This file contains 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 fun camera(){ | |
val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) | |
if (takePictureIntent.resolveActivity( | |
packageManager | |
) != null | |
) { | |
var photoFile: File? = null | |
try { | |
photoFile = createImageFile() | |
} catch (ex: IOException) { |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<ImageView | |
android:id="@+id/text_image" |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<paths xmlns:android="http://schemas.android.com/apk/res/android"> | |
<external-path name="my_images" path="Android/data/com.ibrahim.mlkit/files/Pictures" /> | |
</paths> |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.ibrahim.mlkit"> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" | |
android:maxSdkVersion="18"/> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
<uses-feature | |
android:name="android.hardware.camera" |
This file contains 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
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.3' | |
implementation 'com.github.bumptech.glide:glide:4.11.0' | |
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' |
This file contains 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 viewPager : ViewPager | |
private lateinit var adapter: Adapter | |
private lateinit var model: MutableList<ViewPagerModel> | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
model = ArrayList<ViewPagerModel>() |
This file contains 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
model = ArrayList<ViewPagerModel>() | |
viewPager = findViewById(R.id.viewPager) | |
adapter = Adapter(model as ArrayList<ViewPagerModel>, applicationContext) | |
viewPager.adapter = adapter | |
request() | |
} |
This file contains 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 lateinit var viewPager : ViewPager | |
private lateinit var adapter: Adapter | |
private lateinit var model: MutableList<ViewPagerModel> |