Search in sources :

Example 1 with DownloadListener

use of com.androidnetworking.interfaces.DownloadListener in project Fast-Android-Networking by amitshekhariitbhu.

the class OkHttpResponseTestActivity method downloadImage.

public void downloadImage(final View view) {
    String url = "http://i.imgur.com/AtbX9iX.png";
    AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), "image1.png").setPriority(Priority.MEDIUM).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);
        }
    }).startDownload(new DownloadListener() {

        @Override
        public void onDownloadComplete() {
            Log.d(TAG, "Image 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 a 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());
            }
        }
    });
}
Also used : AnalyticsListener(com.androidnetworking.interfaces.AnalyticsListener) DownloadListener(com.androidnetworking.interfaces.DownloadListener) ANError(com.androidnetworking.error.ANError)

Example 2 with DownloadListener

use of com.androidnetworking.interfaces.DownloadListener in project Fast-Android-Networking by amitshekhariitbhu.

the class OkHttpResponseTestActivity method downloadFile.

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());
            }
        }
    });
}
Also used : AnalyticsListener(com.androidnetworking.interfaces.AnalyticsListener) DownloadProgressListener(com.androidnetworking.interfaces.DownloadProgressListener) DownloadListener(com.androidnetworking.interfaces.DownloadListener) ANError(com.androidnetworking.error.ANError)

Example 3 with DownloadListener

use of com.androidnetworking.interfaces.DownloadListener in project Fast-Android-Networking by amitshekhariitbhu.

the class OkHttpResponseTestActivity method checkCacheForCustomClient.

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());
            }
        }
    });
}
Also used : OkHttpClient(okhttp3.OkHttpClient) AnalyticsListener(com.androidnetworking.interfaces.AnalyticsListener) DownloadProgressListener(com.androidnetworking.interfaces.DownloadProgressListener) DownloadListener(com.androidnetworking.interfaces.DownloadListener) ANError(com.androidnetworking.error.ANError)

Example 4 with DownloadListener

use of com.androidnetworking.interfaces.DownloadListener in project Fast-Android-Networking by amitshekhariitbhu.

the class ApiTestActivity method downloadImage.

public void downloadImage(final View view) {
    String url = "http://i.imgur.com/AtbX9iX.png";
    AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), "image1.png").setPriority(Priority.MEDIUM).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);
        }
    }).startDownload(new DownloadListener() {

        @Override
        public void onDownloadComplete() {
            Log.d(TAG, "Image 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 a 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());
            }
        }
    });
}
Also used : AnalyticsListener(com.androidnetworking.interfaces.AnalyticsListener) DownloadListener(com.androidnetworking.interfaces.DownloadListener) ANError(com.androidnetworking.error.ANError)

Example 5 with DownloadListener

use of com.androidnetworking.interfaces.DownloadListener in project Fast-Android-Networking by amitshekhariitbhu.

the class ApiTestActivity method checkCacheForCustomClient.

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());
            }
        }
    });
}
Also used : OkHttpClient(okhttp3.OkHttpClient) AnalyticsListener(com.androidnetworking.interfaces.AnalyticsListener) DownloadProgressListener(com.androidnetworking.interfaces.DownloadProgressListener) DownloadListener(com.androidnetworking.interfaces.DownloadListener) ANError(com.androidnetworking.error.ANError)

Aggregations

ANError (com.androidnetworking.error.ANError)8 AnalyticsListener (com.androidnetworking.interfaces.AnalyticsListener)8 DownloadListener (com.androidnetworking.interfaces.DownloadListener)8 DownloadProgressListener (com.androidnetworking.interfaces.DownloadProgressListener)6 OkHttpClient (okhttp3.OkHttpClient)2