Skip to content

Commit

Permalink
added fragment to test
Browse files Browse the repository at this point in the history
  • Loading branch information
HashirRajah committed Feb 14, 2024
1 parent 714b168 commit 28d5366
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<config-file target="res/xml/config.xml" parent="/*">
<feature name="ImagePicker">
<param name="android-package" value="com.spoon.imagepicker.ImagePicker"/>
<param name="onload" value="true" />
</feature>
</config-file>

Expand All @@ -106,7 +107,9 @@

<framework src="com.android.support:appcompat-v7:27.1.1" />
<framework src="androidx.activity:activity:1.7.+" />
<framework src="androidx.fragment:fragment:1.6.2" />

<source-file src="src/android/ImagePicker.java" target-dir="src/com/spoon/imagepicker" />
<source-file src="src/android/ImagePickerFragment.java" target-dir="src/com/spoon/imagepicker" />
</platform>
</plugin>
34 changes: 34 additions & 0 deletions src/android/ImagePickerFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.spoon.imagepicker;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.PickVisualMediaRequest;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.sharinpix.SharinPix.MainActivity;

public class ImagePickerFragment extends Fragment {
private ActivityResultLauncher<PickVisualMediaRequest> pickMultipleMedia;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.pickMultipleMedia =
registerForActivityResult(new ActivityResultContracts.PickMultipleVisualMedia(5), uris -> {
// Callback is invoked after the user selects media items or closes the
// photo picker.
if (!uris.isEmpty()) {
Log.d("PhotoPicker", "Number of items selected: " + uris.size());
} else {
Log.d("PhotoPicker", "No media selected");
}
});
this.pickMultipleMedia.launch(new PickVisualMediaRequest.Builder()
.setMediaType(ActivityResultContracts.PickVisualMedia.ImageAndVideo.INSTANCE)
.build());
}
}

0 comments on commit 28d5366

Please sign in to comment.