0

The below code is meant to implement glide on a multiple image uploading app. I am trying to set the variable bitmap1 in the onResourceReady and imageView for reuse in the code (upload) without success.

  @Override
    protected void onActivityResult(int RC, int RQC, Intent I) {
        super.onActivityResult(RC, RQC, I);
        if (RC == 1 && RQC == RESULT_OK && I != null && I.getData() != null) {
            Uri uri = I.getData();
            RequestOptions options = new RequestOptions()
                    .format(DecodeFormat.PREFER_RGB_565)
                    .placeholder(R.drawable.ic_launcher_background)
                    .error(R.drawable.ic_launcher_background);

            Glide.with(this)
                    .setDefaultRequestOptions(options)
                    .load(uri)
                    .centerInside()
                    .into(new CustomTarget<Drawable>(512, 512) {
                        @Override
                        public void onResourceReady(@NonNull Drawable bitmap1, @Nullable Transition<? super Drawable> transition) {
                            imageView1.setImageDrawable(bitmap1);
                        }
                        @Override
                        public void onLoadCleared(@Nullable Drawable placeholder) {}
                    });
        }
Zoe
  • 27,060
  • 21
  • 118
  • 148
NyP
  • 499
  • 4
  • 18

1 Answers1

0

From your comment I understand that you want to upload the image to a server. Well in that case, it really depends what is your API to upload an image to that server.

onResourceReady passes a Drawable which you can convert to whatever type you need. For example (and only for example, unless you want to actually use it), this is the API to upload an image to Firebase: https://firebase.google.com/docs/storage/android/upload-files

Hope this helps!

Gil Becker
  • 283
  • 1
  • 9