1

Get Image URL from Fresco SimpleDraweeView.

I have recyclerView items with EditText and SimpleDraweeView, also have on the button on my activity. on button click, I want to get whole recyclerview items data into ArrayList.

Here is the code which written on button click and i successfully got editText data except SimpleDraweeView URL.

        ArrayList<ContactUs> getContactUsArrayList = new ArrayList<>();
    for (int i = 0; i < getContactUsArrayList.size(); i++) {
        View view = rvContact.getChildAt(i);
        EditText etName = (EditText) view.findViewById(R.id.etName);
        EditText etMobile = (EditText) view.findViewById(R.id.etMobile);
        SimpleDraweeView sdvImage = (SimpleDraweeView) view.findViewById(R.id.sdvImage);

        String strName = etName.getText().toString();
        String strNumber = etMobile.getText().toString();
        String strImgUrl = ""; //what is the property?


    }

What is the property for getting URL from SimpleDraweeView?

Arbaz.in
  • 1,478
  • 2
  • 19
  • 41

3 Answers3

0

You have to parse your image URL like this.

SimpleDraweeView simpleDraweeView = 
(SimpleDraweeView)findViewById(R.id.simpleviewid);

Uri imageuri = Uri.parse("YOUR IMAGE URL");
simpleDraweeView.setImageURI(imageuri);

Make sure to initialize fresco before setContentView(), and width and height in XML file of simpleDraweeView must not be wrap content. Try this.

It works for me.

Jaymin
  • 2,879
  • 3
  • 19
  • 35
0

I understood your question but there is not any properties to get the image in the form of String but you can achieve this by something like below. I assume if you set your image in layout correctly.

Drawable drawable = draweeView.getBackground();
        Bitmap bitmap = draweeView.getDrawingCache();
        Drawable drawable1 = draweeView.getHierarchy().getTopLevelDrawable();

Hope it helps.

  • As i see above comments you should have to save the list of load data or which list you have passed in the adapter to load the data in the recycle view, you can use the same list to get the image url according to the position in onBindViewHolder method. – Mohit Arora Nov 30 '18 at 05:58
0

I got Solution based on Answers and comments

What i have done

Replace This code

        ArrayList<ContactUs> getContactUsArrayList = new ArrayList<>();
    for (int i = 0; i < getContactUsArrayList.size(); i++) {
        View view = rvContact.getChildAt(i);
        EditText etName = (EditText) view.findViewById(R.id.etName);
        EditText etMobile = (EditText) view.findViewById(R.id.etMobile);
        SimpleDraweeView sdvImage = (SimpleDraweeView) view.findViewById(R.id.sdvImage);

        String strName = etName.getText().toString();
        String strNumber = etMobile.getText().toString();
        String strImgUrl = ""; //what is the property?


    }

With This code

   ArrayList<ContactUs> getContactUsArrayList = new ArrayList<>();
    ContactUs contactUs;
    for (int i = 0; i < getContactUsArrayList.size(); i++) {
        contactUs = getContactUsArrayList.get(i);//Here i got whole object.
        String strName = contactUs.getUserName();
        String strNumber = contactUs.getUserMobile();
        String strImgUrl=contactUs.getImagePath();

    }
Arbaz.in
  • 1,478
  • 2
  • 19
  • 41