当前位置: 首页>>代码示例>>Java>>正文


Java DownloadProgressListener类代码示例

本文整理汇总了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);
            }
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ANRequest.java

示例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);
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:58,代码来源:RxApiTestActivity.java

示例3: DownloadProgressHandler

import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public DownloadProgressHandler(DownloadProgressListener downloadProgressListener) {
    super(Looper.getMainLooper());
    mDownloadProgressListenerWeakRef = downloadProgressListener;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:DownloadProgressHandler.java

示例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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:ResponseProgressBody.java

示例5: setDownloadProgressListener

import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public T setDownloadProgressListener(DownloadProgressListener downloadProgressListener) {
    this.mDownloadProgressListener = downloadProgressListener;
    return (T) this;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:ANRequest.java

示例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());
                    }
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:47,代码来源:OkHttpResponseTestActivity.java

示例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());
                    }
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:51,代码来源:OkHttpResponseTestActivity.java

示例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());
                    }
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:48,代码来源:OkHttpResponseTestActivity.java

示例9: DownloadProgressHandler

import com.androidnetworking.interfaces.DownloadProgressListener; //导入依赖的package包/类
public DownloadProgressHandler(DownloadProgressListener downloadProgressListener) {
    super(Looper.getMainLooper());
    mDownloadProgressListener = downloadProgressListener;
}
 
开发者ID:amitshekhariitbhu,项目名称:Fast-Android-Networking,代码行数:5,代码来源:DownloadProgressHandler.java

示例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);
                }
            });
}
 
开发者ID:amitshekhariitbhu,项目名称:Fast-Android-Networking,代码行数:42,代码来源:Rx2ApiTestActivity.java


注:本文中的com.androidnetworking.interfaces.DownloadProgressListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。