Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More friendly Java API support #160

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ proguard/
captures/
# IntelliJ
*.iml
.idea/
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/gradle.xml
# .idea/assetWizardSettings.xml
# .idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
*.jks
Expand Down Expand Up @@ -68,7 +56,4 @@ lint/outputs/
lint/tmp/
# lint/reports/
# MacOS
.DS_Store
# App Specific cases
app/release/output.json
.idea/codeStyles/
.DS_Store
9 changes: 9 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 0 additions & 113 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

40 changes: 0 additions & 40 deletions .idea/jarRepositories.xml

This file was deleted.

31 changes: 0 additions & 31 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ val config = ImagePickerConfig(
launcher.launch(config)
```

Java example: [MainActivity.java](example/src/main/java/com/imagepicker/example/java/MainActivity.java)

## Configuration options

| Option | Description | Default value
Expand Down
15 changes: 1 addition & 14 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ proguard/
captures/
# IntelliJ
*.iml
.idea/
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/gradle.xml
# .idea/assetWizardSettings.xml
# .idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
*.jks
Expand Down Expand Up @@ -70,5 +58,4 @@ lint/tmp/
# MacOS
.DS_Store
# App Specific cases
app/release/output.json
.idea/codeStyles/
release/output.json
20 changes: 0 additions & 20 deletions example/release/output.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.imagepicker.example.java;

import android.app.Activity;
import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import kotlin.jvm.functions.Function0;

public class JvmContextProvider implements Function0<Context> {

@Nullable
private Activity hostAct;
@Nullable
private Fragment hostFrag;

public JvmContextProvider(@NonNull Activity host) {
this.hostAct = host;
}

public JvmContextProvider(@NonNull Fragment host) {
this.hostFrag = host;
}

@Override
public Context invoke() {
if (hostAct != null) {
return hostAct;
} else if (hostFrag != null) {
return hostFrag.requireContext();
} else {
throw new IllegalArgumentException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.imagepicker.example.java;

import com.nguyenhoanglam.imagepicker.model.Image;

import java.util.ArrayList;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;

public interface JvmImagePickerCallback extends Function1<ArrayList<Image>, Unit> {

void onImagePickerResult(ArrayList<Image> images);

@Override
default Unit invoke(ArrayList<Image> images) {
this.onImagePickerResult(images);
return null;
}
}
Loading