Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.francescopedronomnys:PickImage:2.0.1'
}
dependencies {
implementation("com.github.francescopedronomnys:PickImage:2.0.1")
}
<dependency>
<groupId>com.github.francescopedronomnys</groupId>
<artifactId>PickImage</artifactId>
<version>2.0.1</version>
</dependency>
libraryDependencies += "com.github.francescopedronomnys" % "PickImage" % "2.0.1"
:dependencies [[com.github.francescopedronomnys/PickImage "2.0.1"]]
This class was created to use in Android projects.
Shows a DialogFragment with Camera or Gallery options. The user can choose from where provider wants to pick an image.
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
compile 'com.github.jrvansuita:PickImage:v2.0.1'
}
You can take a look at the sample app located on this project.
PickImageDialog.on(MainActivity.this, new PickSetup());
//or
PickImageDialog.on(getSupportFragmentManager(), new PickSetup());
@Override
public void onPickResult(PickResult r) {
if (r.getError() == null) {
ImageView imageView = ((ImageView) findViewById(R.id.result_image));
//If you want the Bitmap.
imageView.setImageBitmap(r.getBitmap());
//If you want the Uri.
//Mandatory to refresh image from Uri.
imageView.setImageURI(null);
//Setting the real returned image.
imageView.setImageURI(r.getUri());
//Image path.
r.getPath();
} else {
//Handle possible errors
//TODO: do what you have to do with r.getError();
}
}
PickImageDialog.on(getSupportFragmentManager(), new IPickResult() {
@Override
public void onPickResult(PickResult r) {
//TODO: do what you have to...
}
});
PickImageDialog.on(getSupportFragmentManager())
.setOnPickResult(new IPickResult() {
@Override
public void onPickResult(PickResult r) {
//TODO: do what you have to...
}
});
PickSetup setup = new PickSetup();
setup.setBackgroundColor(yourColor);
setup.setTitle(yourTitle);
setup.setDimAmount(yourFloat);
setup.setTitleColor(yourColor);
setup.setFlip(true);
setup.setCancelText("Test");
setup.setImageSize(500);
setup.setPickTypes(EPickTypes.GALERY, EPickTypes.CAMERA);
setup.setProgressText("Loading...");
setup.setProgressTextColor(Color.BLUE);
If you want to write your own pick images functionalities, your class have to implements IPickClick like in the example below. You may want to take a look at the sample app.
@Override
public void onGalleryClick() {
//TODO: Your onw implementation
}
@Override
public void onCameraClick() {
//TODO: Your onw implementation
}
PickImageDialog dialog = PickImageDialog.on(...);
dialog.dismiss();
See the LICENSE. file for license rights and limitations (MIT).