forked from esafirm/android-image-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor launcher * sample now use view binding * fix test compile
- Loading branch information
Showing
12 changed files
with
172 additions
and
161 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
package com.esafirm.sample | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import com.bumptech.glide.Glide | ||
import com.esafirm.imagepicker.features.ImagePickerConfig | ||
import com.esafirm.imagepicker.features.ImagePickerMode | ||
import com.esafirm.imagepicker.features.ReturnMode | ||
import com.esafirm.imagepicker.features.registerImagePicker | ||
import kotlinx.android.synthetic.main.fragment_main.* | ||
import com.esafirm.sample.databinding.FragmentMainBinding | ||
|
||
class MainFragment : Fragment() { | ||
class MainFragment : Fragment(R.layout.fragment_main) { | ||
|
||
private val startImagePicker = registerImagePicker { | ||
private lateinit var binding: FragmentMainBinding | ||
|
||
private val imagePickerLauncher = registerImagePicker { | ||
val firstImage = it.firstOrNull() ?: return@registerImagePicker | ||
Glide.with(img_fragment) | ||
Glide.with(binding.imgFragment) | ||
.load(firstImage.uri) | ||
.into(img_fragment) | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_main, container, false) | ||
.into(binding.imgFragment) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
button_pick_fragment.setOnClickListener { | ||
startImagePicker(ImagePickerConfig { | ||
mode = ImagePickerMode.SINGLE | ||
returnMode = ReturnMode.ALL // set whether pick action or camera action should return immediate result or not. Only works in single mode for image picker | ||
isFolderMode = true // set folder mode (false by default) | ||
folderTitle = "Folder" // folder selection title | ||
imageTitle = "Tap to select" // image selection title | ||
doneButtonText = "DONE" // done button text | ||
}) | ||
binding = FragmentMainBinding.bind(view) | ||
|
||
binding.buttonPickFragment.setOnClickListener { | ||
imagePickerLauncher.launch( | ||
ImagePickerConfig { | ||
mode = ImagePickerMode.SINGLE | ||
returnMode = ReturnMode.ALL // set whether pick action or camera action should return immediate result or not. Only works in single mode for image picker | ||
isFolderMode = true // set folder mode (false by default) | ||
folderTitle = "Folder" // folder selection title | ||
imageTitle = "Tap to select" // image selection title | ||
doneButtonText = "DONE" // done button text | ||
} | ||
) | ||
} | ||
|
||
button_close.setOnClickListener { | ||
fragmentManager?.beginTransaction() | ||
?.remove(this@MainFragment) | ||
?.commitAllowingStateLoss() | ||
binding.buttonClose.setOnClickListener { | ||
parentFragmentManager.beginTransaction() | ||
.remove(this@MainFragment) | ||
.commitAllowingStateLoss() | ||
} | ||
} | ||
} |
Oops, something went wrong.