package com.bumptech.glide.manager; import android.annotation.SuppressLint; import android.support.v4.app.Fragment; import com.bumptech.glide.RequestManager; /** * A view-less {@link android.support.v4.app.Fragment} used to safely store an * {@link com.bumptech.glide.RequestManager} that can be used to start, stop and manage Glide requests started for * targets within the fragment or activity this fragment is a child of. * * @see com.bumptech.glide.manager.RequestManagerFragment * @see com.bumptech.glide.manager.RequestManagerRetriever * @see com.bumptech.glide.RequestManager */ public class SupportRequestManagerFragment extends Fragment { private RequestManager requestManager; private final ActivityFragmentLifecycle lifecycle; public SupportRequestManagerFragment() { this(new ActivityFragmentLifecycle()); } // For testing only. @SuppressLint("ValidFragment") public SupportRequestManagerFragment(ActivityFragmentLifecycle lifecycle) { this.lifecycle = lifecycle; } /** * Sets the current {@link com.bumptech.glide.RequestManager}. * * @param requestManager The manager to set. */ public void setRequestManager(RequestManager requestManager) { this.requestManager = requestManager; } ActivityFragmentLifecycle getGlideLifecycle() { return lifecycle; } /** * Returns the current {@link com.bumptech.glide.RequestManager} or null if none is set. */ public RequestManager getRequestManager() { return requestManager; } @Override public void onStart() { super.onStart(); lifecycle.onStart(); } @Override public void onStop() { super.onStop(); lifecycle.onStop(); } @Override public void onDestroy() { super.onDestroy(); lifecycle.onDestroy(); } }