stephanenicolas / robospice

Repo of the Open Source Android library : RoboSpice. RoboSpice is a modular android library that makes writing asynchronous long running tasks easy. It is specialized in network requests, supports caching and offers REST requests out-of-the box using extension modules.
Apache License 2.0
2.95k stars 545 forks source link

Sending multiple request, only one result catch #350

Closed WMariusz closed 10 years ago

WMariusz commented 10 years ago

Hey, during send 2 requests, i recieve 2 response but requestListener is call only once

SendResourceRequest request = new SendResourceRequest(b64, filename, SendResourceRequest.PHOTO); ((MainActivity) getActivity()).getSpiceManager().execute(request, new SendResourceRequestListener());

i call it 2 times with different data, but SendResourceRequestListener gives any result only once

public class SendResourceRequestListener implements RequestListener< SendResourceResponse > {

    @Override
    public void onRequestFailure(SpiceException arg0) {
        Utils.PrintError("something wrong during send "+arg0.getMessage());
    }

    @Override
    public void onRequestSuccess(SendResourceResponse response) {
        Utils.PrintInfo("something returned");
        if(response.isSuccess()) {
            photos.add(new Photo(response.getId(), response.getName()));
            Utils.PrintInfo("added photo "+photos.size());
        }else{
            Utils.PrintError("something wrong during send");
        }
    }
}

i hope i explained clearly

WMariusz commented 10 years ago

it was all my fault, i selectes image from other activity and then i started request, so every time i picked image i calles onStop im mainActivity, so i added flag and block SpiceManager.shouldStop() every time i pick image