Home

Awesome

Aster for Android

License API Download Readme Wiki-Guide

Aster is a network request library for android, supporting HttpURLConnection, Volley, OkHttp3, Retrofit2 as HTTP client.

Set up

Maven:

<dependency>
  <groupId>com.dsiner.lib</groupId>
  <artifactId>aster</artifactId>
  <version>2.1.0</version>
</dependency>

or Gradle:

    implementation 'com.dsiner.lib:aster:2.1.0'
    implementation 'com.dsiner.lib:aster-adapter-http:2.1.0'
    implementation 'com.dsiner.lib:aster-adapter-okhttp3:2.1.0'
    implementation 'com.dsiner.lib:aster-adapter-retrofit:2.1.0'

or Gradle(OkHttp3 lite):

    implementation 'com.dsiner.lib:aster:2.1.0'
    implementation 'com.dsiner.lib:aster-adapter-okhttp3:2.1.0'

or Gradle(Retrofit2 lite):

    implementation 'com.dsiner.lib:aster:2.1.0'
    implementation 'com.dsiner.lib:aster-adapter-okhttp3:2.1.0'
    implementation 'com.dsiner.lib:aster-adapter-retrofit:2.1.0'

or Gradle(HttpURLConnection lite):

    implementation 'com.dsiner.lib:aster:2.1.0'
    implementation 'com.dsiner.lib:aster-adapter-http:2.1.0'

Integration libraries

Features

Support

How do I use Aster?

Simple use cases will look something like this:

        Params params = new Params("https://api.douban.com/v2/movie/top250");
        params.addParam("start", "0");
        params.addParam("count", "10");
        Aster.get(params.rtp, params)
                .request(new SimpleCallback<MovieInfo>() {
                    @Override
                    public void onSuccess(MovieInfo response) {
                        ...do something in main thread
                    }

                    @Override
                    public void onError(Throwable e) {
                        ...do something in main thread
                    }
                });

Download:

        Aster.download(url)
                .connectTimeout(60 * 1000)
                .readTimeout(60 * 1000)
                .writeTimeout(60 * 1000)
                .retryCount(3)
                .retryDelayMillis(1000)
                .tag(url)
                .request(path, name, new ProgressCallback() {
                    @Override
                    public void onStart() {}

                    @Override
                    public void onProgress(long currentLength, long totalLength) {}

                    @Override
                    public void onSuccess() {}

                    @Override
                    public void onError(Throwable e) {}

                    @Override
                    public void onCancel() {}
                });

Upload:

        Aster.upload(url)
                .connectTimeout(60 * 1000)
                .readTimeout(60 * 1000)
                .writeTimeout(60 * 1000)
                .retryCount(3)
                .retryDelayMillis(1000)
                .addImageFile("file", file.getName(), file)
                .request(new UploadCallback<String>() {
                             @Override
                             public void onStart() {}

                             @Override
                             public void onProgress(long currentLength, long totalLength) {}

                             @Override
                             public void onSuccess() {}

                             @Override
                             public void onSuccess(String response) {}

                             @Override
                             public void onError(Throwable e) {}

                             @Override
                             public void onCancel() {}
                         }
                );

More usage see Wiki.

Latest Changes

Licence

Copyright 2017 D

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.