JessYanCoding / ProgressManager
- вторник, 13 июня 2017 г. в 03:12:41
Java
Listen the progress of downloading and uploading in Okhttp (compatible Retrofit and Glide).
ProgressManager a line of code to listen App all the links and upload the progress of the network, including Glide picture loading progress, to achieve the principle of similar EventBus, you can be in anywhere in App, the number of listeners to Url address as an identifier, registered to the framework, when this Url address haves to download or upload the action, the framework will take the initiative to call All listeners registered with this Url address are synchronized to multiple modules.
compile 'me.jessyan:progressmanager:1.2.3'
// When building OkHttpClient, the OkHttpClient.Builder() is passed to the with() method to initialize the configuration
OkHttpClient = ProgressManager.getInstance().with(new OkHttpClient.Builder())
.build();
// Glide load
ProgressManager.getInstance().addResponseListener(IMAGE_URL, getGlideListener());
// Okhttp/Retofit download
ProgressManager.getInstance().addResponseListener(DOWNLOAD_URL, getDownloadListener());
// Okhttp/Retofit upload
ProgressManager.getInstance().addRequestLisenter(UPLOAD_URL, getUploadListener());
-keep class me.jessyan.progressmanager.** { *; }
-keep interface me.jessyan.progressmanager.** { *; }
Copyright 2017, jessyan
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.