Merge pull request #1580 from colinkho:main
PiperOrigin-RevId: 665330328
This commit is contained in:
commit
24f3856ea4
@ -90,6 +90,19 @@ public final class Loader implements LoaderErrorThrower {
|
||||
/** A callback to be notified of {@link Loader} events. */
|
||||
public interface Callback<T extends Loadable> {
|
||||
|
||||
/**
|
||||
* Called when a load has started for the first time or through a retry.
|
||||
*
|
||||
* @param loadable The loadable whose load has completed.
|
||||
* @param elapsedRealtimeMs {@link SystemClock#elapsedRealtime} when the load attempts to start.
|
||||
* @param loadDurationMs The duration in milliseconds of the load since {@link #startLoading}
|
||||
* was called.
|
||||
* @param retryCount The number of failed attempts since {@link #startLoading} was called (this
|
||||
* is zero for the first load attempt).
|
||||
*/
|
||||
default void onLoadStarted(
|
||||
T loadable, long elapsedRealtimeMs, long loadDurationMs, int retryCount) {}
|
||||
|
||||
/**
|
||||
* Called when a load has completed.
|
||||
*
|
||||
@ -531,6 +544,9 @@ public final class Loader implements LoaderErrorThrower {
|
||||
}
|
||||
|
||||
private void execute() {
|
||||
long nowMs = SystemClock.elapsedRealtime();
|
||||
long durationMs = nowMs - startTimeMs;
|
||||
Assertions.checkNotNull(this.callback).onLoadStarted(loadable, nowMs, durationMs, errorCount);
|
||||
currentError = null;
|
||||
downloadExecutor.execute(Assertions.checkNotNull(currentTask));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user