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);
}
Aggregations