Writable Constract HTTP client for Android.
Normal network processing is used try catch sentence.
But it is difficult to understand and complex.
constructProcessing is construct network processing.
2 pattern attribute.onSuccess is network process,When success.onError is network process,When failure.
//add gradle(app)
repositories {
maven { url 'http://raw.github.com/Ooshita/constructProcessing/master/repository/' }
}
dependencies {
compile 'com.whispon:constructprocessing:1.0.0'
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ProgressBar progressBar = (ProgressBar)findViewById(R.id.progressBar);
CPHttp cpHttp = new CPHttp();
cpHttp.get("http://whispon.com", new OnSuccess() {
@Override
public void onSuccess(String response) {
Log.d("success", response);
}
}, new OnFailure() {
@Override
public void onFailure(NetworkException e) {
Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show();
}
}, progressBar);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ProgressBar progressBar = (ProgressBar)findViewById(R.id.progressBar);
CPHttp cpHttp = new CPHttp();
cpHttp.get("http://whispon.com", (String response) -> Log.d("success", response)
, (NetworkException e) -> Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show(), progressBar);
}