Hey I am using sillicompressor for compressing images and now the problem is that it is throwing numberformatException. I tried everything but nothing is working. Please guide me how can i solve this problem.
CODE IS HERE
activityResultLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
if (result.getResultCode() == RESULT_OK && null != result.getData()) {
if (result.getData().getClipData() != null) {
int countofImages = result.getData().getClipData().getItemCount();
//this part is to select multiple images
for (int i = 0; i < countofImages; i++) {
if (imageList.size() < 8)
{
imageuri = result.getData().getClipData().getItemAt(i).getUri();
File file = new File(SiliCompressor.with(getContext()).compress(FileUtils.getPath(getContext(), imageuri), new File(getContext().getCacheDir(), "temp" + i)));
compresseduri = Uri.fromFile(file);
imageList.add(new CustomModel(getfilename(imageuri), compresseduri));
} else
{
Toast.makeText(getContext(), "Can't select more than 8 images", Toast.LENGTH_SHORT).show();
}
}
//then notify the adapter
adapter.notifyDataSetChanged();
rentSell3Binding.totalphotos.setText("Photos (" + imageList.size() + ")");
}
//this part is to select single image
else {
if (imageList.size()<8) {
imageuri = result.getData().getData();
File file = new File(SiliCompressor.with(getContext()).compress(FileUtils.getPath(getContext(), imageuri), new File(getContext().getCacheDir(), "temp")));
compresseduri = Uri.fromFile(file);
imageList.add(new CustomModel(getfilename(imageuri), compresseduri));
}else
{
Toast.makeText(getContext(), "Can't select more than 8 images", Toast.LENGTH_SHORT).show();
}
//notify the adapter
adapter.notifyDataSetChanged();
rentSell3Binding.totalphotos.setText("Photos (" + imageList.size() + ")");
}
}
Error is throwing on this line
File file = new File(SiliCompressor.with(getContext()).compress(FileUtils.getPath(getContext(), imageuri), new File(getContext().getCacheDir(), "temp" + i)));
StackTrace
java.lang.NumberFormatException: For input string: "msf:126968"
at java.lang.Long.parseLong(Long.java:594)
at java.lang.Long.valueOf(Long.java:808)
at com.iceteck.silicompressorr.FileUtils.getPath(FileUtils.java:288)
at com.shrihari.backsoon.Listing_Fragment_3$5.onActivityResult(Listing_Fragment_3.java:263)