/** * for fetching the data * * @throws RequestRepeatException if the request to download the image is already present in the * queue or is downloading. * @return object -- returns string */ public Object send() throws RequestRepeatException { if (Util.isInternetAvailable()) { isRepeatRequest = false; // checking again if this request is already duplicated for previous one is completed or not. // if not completed it will be "duplicated" request hence isRepeatRequest will be true. // else isRepeatRequest will become true. if (isRepeatRequest) { // checks for duplicate request completion setIsRepeatRequest(); } if (!isRepeatRequest) { // get downloaded data Object obj = sendRequest(); // removes this instance from the list to tell the future request that its been completed. Util.removeHttRequest(this); return obj; } else { throw new RequestRepeatException("Request already in queue"); } } else { if (this.METHOD_TYPE != Constants.IMAGE_METHOD) { Util.showToast("Network not available"); } return null; } }