
com.bumptech.glide.manager.TargetTracker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glide Show documentation
Show all versions of glide Show documentation
A fast and efficient image loading library for Android focused on smooth scrolling.
package com.bumptech.glide.manager;
import androidx.annotation.NonNull;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.util.Util;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;
/**
* Holds the set of {@link Target}s currently active for a {@link com.bumptech.glide.RequestManager}
* and forwards on lifecycle events.
*/
public final class TargetTracker implements LifecycleListener {
private final Set> targets =
Collections.newSetFromMap(new WeakHashMap, Boolean>());
public void track(@NonNull Target> target) {
targets.add(target);
}
public void untrack(@NonNull Target> target) {
targets.remove(target);
}
@Override
public void onStart() {
for (Target> target : Util.getSnapshot(targets)) {
target.onStart();
}
}
@Override
public void onStop() {
for (Target> target : Util.getSnapshot(targets)) {
target.onStop();
}
}
@Override
public void onDestroy() {
for (Target> target : Util.getSnapshot(targets)) {
target.onDestroy();
}
}
@NonNull
public List> getAll() {
return Util.getSnapshot(targets);
}
public void clear() {
targets.clear();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy