{"action":"created","comment":{"url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/comments/45107179","id":45107179,"diff_hunk":"@@ -0,0 +1,153 @@\n+package com.climate.mirage.targets;\n+\n+import android.graphics.drawable.Drawable;\n+import android.support.annotation.DrawableRes;\n+import android.support.annotation.IntDef;\n+import android.widget.TextView;\n+\n+import com.climate.mirage.Mirage;\n+import com.climate.mirage.requests.MirageRequest;\n+import com.climate.mirage.targets.animation.TextViewDrawableCrossFadeAnimation;\n+\n+import java.lang.annotation.Retention;\n+import java.lang.annotation.RetentionPolicy;\n+\n+/**\n+ * The standard {@link Target} for loading images\n+ * into an {@link TextView} drawable\n+ */\n+public class TextViewTarget extends ViewTarget<TextView> {\n+\n+    public static final int LEFT = 0;\n+    public static final int TOP = 1;\n+    public static final int RIGHT = 2;\n+    public static final int BOTTOM = 3;\n+\n+    private int location = LEFT;\n+    private int boundsLeft = -1;\n+    private int boundsTop = -1;\n+    private int boundsRight = -1;\n+    private int boundsBottom = -1;\n+\n+    @IntDef({LEFT, TOP, RIGHT, BOTTOM})\n+    @Retention(RetentionPolicy.SOURCE)\n+    public @interface Location {}\n+\n+\tpublic TextViewTarget(TextView textView) {\n+\t\tsuper(textView);\n+\t}\n+\n+\tpublic TextViewTarget(MirageRequest request, TextView textView) {\n+\t\tsuper(request, textView);\n+\t}\n+\n+    /**\n+     * Controls where the drawable will be placed. The choices are left, top, right, and bottom\n+     *\n+     * @param location Defines the location of the drawable\n+     * @return reference to daisy chain\n+     */\n+    public TextViewTarget location(@Location int location) {\n+        this.location = location;\n+        return this;\n+    }\n+\n+    /**\n+     * Controls the size of the drawables. This is one size fits all, meaning the loading\n+     * drawable, error drawable, and loaded drawable and receive the same size. This method\n+     * is used the same as {@link Drawable#setBounds(int, int, int, int)}\n+     *\n+     * @return reference to daisy chain\n+     */\n+    public TextViewTarget bounds(int left, int top, int right, int bottom) {\n+        boundsLeft = left;\n+        boundsTop = top;\n+        boundsRight = right;\n+        boundsBottom = bottom;\n+        return this;\n+    }\n+\n+\t@Override\n+\tprotected void onPreparingLoad(TextView view) {\n+\t\tif (getPlaceHolderResourceId() != 0) {\n+            placeDrawable(view, getPlaceHolderResourceId());\n+\t\t} else if (getPlaceHolderDrawable() != null) {\n+            placeDrawable(view, getPlaceHolderDrawable());\n+\t\t} else {\n+            view.setCompoundDrawables(null, null, null, null);\n+\t\t}\n+\t}\n+\n+\t@Override\n+\tprotected void onResult(TextView view, Drawable drawable, Mirage.Source source, MirageRequest request) {\n+\t\tif (animation() != null) {\n+\t\t\tif (!animation().animate(view, drawable, source)) {\n+                placeDrawable(view, drawable);\n+\t\t\t}\n+\t\t} else {\n+            placeDrawable(view, drawable);\n+\t\t}\n+\t}\n+\n+\t@Override\n+\tprotected void onError(TextView view, Exception e, Mirage.Source source, MirageRequest request) {\n+\t\tif (animation() != null) {\n+\t\t\tDrawable drawable;\n+\t\t\tif (getErrorResourceId() > 0) {\n+\t\t\t\tdrawable = view.getContext().getResources().getDrawable(getErrorResourceId());\n+\t\t\t} else {\n+\t\t\t\tdrawable = getErrorDrawable();\n+\t\t\t}\n+\t\t\tif (drawable != null) {\n+\t\t\t\tif (!animation().animate(view, drawable, source)) {\n+                    placeDrawable(view, drawable);\n+\t\t\t\t}\n+\t\t\t} else {\n+                placeDrawable(view, null);\n+\t\t\t}\n+\t\t} else {\n+\t\t\tif (getErrorResourceId() != 0) {\n+                placeDrawable(view, getErrorResourceId());\n+\t\t\t} else if (getErrorDrawable() != null) {\n+                placeDrawable(view, getErrorDrawable());\n+\t\t\t} else {\n+                placeDrawable(view, null);\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t@Override\n+\tpublic ViewTarget<TextView> fade() {\n+        int loc = TextViewDrawableCrossFadeAnimation.LEFT;\n+        switch (location) {\n+            case LEFT: loc = TextViewDrawableCrossFadeAnimation.LEFT; break;\n+            case TOP: loc = TextViewDrawableCrossFadeAnimation.TOP; break;\n+            case RIGHT: loc = TextViewDrawableCrossFadeAnimation.RIGHT; break;\n+            case BOTTOM: loc = TextViewDrawableCrossFadeAnimation.BOTTOM; break;\n+        }\n+        TextViewDrawableCrossFadeAnimation ani = new TextViewDrawableCrossFadeAnimation();\n+        ani.setLocation(loc);\n+        if (boundsLeft > -1) {\n+            ani.setBounds(boundsLeft, boundsTop, boundsRight, boundsBottom);\n+        }\n+\t\treturn animation(ani);\n+\t}\n+\n+    private void placeDrawable(TextView view, @DrawableRes int resId) {\n+        Drawable drawable = view.getResources().getDrawable(resId);\n+        placeDrawable(view, drawable);\n+    }\n+\n+    private void placeDrawable(TextView view, Drawable drawable) {\n+        Drawable[] drawables = view.getCompoundDrawables();\n+        drawables[location] = drawable;\n+        if (boundsLeft > -1) {\n+            drawable.setBounds(boundsLeft, boundsTop, boundsRight, boundsBottom);\n+            view.setCompoundDrawables(\n+                    drawables[0], drawables[1], drawables[2], drawables[3]);\n+        } else {","path":"library/src/main/java/com/climate/mirage/targets/TextViewTarget.java","position":148,"original_position":148,"commit_id":"1301487b0630e6b63b3e709f90a356d4960c01ff","original_commit_id":"1301487b0630e6b63b3e709f90a356d4960c01ff","user":{"login":"chrispix99","id":2940243,"avatar_url":"https://avatars.githubusercontent.com/u/2940243?v=3","gravatar_id":"","url":"https://api.github.com/users/chrispix99","html_url":"https://github.com/chrispix99","followers_url":"https://api.github.com/users/chrispix99/followers","following_url":"https://api.github.com/users/chrispix99/following{/other_user}","gists_url":"https://api.github.com/users/chrispix99/gists{/gist_id}","starred_url":"https://api.github.com/users/chrispix99/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrispix99/subscriptions","organizations_url":"https://api.github.com/users/chrispix99/orgs","repos_url":"https://api.github.com/users/chrispix99/repos","events_url":"https://api.github.com/users/chrispix99/events{/privacy}","received_events_url":"https://api.github.com/users/chrispix99/received_events","type":"User","site_admin":false},"body":"nice covering the alternative option. ","created_at":"2015-11-17T19:27:11Z","updated_at":"2015-11-17T19:27:11Z","html_url":"https://github.com/TheClimateCorporation/mirage/pull/1#discussion_r45107179","pull_request_url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/comments/45107179"},"html":{"href":"https://github.com/TheClimateCorporation/mirage/pull/1#discussion_r45107179"},"pull_request":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1","id":50457762,"html_url":"https://github.com/TheClimateCorporation/mirage/pull/1","diff_url":"https://github.com/TheClimateCorporation/mirage/pull/1.diff","patch_url":"https://github.com/TheClimateCorporation/mirage/pull/1.patch","issue_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/1","number":1,"state":"open","locked":false,"title":"Textviewtarget","user":{"login":"musselwhizzle","id":2308674,"avatar_url":"https://avatars.githubusercontent.com/u/2308674?v=3","gravatar_id":"","url":"https://api.github.com/users/musselwhizzle","html_url":"https://github.com/musselwhizzle","followers_url":"https://api.github.com/users/musselwhizzle/followers","following_url":"https://api.github.com/users/musselwhizzle/following{/other_user}","gists_url":"https://api.github.com/users/musselwhizzle/gists{/gist_id}","starred_url":"https://api.github.com/users/musselwhizzle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/musselwhizzle/subscriptions","organizations_url":"https://api.github.com/users/musselwhizzle/orgs","repos_url":"https://api.github.com/users/musselwhizzle/repos","events_url":"https://api.github.com/users/musselwhizzle/events{/privacy}","received_events_url":"https://api.github.com/users/musselwhizzle/received_events","type":"User","site_admin":false},"body":"Added a TextViewTarget ","created_at":"2015-11-12T00:42:47Z","updated_at":"2015-11-17T19:27:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d787e5e38e1a0da10200b27489a2f72ca9b44813","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1/commits","review_comments_url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1/comments","review_comment_url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/1/comments","statuses_url":"https://api.github.com/repos/TheClimateCorporation/mirage/statuses/1301487b0630e6b63b3e709f90a356d4960c01ff","head":{"label":"TheClimateCorporation:textviewtarget","ref":"textviewtarget","sha":"1301487b0630e6b63b3e709f90a356d4960c01ff","user":{"login":"TheClimateCorporation","id":1661603,"avatar_url":"https://avatars.githubusercontent.com/u/1661603?v=3","gravatar_id":"","url":"https://api.github.com/users/TheClimateCorporation","html_url":"https://github.com/TheClimateCorporation","followers_url":"https://api.github.com/users/TheClimateCorporation/followers","following_url":"https://api.github.com/users/TheClimateCorporation/following{/other_user}","gists_url":"https://api.github.com/users/TheClimateCorporation/gists{/gist_id}","starred_url":"https://api.github.com/users/TheClimateCorporation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheClimateCorporation/subscriptions","organizations_url":"https://api.github.com/users/TheClimateCorporation/orgs","repos_url":"https://api.github.com/users/TheClimateCorporation/repos","events_url":"https://api.github.com/users/TheClimateCorporation/events{/privacy}","received_events_url":"https://api.github.com/users/TheClimateCorporation/received_events","type":"Organization","site_admin":false},"repo":{"id":35564219,"name":"mirage","full_name":"TheClimateCorporation/mirage","owner":{"login":"TheClimateCorporation","id":1661603,"avatar_url":"https://avatars.githubusercontent.com/u/1661603?v=3","gravatar_id":"","url":"https://api.github.com/users/TheClimateCorporation","html_url":"https://github.com/TheClimateCorporation","followers_url":"https://api.github.com/users/TheClimateCorporation/followers","following_url":"https://api.github.com/users/TheClimateCorporation/following{/other_user}","gists_url":"https://api.github.com/users/TheClimateCorporation/gists{/gist_id}","starred_url":"https://api.github.com/users/TheClimateCorporation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheClimateCorporation/subscriptions","organizations_url":"https://api.github.com/users/TheClimateCorporation/orgs","repos_url":"https://api.github.com/users/TheClimateCorporation/repos","events_url":"https://api.github.com/users/TheClimateCorporation/events{/privacy}","received_events_url":"https://api.github.com/users/TheClimateCorporation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TheClimateCorporation/mirage","description":"Android image loading library which allows composite disk caches to facilitate offline syncing","fork":false,"url":"https://api.github.com/repos/TheClimateCorporation/mirage","forks_url":"https://api.github.com/repos/TheClimateCorporation/mirage/forks","keys_url":"https://api.github.com/repos/TheClimateCorporation/mirage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheClimateCorporation/mirage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheClimateCorporation/mirage/teams","hooks_url":"https://api.github.com/repos/TheClimateCorporation/mirage/hooks","issue_events_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/events{/number}","events_url":"https://api.github.com/repos/TheClimateCorporation/mirage/events","assignees_url":"https://api.github.com/repos/TheClimateCorporation/mirage/assignees{/user}","branches_url":"https://api.github.com/repos/TheClimateCorporation/mirage/branches{/branch}","tags_url":"https://api.github.com/repos/TheClimateCorporation/mirage/tags","blobs_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheClimateCorporation/mirage/statuses/{sha}","languages_url":"https://api.github.com/repos/TheClimateCorporation/mirage/languages","stargazers_url":"https://api.github.com/repos/TheClimateCorporation/mirage/stargazers","contributors_url":"https://api.github.com/repos/TheClimateCorporation/mirage/contributors","subscribers_url":"https://api.github.com/repos/TheClimateCorporation/mirage/subscribers","subscription_url":"https://api.github.com/repos/TheClimateCorporation/mirage/subscription","commits_url":"https://api.github.com/repos/TheClimateCorporation/mirage/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheClimateCorporation/mirage/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheClimateCorporation/mirage/contents/{+path}","compare_url":"https://api.github.com/repos/TheClimateCorporation/mirage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheClimateCorporation/mirage/merges","archive_url":"https://api.github.com/repos/TheClimateCorporation/mirage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheClimateCorporation/mirage/downloads","issues_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues{/number}","pulls_url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls{/number}","milestones_url":"https://api.github.com/repos/TheClimateCorporation/mirage/milestones{/number}","notifications_url":"https://api.github.com/repos/TheClimateCorporation/mirage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheClimateCorporation/mirage/labels{/name}","releases_url":"https://api.github.com/repos/TheClimateCorporation/mirage/releases{/id}","created_at":"2015-05-13T17:38:57Z","updated_at":"2015-08-06T23:52:15Z","pushed_at":"2015-11-12T01:01:04Z","git_url":"git://github.com/TheClimateCorporation/mirage.git","ssh_url":"git@github.com:TheClimateCorporation/mirage.git","clone_url":"https://github.com/TheClimateCorporation/mirage.git","svn_url":"https://github.com/TheClimateCorporation/mirage","homepage":"","size":757,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"base":{"label":"TheClimateCorporation:master","ref":"master","sha":"78203459dd777ce535c0f9304be00d79b842ae82","user":{"login":"TheClimateCorporation","id":1661603,"avatar_url":"https://avatars.githubusercontent.com/u/1661603?v=3","gravatar_id":"","url":"https://api.github.com/users/TheClimateCorporation","html_url":"https://github.com/TheClimateCorporation","followers_url":"https://api.github.com/users/TheClimateCorporation/followers","following_url":"https://api.github.com/users/TheClimateCorporation/following{/other_user}","gists_url":"https://api.github.com/users/TheClimateCorporation/gists{/gist_id}","starred_url":"https://api.github.com/users/TheClimateCorporation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheClimateCorporation/subscriptions","organizations_url":"https://api.github.com/users/TheClimateCorporation/orgs","repos_url":"https://api.github.com/users/TheClimateCorporation/repos","events_url":"https://api.github.com/users/TheClimateCorporation/events{/privacy}","received_events_url":"https://api.github.com/users/TheClimateCorporation/received_events","type":"Organization","site_admin":false},"repo":{"id":35564219,"name":"mirage","full_name":"TheClimateCorporation/mirage","owner":{"login":"TheClimateCorporation","id":1661603,"avatar_url":"https://avatars.githubusercontent.com/u/1661603?v=3","gravatar_id":"","url":"https://api.github.com/users/TheClimateCorporation","html_url":"https://github.com/TheClimateCorporation","followers_url":"https://api.github.com/users/TheClimateCorporation/followers","following_url":"https://api.github.com/users/TheClimateCorporation/following{/other_user}","gists_url":"https://api.github.com/users/TheClimateCorporation/gists{/gist_id}","starred_url":"https://api.github.com/users/TheClimateCorporation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheClimateCorporation/subscriptions","organizations_url":"https://api.github.com/users/TheClimateCorporation/orgs","repos_url":"https://api.github.com/users/TheClimateCorporation/repos","events_url":"https://api.github.com/users/TheClimateCorporation/events{/privacy}","received_events_url":"https://api.github.com/users/TheClimateCorporation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TheClimateCorporation/mirage","description":"Android image loading library which allows composite disk caches to facilitate offline syncing","fork":false,"url":"https://api.github.com/repos/TheClimateCorporation/mirage","forks_url":"https://api.github.com/repos/TheClimateCorporation/mirage/forks","keys_url":"https://api.github.com/repos/TheClimateCorporation/mirage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheClimateCorporation/mirage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheClimateCorporation/mirage/teams","hooks_url":"https://api.github.com/repos/TheClimateCorporation/mirage/hooks","issue_events_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/events{/number}","events_url":"https://api.github.com/repos/TheClimateCorporation/mirage/events","assignees_url":"https://api.github.com/repos/TheClimateCorporation/mirage/assignees{/user}","branches_url":"https://api.github.com/repos/TheClimateCorporation/mirage/branches{/branch}","tags_url":"https://api.github.com/repos/TheClimateCorporation/mirage/tags","blobs_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheClimateCorporation/mirage/statuses/{sha}","languages_url":"https://api.github.com/repos/TheClimateCorporation/mirage/languages","stargazers_url":"https://api.github.com/repos/TheClimateCorporation/mirage/stargazers","contributors_url":"https://api.github.com/repos/TheClimateCorporation/mirage/contributors","subscribers_url":"https://api.github.com/repos/TheClimateCorporation/mirage/subscribers","subscription_url":"https://api.github.com/repos/TheClimateCorporation/mirage/subscription","commits_url":"https://api.github.com/repos/TheClimateCorporation/mirage/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheClimateCorporation/mirage/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheClimateCorporation/mirage/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheClimateCorporation/mirage/contents/{+path}","compare_url":"https://api.github.com/repos/TheClimateCorporation/mirage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheClimateCorporation/mirage/merges","archive_url":"https://api.github.com/repos/TheClimateCorporation/mirage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheClimateCorporation/mirage/downloads","issues_url":"https://api.github.com/repos/TheClimateCorporation/mirage/issues{/number}","pulls_url":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls{/number}","milestones_url":"https://api.github.com/repos/TheClimateCorporation/mirage/milestones{/number}","notifications_url":"https://api.github.com/repos/TheClimateCorporation/mirage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheClimateCorporation/mirage/labels{/name}","releases_url":"https://api.github.com/repos/TheClimateCorporation/mirage/releases{/id}","created_at":"2015-05-13T17:38:57Z","updated_at":"2015-08-06T23:52:15Z","pushed_at":"2015-11-12T01:01:04Z","git_url":"git://github.com/TheClimateCorporation/mirage.git","ssh_url":"git@github.com:TheClimateCorporation/mirage.git","clone_url":"https://github.com/TheClimateCorporation/mirage.git","svn_url":"https://github.com/TheClimateCorporation/mirage","homepage":"","size":757,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1"},"html":{"href":"https://github.com/TheClimateCorporation/mirage/pull/1"},"issue":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/1"},"comments":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/TheClimateCorporation/mirage/statuses/1301487b0630e6b63b3e709f90a356d4960c01ff"}}}}