Issue
I have a requirement where there is a dynamic form with different types like take edittext, upload image etc.
The issue I am facing is while iterating thru all cases I have to upload image to server and get that url before moving to next type. And at last post form data to server.
I tried putting all code in thread:
new Thread(new Runnable() {
@Override
public void run() {
//Code below with for loop
}
}).start();
Also upload image is in asnctask
for (int fieldIndex = 0; fieldIndex < section.getFields().size(); fieldIndex++) {
switch (field.getType()) {
case ("TextField"):
//take data
break;
case ("Number"):
//take data
break;
case ("image"):
// UPLOAD to server and get that url in Asynctask
break;
} fieldIndex++;
}
// Once for loop done upload all data witb image url to server
But it's not waiting for image URL but iterating the loop and if its not incremented, then upload image function call again.
Solution
You can first find image from list and upload to server, after successful upload response save image url. Then get all data using for loop and upload all data to server with image url.
Answered By - Jignesh Mayani
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.