Skip to content

oshita-n/constructProcessing

Repository files navigation

constructProcessing

Writable Constract HTTP client for Android.

Description

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.

How to use

//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);
}

Lamda version.

@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);
}

Licence

License

Author

Ooshita

About

Writable Constract HTTP client for Android.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages