Search in sources :

Example 1 with OnProgressListener

use of common.base.glide.progress.OnProgressListener in project BaseProject by feer921.

the class GlideImageLoader method addProgressListener.

private void addProgressListener() {
    if (getImageUrl() == null)
        return;
    final String url = getImageUrl();
    if (!url.startsWith(HTTP))
        return;
    internalProgressListener = new OnProgressListener() {

        @Override
        public void onProgress(String imageUrl, long bytesRead, long totalBytes, boolean isDone, GlideException exception) {
            if (totalBytes == 0)
                return;
            if (!url.equals(imageUrl))
                return;
            if (mLastBytesRead == bytesRead && mLastStatus == isDone)
                return;
            mLastBytesRead = bytesRead;
            mTotalBytes = totalBytes;
            mLastStatus = isDone;
            mainThreadCallback(bytesRead, totalBytes, isDone, exception);
            if (isDone) {
                ProgressManager.removeProgressListener(this);
            }
        }
    };
    ProgressManager.addProgressListener(internalProgressListener);
}
Also used : OnProgressListener(common.base.glide.progress.OnProgressListener) GlideException(com.bumptech.glide.load.engine.GlideException)

Aggregations

GlideException (com.bumptech.glide.load.engine.GlideException)1 OnProgressListener (common.base.glide.progress.OnProgressListener)1