本文整理汇总了Java中com.androidnetworking.interfaces.DownloadProgressListener类的典型用法代码示例。如果您正苦于以下问题:Java DownloadProgressListener类的具体用法?Java DownloadProgressListener怎么用?Java DownloadProgressListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DownloadProgressListener类属于com.androidnetworking.interfaces包,在下文中一共展示了DownloadProgressListener类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDownloadProgressListener
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public DownloadProgressListener getDownloadProgressListener() {
return new DownloadProgressListener() {
@Override
public void onProgress(final long bytesDownloaded, final long totalBytes) {
if (mDownloadProgressListener != null && !isCancelled) {
mDownloadProgressListener.onProgress(bytesDownloaded, totalBytes);
}
}
};
}
示例2: downloadFile
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public void downloadFile(final View view) {
String url = "http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP";
RxAndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), "file1.zip")
.build()
.setAnalyticsListener(new AnalyticsListener() {
@Override
public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {
Log.d(TAG, " timeTakenInMillis : " + timeTakenInMillis);
Log.d(TAG, " bytesSent : " + bytesSent);
Log.d(TAG, " bytesReceived : " + bytesReceived);
Log.d(TAG, " isFromCache : " + isFromCache);
}
})
.setDownloadProgressListener(new DownloadProgressListener() {
@Override
public void onProgress(long bytesDownloaded, long totalBytes) {
Log.d(TAG, "bytesDownloaded : " + bytesDownloaded + " totalBytes : " + totalBytes);
Log.d(TAG, "setDownloadProgressListener isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
})
.getDownloadObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<String>() {
@Override
public void onCompleted() {
Log.d(TAG, "File download Completed");
Log.d(TAG, "onDownloadComplete isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
@Override
public void onError(Throwable e) {
if (e instanceof ANError) {
ANError anError = (ANError) e;
if (anError.getErrorCode() != 0) {
// received ANError from server
// error.getErrorCode() - the ANError code from server
// error.getErrorBody() - the ANError body from server
// error.getErrorDetail() - just a ANError detail
Log.d(TAG, "onError errorCode : " + anError.getErrorCode());
Log.d(TAG, "onError errorBody : " + anError.getErrorBody());
Log.d(TAG, "onError errorDetail : " + anError.getErrorDetail());
} else {
// error.getErrorDetail() : connectionError, parseError, requestCancelledError
Log.d(TAG, "onError errorDetail : " + anError.getErrorDetail());
}
} else {
Log.d(TAG, "onError errorMessage : " + e.getMessage());
}
}
@Override
public void onNext(String s) {
Log.d(TAG, "onNext : " + s);
}
});
}
示例3: DownloadProgressHandler
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public DownloadProgressHandler(DownloadProgressListener downloadProgressListener) {
super(Looper.getMainLooper());
mDownloadProgressListenerWeakRef = downloadProgressListener;
}
示例4: ResponseProgressBody
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public ResponseProgressBody(ResponseBody responseBody, DownloadProgressListener downloadProgressListener) {
this.mResponseBody = responseBody;
if (downloadProgressListener != null) {
this.downloadProgressHandler = new DownloadProgressHandler(downloadProgressListener);
}
}
示例5: setDownloadProgressListener
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public T setDownloadProgressListener(DownloadProgressListener downloadProgressListener) {
this.mDownloadProgressListener = downloadProgressListener;
return (T) this;
}
示例6: downloadFile
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public void downloadFile(final View view) {
String url = "http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP";
AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), "file1.zip")
.setPriority(Priority.HIGH)
.setTag(this)
.build()
.setAnalyticsListener(new AnalyticsListener() {
@Override
public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {
Log.d(TAG, " timeTakenInMillis : " + timeTakenInMillis);
Log.d(TAG, " bytesSent : " + bytesSent);
Log.d(TAG, " bytesReceived : " + bytesReceived);
Log.d(TAG, " isFromCache : " + isFromCache);
}
})
.setDownloadProgressListener(new DownloadProgressListener() {
@Override
public void onProgress(long bytesDownloaded, long totalBytes) {
Log.d(TAG, "bytesDownloaded : " + bytesDownloaded + " totalBytes : " + totalBytes);
Log.d(TAG, "setDownloadProgressListener isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
})
.startDownload(new DownloadListener() {
@Override
public void onDownloadComplete() {
Log.d(TAG, "File download Completed");
Log.d(TAG, "onDownloadComplete isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
@Override
public void onError(ANError error) {
if (error.getErrorCode() != 0) {
// received ANError from server
// error.getErrorCode() - the ANError code from server
// error.getErrorBody() - the ANError body from server
// error.getErrorDetail() - just an ANError detail
Log.d(TAG, "onError errorCode : " + error.getErrorCode());
Log.d(TAG, "onError errorBody : " + error.getErrorBody());
Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
} else {
// error.getErrorDetail() : connectionError, parseError, requestCancelledError
Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
}
}
});
}
示例7: cleanupDestinationTest
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public void cleanupDestinationTest(View view) {
String url = "http://i.imgur.com/m6K1DCQ.jpg";
AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), "cleanupDestinationTest.jpg")
.setPriority(Priority.HIGH)
.setTag("cleanupDestinationTest")
.build()
.setAnalyticsListener(new AnalyticsListener() {
@Override
public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {
Log.d(TAG, " timeTakenInMillis : " + timeTakenInMillis);
Log.d(TAG, " bytesSent : " + bytesSent);
Log.d(TAG, " bytesReceived : " + bytesReceived);
Log.d(TAG, " isFromCache : " + isFromCache);
}
})
.setDownloadProgressListener(new DownloadProgressListener() {
@Override
public void onProgress(long bytesDownloaded, long totalBytes) {
Log.d(TAG, "bytesDownloaded : " + bytesDownloaded + " totalBytes : " + totalBytes);
Log.d(TAG, "setDownloadProgressListener isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
if (bytesDownloaded > 50) {
AndroidNetworking.cancel("cleanupDestinationTest");
Log.d(TAG, "cancel: cleanupDestinationTest");
}
}
})
.startDownload(new DownloadListener() {
@Override
public void onDownloadComplete() {
Log.d(TAG, "File download Completed");
Log.d(TAG, "onDownloadComplete isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
@Override
public void onError(ANError error) {
if (error.getErrorCode() != 0) {
// received ANError from server
// error.getErrorCode() - the ANError code from server
// error.getErrorBody() - the ANError body from server
// error.getErrorDetail() - just an ANError detail
Log.d(TAG, "onError errorCode : " + error.getErrorCode());
Log.d(TAG, "onError errorBody : " + error.getErrorBody());
Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
} else {
// error.getErrorDetail() : connectionError, parseError, requestCancelledError
Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
}
}
});
}
示例8: checkCacheForCustomClient
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public void checkCacheForCustomClient(View view) {
String url = "http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP";
AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), "file1.zip")
.setPriority(Priority.HIGH)
.setTag(this)
.setOkHttpClient(new OkHttpClient())
.build()
.setAnalyticsListener(new AnalyticsListener() {
@Override
public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {
Log.d(TAG, " timeTakenInMillis : " + timeTakenInMillis);
Log.d(TAG, " bytesSent : " + bytesSent);
Log.d(TAG, " bytesReceived : " + bytesReceived);
Log.d(TAG, " isFromCache : " + isFromCache);
}
})
.setDownloadProgressListener(new DownloadProgressListener() {
@Override
public void onProgress(long bytesDownloaded, long totalBytes) {
Log.d(TAG, "bytesDownloaded : " + bytesDownloaded + " totalBytes : " + totalBytes);
Log.d(TAG, "setDownloadProgressListener isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
})
.startDownload(new DownloadListener() {
@Override
public void onDownloadComplete() {
Log.d(TAG, "File download Completed");
Log.d(TAG, "onDownloadComplete isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
@Override
public void onError(ANError error) {
if (error.getErrorCode() != 0) {
// received ANError from server
// error.getErrorCode() - the ANError code from server
// error.getErrorBody() - the ANError body from server
// error.getErrorDetail() - just an ANError detail
Log.d(TAG, "onError errorCode : " + error.getErrorCode());
Log.d(TAG, "onError errorBody : " + error.getErrorBody());
Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
} else {
// error.getErrorDetail() : connectionError, parseError, requestCancelledError
Log.d(TAG, "onError errorDetail : " + error.getErrorDetail());
}
}
});
}
示例9: DownloadProgressHandler
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public DownloadProgressHandler(DownloadProgressListener downloadProgressListener) {
super(Looper.getMainLooper());
mDownloadProgressListener = downloadProgressListener;
}
示例10: downloadFile
import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public void downloadFile(final View view) {
String url = "http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP";
Rx2AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), "file1.zip")
.build()
.setAnalyticsListener(new AnalyticsListener() {
@Override
public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {
Log.d(TAG, " timeTakenInMillis : " + timeTakenInMillis);
Log.d(TAG, " bytesSent : " + bytesSent);
Log.d(TAG, " bytesReceived : " + bytesReceived);
Log.d(TAG, " isFromCache : " + isFromCache);
}
})
.setDownloadProgressListener(new DownloadProgressListener() {
@Override
public void onProgress(long bytesDownloaded, long totalBytes) {
Log.d(TAG, "bytesDownloaded : " + bytesDownloaded + " totalBytes : " + totalBytes);
Log.d(TAG, "setDownloadProgressListener isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
})
.getDownloadCompletable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new CompletableObserver() {
@Override
public void onSubscribe(@NonNull Disposable disposable) {
}
@Override
public void onComplete() {
Log.d(TAG, "File download Completed");
Log.d(TAG, "onDownloadComplete isMainThread : " + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));
}
@Override
public void onError(@NonNull Throwable throwable) {
Utils.logError(TAG, throwable);
}
});
}