Hello everyone, How can I use `Koin` to inject cor...
# koin
s
Hello everyone, How can I use
Koin
to inject correctly context of Fragment/Activity ( especially for Recyclerview, Viewpapger) for
Glide
? My purpose is
create a request manager from
the context of current parent view ( fragment, activity etc) and clear these request images in
onDestroy
fragment/Acitivty. Thanks. Ref: https://github.com/bumptech/glide/blob/a2b759bdcd668f05011e3864aad69f317f342283/library/src/main/java/com/bumptech/glide/Glide.java#L800
Copy code
/**
   * Begin a load with Glide by passing in a context.
   *
   * <p>Any requests started using a context will only have the application level options applied
   * and will not be started or stopped based on lifecycle events. In general, loads should be
   * started at the level the result will be used in. If the resource will be used in a view in a
   * child fragment, the load should be started with {@link #with(android.app.Fragment)}} using that
   * child fragment. Similarly, if the resource will be used in a view in the parent fragment, the
   * load should be started with {@link #with(android.app.Fragment)} using the parent fragment. In
   * the same vein, if the resource will be used in a view in an activity, the load should be
   * started with {@link #with(android.app.Activity)}}.
   *
   * <p>This method is appropriate for resources that will be used outside of the normal fragment or
   * activity lifecycle (For example in services, or for notification thumbnails).
   *
   * @param context Any context, will not be retained.
   * @return A RequestManager for the top level application that can be used to start a load.
   * @see #with(android.app.Activity)
   * @see #with(android.app.Fragment)
   * @see #with(androidx.fragment.app.Fragment)
   * @see #with(androidx.fragment.app.FragmentActivity)
   */
  @NonNull
  public static RequestManager with(@NonNull Context context) {
    return getRetriever(context).get(context);
  }