Created
October 15, 2019 13:08
-
-
Save mhd-zulqarnain/208e712008722440923c8c5b1d04d652 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class test extends AppCompatActivity { | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
doWork("paremter", new ServiceListener<String>() { | |
@Override | |
public void success(String obj) { | |
//get the response if success | |
} | |
@Override | |
public void fail(ServiceError error) { | |
//get the error response | |
} | |
}); | |
} | |
private void doWork(String param , ServiceListener<String> serviceListener) { | |
mUpLoadDataService.uploadInspectionData(new UpLoadDataService.UploadCompleteListener() { | |
@Override | |
public void uploadComplete() { | |
serviceListener.success("success"); | |
} | |
@Override | |
public void uploadFailed(String reason) { | |
serviceListener.fail(new ServiceError("Can not Upload")); | |
} | |
}); | |
} | |
public interface ServiceListener<T> { | |
void success(T obj); | |
void fail(ServiceError error); | |
} | |
public class ServiceError { | |
public Throwable errorObject; | |
public String message; | |
public ServiceError(){ | |
message = ""; | |
} | |
public ServiceError(String message){ | |
this.message = message; | |
} | |
public ServiceError(String message, Throwable errorObject){ | |
this.message = message; | |
this.errorObject = errorObject; | |
} | |
public Object getErrorObject() { | |
return errorObject; | |
} | |
public void setErrorObject(Throwable errorObject) { | |
this.errorObject = errorObject; | |
} | |
public String getMessage() { | |
return message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment