{"action":"created","issue":{"url":"https://api.github.com/repos/bumptech/glide/issues/723","labels_url":"https://api.github.com/repos/bumptech/glide/issues/723/labels{/name}","comments_url":"https://api.github.com/repos/bumptech/glide/issues/723/comments","events_url":"https://api.github.com/repos/bumptech/glide/issues/723/events","html_url":"https://github.com/bumptech/glide/issues/723","id":114888276,"number":723,"title":"RequestManagerRetriever: You cannot start a load on a fragment before it is attached, but it is.","user":{"login":"ZkHaider","id":7844550,"avatar_url":"https://avatars.githubusercontent.com/u/7844550?v=3","gravatar_id":"","url":"https://api.github.com/users/ZkHaider","html_url":"https://github.com/ZkHaider","followers_url":"https://api.github.com/users/ZkHaider/followers","following_url":"https://api.github.com/users/ZkHaider/following{/other_user}","gists_url":"https://api.github.com/users/ZkHaider/gists{/gist_id}","starred_url":"https://api.github.com/users/ZkHaider/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZkHaider/subscriptions","organizations_url":"https://api.github.com/users/ZkHaider/orgs","repos_url":"https://api.github.com/users/ZkHaider/repos","events_url":"https://api.github.com/users/ZkHaider/events{/privacy}","received_events_url":"https://api.github.com/users/ZkHaider/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-11-03T19:14:19Z","updated_at":"2015-11-12T08:55:56Z","closed_at":null,"body":"The app crashes when I try to load an image with `Glide`. \r\n\r\nJust as some background, I am setting up `Glide` after `onAttach` in my `Fragment` inside the `onCreateView` call. I have a Presenter class that I pass the context to, and it goes and talks to an API to grab an image via `Retrofit`.\r\n\r\nSo my code looks like this:\r\n\r\n**Base Fragment**:\r\n\r\n```java\r\npublic abstract class BaseFragment extends Fragment {\r\n    \r\n    Context context;\r\n\r\n    @Override\r\n    public void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        context = getActivity();\r\n    }\r\n\r\n}\r\n```\r\n\r\n\r\n**TestFragment**:\r\n\r\n```java\r\npublic class TestFragment extends Fragment {\r\n\r\n    IPresenter mPresenter;\r\n\r\n    @Bind(R.id.testImage) ImageView mTestImage;\r\n\r\n    @Override\r\n    public void onCreate(Bundle savedInstanceState) {\r\n        // Do setup stuff here...\r\n        // Setup presenter here and pass in the context\r\n        mPresenter = new Presenter(context);\r\n\r\n    }\r\n\r\n    // This is called from the presenter to set an image\r\n\r\n    public void setTestImage(String url) {\r\n         Glide.with(context)\r\n                  .load(url)\r\n                  .listener(new RequestListener<String, GlideDrawable>() {\r\n                            @Override\r\n                            public void onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {\r\n                                 return false;\r\n                            }\r\n\r\n                            @Override\r\n                            public void onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemory, boolean isFirstResource) {\r\n                                 // Do stuff\r\n                                 return false;\r\n                             }\r\n                    .into(mTestImage);\r\n\r\n      }\r\n}\r\n```\r\n\r\nThe issue is that the following error gets thrown:\r\n\r\n>Fatal Exception: java.lang.IllegalArgumentException: You cannot start a load on a fragment before it is attached\r\n       at com.bumptech.glide.manager.RequestManagerRetriever.get(RequestManagerRetriever.java)\r\n       at com.bumptech.glide.Glide.with(Glide.java)\r\n\r\nSpecifically this gets called:\r\n\r\n```java\r\n@TargetApi(Build.VERSION_CODES.HONEYCOMB)\r\npublic static RequestManager with(android.app.Fragment fragment) {\r\n    RequestManagerRetriever retriever = RequestManagerRetriever.get();\r\n    return retriever.get(fragment);\r\n}\r\n```\r\n\r\nAnd then in the `RequestManagerRetriever` class this gets thrown:\r\n\r\n```java\r\n@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)\r\npublic RequestManager get(android.app.Fragment fragment) {\r\n    if (fragment.getActivity() == null) {\r\n        throw new IllegalArgumentException(\"You cannot start a load on a fragment before it is attached\");\r\n    }\r\n    if (Util.isOnBackgroundThread() || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {\r\n        return get(fragment.getActivity().getApplicationContext());\r\n    } else {\r\n        android.app.FragmentManager fm = fragment.getChildFragmentManager();\r\n        return fragmentGet(fragment.getActivity(), fm);\r\n    }\r\n}\r\n```\r\n\r\nI don't understand why the `Activity` from `fragment.getActivity()` is null? What seems to be the issue here? I am passing in the context in `onCreateView()` after the context is initialized."},"comment":{"url":"https://api.github.com/repos/bumptech/glide/issues/comments/156036973","html_url":"https://github.com/bumptech/glide/issues/723#issuecomment-156036973","issue_url":"https://api.github.com/repos/bumptech/glide/issues/723","id":156036973,"user":{"login":"TWiStErRob","id":2906988,"avatar_url":"https://avatars.githubusercontent.com/u/2906988?v=3","gravatar_id":"","url":"https://api.github.com/users/TWiStErRob","html_url":"https://github.com/TWiStErRob","followers_url":"https://api.github.com/users/TWiStErRob/followers","following_url":"https://api.github.com/users/TWiStErRob/following{/other_user}","gists_url":"https://api.github.com/users/TWiStErRob/gists{/gist_id}","starred_url":"https://api.github.com/users/TWiStErRob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TWiStErRob/subscriptions","organizations_url":"https://api.github.com/users/TWiStErRob/orgs","repos_url":"https://api.github.com/users/TWiStErRob/repos","events_url":"https://api.github.com/users/TWiStErRob/events{/privacy}","received_events_url":"https://api.github.com/users/TWiStErRob/received_events","type":"User","site_admin":false},"created_at":"2015-11-12T08:55:56Z","updated_at":"2015-11-12T08:55:56Z","body":"@ZkHaider any news?"}}