{"action":"opened","issue":{"url":"https://api.github.com/repos/bumptech/glide/issues/1533","repository_url":"https://api.github.com/repos/bumptech/glide","labels_url":"https://api.github.com/repos/bumptech/glide/issues/1533/labels{/name}","comments_url":"https://api.github.com/repos/bumptech/glide/issues/1533/comments","events_url":"https://api.github.com/repos/bumptech/glide/issues/1533/events","html_url":"https://github.com/bumptech/glide/issues/1533","id":183911932,"number":1533,"title":"How can i use Glide with dagger2","user":{"login":"kienvtqhi","id":1924632,"avatar_url":"https://avatars.githubusercontent.com/u/1924632?v=3","gravatar_id":"","url":"https://api.github.com/users/kienvtqhi","html_url":"https://github.com/kienvtqhi","followers_url":"https://api.github.com/users/kienvtqhi/followers","following_url":"https://api.github.com/users/kienvtqhi/following{/other_user}","gists_url":"https://api.github.com/users/kienvtqhi/gists{/gist_id}","starred_url":"https://api.github.com/users/kienvtqhi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kienvtqhi/subscriptions","organizations_url":"https://api.github.com/users/kienvtqhi/orgs","repos_url":"https://api.github.com/users/kienvtqhi/repos","events_url":"https://api.github.com/users/kienvtqhi/events{/privacy}","received_events_url":"https://api.github.com/users/kienvtqhi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-19T09:35:13Z","updated_at":"2016-10-19T09:35:13Z","closed_at":null,"body":"<!--\r\nPlease fill in the below fields with some data to help us best diagnose the issue.\r\nThe more specific you are, the better! You can help a lot by not making us ask these questions.\r\nFeel free to remove any irrelevant parts that you know are not related to the issue.\r\nAny HTML comment like this will be stripped when rendering markdown, no need to delete them.\r\n-->\r\nHello\r\n\r\n<!-- What version of Glide you're running, for example: 3.7.1 | 3.8.0-SNAPSHOT | 4.0.0-SNAPSHOT\r\nIt's essentially the version number from your build.gradle: `dependencies { compile '...:x.y.z' }` -->\r\n**Glide Version**: 3.7.0\r\n\r\n<!-- Do you use any integration library, like OkHttp3 or Volley? For example:\r\nFails to display with stock networking, but works with okhttp3-1.4.0 -->\r\n**Integration libraries**: OkHttp3 + Dagger2\r\n\r\n<!-- What devices you managed to get the issue to come up on? For example:\r\nfails on Galaxy S4/GT-I9500 4.4.2, works fine on Nexus 6P 5.1 and Genymotion Nexus 5 5.0.1 -->\r\n**Device/Android Version**: Android Emulator + Asus zenfone 5\r\n\r\n<!-- Share the details of your issue in prose, detailing actual and expected behavior. It also helps if you give some info **why** you are trying to do something as opposed to **what** is not working. -->\r\n**Issue details / Repro steps / Use case background**: \r\nI am developing a music application. I want to load artist's image from LastFM so i do this this way\r\n1. I created a class `ArtistImageLoader extends BaseGlideUrlLoader`. \r\n2. In the `getUrl` method i used retrofit2 to get the artist's image url from LastFM via [getArtistInfo][http://www.last.fm/api/show/album.getInfo] method. \r\n\r\nMy problem is i didn't know how to inject the service of retrofit to make the request in `ArtistImageLoader`. Can you help me to do it? Thank you so much!\r\n\r\n<!-- How do you use Glide?\r\nMake sure you include everything as is in your app's code:\r\nChanging a single method parameter can yield totally different results.\r\nPlease clarify any magic variables that appear in the code, for example: \"// `this` is a Fragment\"\r\n-->\r\n**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:\r\n```java\r\nglide.register(MLocalArtist.class, InputStream.class, new ArtistImageLoader.Factory());\r\n\r\nGlide.with(getContext())\r\n                .from(MLocalArtist.class)\r\n                .load(localArtist)\r\n                .into(localArtistViewHolder.ivArtwork);\r\n```\r\n\r\n**ArtistImageLoader**\r\n```java\r\npublic class ArtistImageLoader extends BaseGlideUrlLoader<MLocalArtist> {\r\n\r\n    @Inject\r\n    LastfmService lastfmService;\r\n\r\n    public ArtistImageLoader(Context context) {\r\n        super(context);\r\n    }\r\n\r\n    @Override\r\n    protected String getUrl(MLocalArtist model, int width, int height) {\r\n        Call<List<MArtist>> call = lastfmService.getArtistInfo(model.artistName);\r\n        try {\r\n            List<MArtist> artists = call.execute().body();\r\n            if (artists != null && artists.size() > 0) {\r\n                Timber.e(artists.get(0).toString());\r\n            }\r\n        } catch (IOException e) {\r\n            e.printStackTrace();\r\n        }\r\n        return null;\r\n    }\r\n\r\n    public static class Factory implements ModelLoaderFactory<MLocalArtist, InputStream> {\r\n        @Override public ModelLoader<MLocalArtist, InputStream> build(Context context, GenericLoaderFactory factories) {\r\n            return new ArtistImageLoader(context);\r\n        }\r\n        @Override public void teardown() {\r\n        }\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"kienvtqhi"}}