BottomSheet Image Picker












0















I have a project that requires some images to be uploaded. I have done it successfully, but the user has to click 6 buttons to get 6 images on the screen. Not very efficient, so I asked around and I was told to use imagepicker.



I have implemented this https://github.com/siralam/BSImagePicker and it makes everything easy, but I am really struggling(no clue) on how to get those image to upload to storage and have the path stored in database.



The way I know it is to get the mimage1Uri = data.getData(); on the onActivityResult.



Could someone help me get the uri?



I apologize if you find this question too much of a burden.



public class PostFragment extends Fragment implements BSImagePicker.OnMultiImageSelectedListener {

private ImageView ivImage1, ivImage2, ivImage3, ivImage4, ivImage5, ivImage6;
private EditText mTitle, mDescription, mPrice, mCountry, mStateProvince, mCity, mContactEmail;
private Button mPost;
private ProgressBar mProgressBar;
private double mProgress = 0;
private Uri mSelectedUri;
private Uri mSelectedUri1;
private byte mUploadBytes;


@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = inflater.inflate(R.layout.fragment_post, container, false);
ivImage1 = view.findViewById(R.id.iv_image1);
ivImage2 = view.findViewById(R.id.iv_image2);
ivImage3 = view.findViewById(R.id.iv_image3);
ivImage4 = view.findViewById(R.id.iv_image4);
ivImage5 = view.findViewById(R.id.iv_image5);
ivImage6 = view.findViewById(R.id.iv_image6);
mTitle = view.findViewById(R.id.input_title);


getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);


view.findViewById(R.id.tv_multi_selection).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BSImagePicker pickerDialog = new BSImagePicker.Builder("")
.setMaximumDisplayingImages(Integer.MAX_VALUE)
.isMultiSelect()
.setMinimumMultiSelectCount(3)
.setMaximumMultiSelectCount(6)
.build();
pickerDialog.show(getChildFragmentManager(), "picker");
}
});

startPosting();

return view;
}
public void onMultiImageSelected(List<Uri> uriList, String tag) {
for (int i = 0; i < uriList.size(); i++) {

if (i >= 6) return;
ImageView iv;
switch (i) {
case 0:
iv = ivImage1;

break;
case 1:
iv = ivImage2;
break;
case 2:
iv = ivImage3;
break;
case 3:
iv = ivImage4;
break;
case 4:
iv = ivImage5;
break;
case 5:
default:
iv = ivImage6;
}
Glide.with(this).load(uriList.get(i)).into(iv);









share|improve this question





























    0















    I have a project that requires some images to be uploaded. I have done it successfully, but the user has to click 6 buttons to get 6 images on the screen. Not very efficient, so I asked around and I was told to use imagepicker.



    I have implemented this https://github.com/siralam/BSImagePicker and it makes everything easy, but I am really struggling(no clue) on how to get those image to upload to storage and have the path stored in database.



    The way I know it is to get the mimage1Uri = data.getData(); on the onActivityResult.



    Could someone help me get the uri?



    I apologize if you find this question too much of a burden.



    public class PostFragment extends Fragment implements BSImagePicker.OnMultiImageSelectedListener {

    private ImageView ivImage1, ivImage2, ivImage3, ivImage4, ivImage5, ivImage6;
    private EditText mTitle, mDescription, mPrice, mCountry, mStateProvince, mCity, mContactEmail;
    private Button mPost;
    private ProgressBar mProgressBar;
    private double mProgress = 0;
    private Uri mSelectedUri;
    private Uri mSelectedUri1;
    private byte mUploadBytes;


    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_post, container, false);
    ivImage1 = view.findViewById(R.id.iv_image1);
    ivImage2 = view.findViewById(R.id.iv_image2);
    ivImage3 = view.findViewById(R.id.iv_image3);
    ivImage4 = view.findViewById(R.id.iv_image4);
    ivImage5 = view.findViewById(R.id.iv_image5);
    ivImage6 = view.findViewById(R.id.iv_image6);
    mTitle = view.findViewById(R.id.input_title);


    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);


    view.findViewById(R.id.tv_multi_selection).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    BSImagePicker pickerDialog = new BSImagePicker.Builder("")
    .setMaximumDisplayingImages(Integer.MAX_VALUE)
    .isMultiSelect()
    .setMinimumMultiSelectCount(3)
    .setMaximumMultiSelectCount(6)
    .build();
    pickerDialog.show(getChildFragmentManager(), "picker");
    }
    });

    startPosting();

    return view;
    }
    public void onMultiImageSelected(List<Uri> uriList, String tag) {
    for (int i = 0; i < uriList.size(); i++) {

    if (i >= 6) return;
    ImageView iv;
    switch (i) {
    case 0:
    iv = ivImage1;

    break;
    case 1:
    iv = ivImage2;
    break;
    case 2:
    iv = ivImage3;
    break;
    case 3:
    iv = ivImage4;
    break;
    case 4:
    iv = ivImage5;
    break;
    case 5:
    default:
    iv = ivImage6;
    }
    Glide.with(this).load(uriList.get(i)).into(iv);









    share|improve this question



























      0












      0








      0








      I have a project that requires some images to be uploaded. I have done it successfully, but the user has to click 6 buttons to get 6 images on the screen. Not very efficient, so I asked around and I was told to use imagepicker.



      I have implemented this https://github.com/siralam/BSImagePicker and it makes everything easy, but I am really struggling(no clue) on how to get those image to upload to storage and have the path stored in database.



      The way I know it is to get the mimage1Uri = data.getData(); on the onActivityResult.



      Could someone help me get the uri?



      I apologize if you find this question too much of a burden.



      public class PostFragment extends Fragment implements BSImagePicker.OnMultiImageSelectedListener {

      private ImageView ivImage1, ivImage2, ivImage3, ivImage4, ivImage5, ivImage6;
      private EditText mTitle, mDescription, mPrice, mCountry, mStateProvince, mCity, mContactEmail;
      private Button mPost;
      private ProgressBar mProgressBar;
      private double mProgress = 0;
      private Uri mSelectedUri;
      private Uri mSelectedUri1;
      private byte mUploadBytes;


      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      View view = inflater.inflate(R.layout.fragment_post, container, false);
      ivImage1 = view.findViewById(R.id.iv_image1);
      ivImage2 = view.findViewById(R.id.iv_image2);
      ivImage3 = view.findViewById(R.id.iv_image3);
      ivImage4 = view.findViewById(R.id.iv_image4);
      ivImage5 = view.findViewById(R.id.iv_image5);
      ivImage6 = view.findViewById(R.id.iv_image6);
      mTitle = view.findViewById(R.id.input_title);


      getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);


      view.findViewById(R.id.tv_multi_selection).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      BSImagePicker pickerDialog = new BSImagePicker.Builder("")
      .setMaximumDisplayingImages(Integer.MAX_VALUE)
      .isMultiSelect()
      .setMinimumMultiSelectCount(3)
      .setMaximumMultiSelectCount(6)
      .build();
      pickerDialog.show(getChildFragmentManager(), "picker");
      }
      });

      startPosting();

      return view;
      }
      public void onMultiImageSelected(List<Uri> uriList, String tag) {
      for (int i = 0; i < uriList.size(); i++) {

      if (i >= 6) return;
      ImageView iv;
      switch (i) {
      case 0:
      iv = ivImage1;

      break;
      case 1:
      iv = ivImage2;
      break;
      case 2:
      iv = ivImage3;
      break;
      case 3:
      iv = ivImage4;
      break;
      case 4:
      iv = ivImage5;
      break;
      case 5:
      default:
      iv = ivImage6;
      }
      Glide.with(this).load(uriList.get(i)).into(iv);









      share|improve this question
















      I have a project that requires some images to be uploaded. I have done it successfully, but the user has to click 6 buttons to get 6 images on the screen. Not very efficient, so I asked around and I was told to use imagepicker.



      I have implemented this https://github.com/siralam/BSImagePicker and it makes everything easy, but I am really struggling(no clue) on how to get those image to upload to storage and have the path stored in database.



      The way I know it is to get the mimage1Uri = data.getData(); on the onActivityResult.



      Could someone help me get the uri?



      I apologize if you find this question too much of a burden.



      public class PostFragment extends Fragment implements BSImagePicker.OnMultiImageSelectedListener {

      private ImageView ivImage1, ivImage2, ivImage3, ivImage4, ivImage5, ivImage6;
      private EditText mTitle, mDescription, mPrice, mCountry, mStateProvince, mCity, mContactEmail;
      private Button mPost;
      private ProgressBar mProgressBar;
      private double mProgress = 0;
      private Uri mSelectedUri;
      private Uri mSelectedUri1;
      private byte mUploadBytes;


      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      View view = inflater.inflate(R.layout.fragment_post, container, false);
      ivImage1 = view.findViewById(R.id.iv_image1);
      ivImage2 = view.findViewById(R.id.iv_image2);
      ivImage3 = view.findViewById(R.id.iv_image3);
      ivImage4 = view.findViewById(R.id.iv_image4);
      ivImage5 = view.findViewById(R.id.iv_image5);
      ivImage6 = view.findViewById(R.id.iv_image6);
      mTitle = view.findViewById(R.id.input_title);


      getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);


      view.findViewById(R.id.tv_multi_selection).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      BSImagePicker pickerDialog = new BSImagePicker.Builder("")
      .setMaximumDisplayingImages(Integer.MAX_VALUE)
      .isMultiSelect()
      .setMinimumMultiSelectCount(3)
      .setMaximumMultiSelectCount(6)
      .build();
      pickerDialog.show(getChildFragmentManager(), "picker");
      }
      });

      startPosting();

      return view;
      }
      public void onMultiImageSelected(List<Uri> uriList, String tag) {
      for (int i = 0; i < uriList.size(); i++) {

      if (i >= 6) return;
      ImageView iv;
      switch (i) {
      case 0:
      iv = ivImage1;

      break;
      case 1:
      iv = ivImage2;
      break;
      case 2:
      iv = ivImage3;
      break;
      case 3:
      iv = ivImage4;
      break;
      case 4:
      iv = ivImage5;
      break;
      case 5:
      default:
      iv = ivImage6;
      }
      Glide.with(this).load(uriList.get(i)).into(iv);






      android firebase firebase-realtime-database firebase-storage






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '18 at 6:43









      PradyumanDixit

      2,1772819




      2,1772819










      asked Nov 25 '18 at 4:43









      Sifaks AgizulSifaks Agizul

      2817




      2817
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Sounds a simple as...



          public void onMultiImageSelected(List<Uri> uriList, String tag) { 
          for (int i = 0; i < uriList.size(); i++) {
          Uri image = uriList.get(i);
          // Do something with Uri of this image
          }
          }





          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464715%2fbottomsheet-image-picker%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Sounds a simple as...



            public void onMultiImageSelected(List<Uri> uriList, String tag) { 
            for (int i = 0; i < uriList.size(); i++) {
            Uri image = uriList.get(i);
            // Do something with Uri of this image
            }
            }





            share|improve this answer






























              1














              Sounds a simple as...



              public void onMultiImageSelected(List<Uri> uriList, String tag) { 
              for (int i = 0; i < uriList.size(); i++) {
              Uri image = uriList.get(i);
              // Do something with Uri of this image
              }
              }





              share|improve this answer




























                1












                1








                1







                Sounds a simple as...



                public void onMultiImageSelected(List<Uri> uriList, String tag) { 
                for (int i = 0; i < uriList.size(); i++) {
                Uri image = uriList.get(i);
                // Do something with Uri of this image
                }
                }





                share|improve this answer















                Sounds a simple as...



                public void onMultiImageSelected(List<Uri> uriList, String tag) { 
                for (int i = 0; i < uriList.size(); i++) {
                Uri image = uriList.get(i);
                // Do something with Uri of this image
                }
                }






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 25 '18 at 6:43









                PradyumanDixit

                2,1772819




                2,1772819










                answered Nov 25 '18 at 4:59









                lionscribelionscribe

                2,0831613




                2,0831613
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53464715%2fbottomsheet-image-picker%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    TypeError: fit_transform() missing 1 required positional argument: 'X'