{"action":"created","issue":{"url":"https://api.github.com/repos/klinker41/android-slidingactivity/issues/20","repository_url":"https://api.github.com/repos/klinker41/android-slidingactivity","labels_url":"https://api.github.com/repos/klinker41/android-slidingactivity/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/klinker41/android-slidingactivity/issues/20/comments","events_url":"https://api.github.com/repos/klinker41/android-slidingactivity/issues/20/events","html_url":"https://github.com/klinker41/android-slidingactivity/issues/20","id":127100093,"number":20,"title":"Cannot start this animator on a detached view","user":{"login":"VictorBG","id":5901459,"avatar_url":"https://avatars.githubusercontent.com/u/5901459?v=3","gravatar_id":"","url":"https://api.github.com/users/VictorBG","html_url":"https://github.com/VictorBG","followers_url":"https://api.github.com/users/VictorBG/followers","following_url":"https://api.github.com/users/VictorBG/following{/other_user}","gists_url":"https://api.github.com/users/VictorBG/gists{/gist_id}","starred_url":"https://api.github.com/users/VictorBG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VictorBG/subscriptions","organizations_url":"https://api.github.com/users/VictorBG/orgs","repos_url":"https://api.github.com/users/VictorBG/repos","events_url":"https://api.github.com/users/VictorBG/events{/privacy}","received_events_url":"https://api.github.com/users/VictorBG/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-01-17T15:02:02Z","updated_at":"2016-10-27T20:39:37Z","closed_at":"2016-10-27T20:39:37Z","body":"When I open the activity from a RecyclerView works ok, but when I open it again with the same image drops an IllegalStateException. I add the Logcat: \r\n\r\n```\r\n Caused by: java.lang.IllegalStateException: Cannot start this animator on a detached view!\r\nat android.view.RenderNode.addAnimator(RenderNode.java:817)\r\nat android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:300)\r\nat android.view.RenderNodeAnimator.setTarget(RenderNodeAnimator.java:282)\r\nat android.animation.RevealAnimator.<init>(RevealAnimator.java:37)\r\nat android.view.ViewAnimationUtils.createCircularReveal(ViewAnimationUtils.java:53)\r\nat com.klinker.android.sliding.SlidingActivity.setImage(SlidingActivity.java:345)\r\nat com.vvss.noticiasanime.DetailNewDark$2$override.onResourceReady(DetailNewDark.java:129)\r\nat com.vvss.noticiasanime.DetailNewDark$2$override.access$dispatch(DetailNewDark.java)\r\nat com.vvss.noticiasanime.DetailNewDark$2.onResourceReady(DetailNewDark.java:0)\r\nat com.vvss.noticiasanime.DetailNewDark$2.onResourceReady(DetailNewDark.java:126)\r\nat com.bumptech.glide.request.GenericRequest.onResourceReady(GenericRequest.java:525)\r\n```\r\n\r\nI add my code: \r\n```\r\ntarget = new SimpleTarget<Bitmap>() {\r\n            @Override\r\n            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {\r\n                setImage(resource);           \r\n            }\r\n        };\r\n\r\n```\r\n\r\nSeems that the problem is in the `setImage()` :\r\n\r\n```\r\npublic void setImage(Bitmap bitmap) {\r\n\r\n        photoView.setImageBitmap(bitmap);\r\n\r\n        if (isStarting) {\r\n            Palette palette = Palette.from(bitmap).generate();\r\n            setPrimaryColors(palette.getVibrantColor(DEFAULT_PRIMARY_COLOR),\r\n                    palette.getDarkVibrantColor(DEFAULT_PRIMARY_DARK_COLOR));\r\n        } else {\r\n            photoViewTempBackground.setBackgroundDrawable(photoView.getBackground());\r\n            photoViewTempBackground.setVisibility(View.VISIBLE);\r\n\r\n            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {\r\n                final int cx = (int) photoView.getX() + photoView.getMeasuredWidth() / 2;\r\n                final int cy = (int) photoView.getY() + photoView.getMeasuredHeight() / 2;\r\n                final int finalRadius = photoView.getWidth();\r\n\r\n\r\n                Animator anim = ViewAnimationUtils.createCircularReveal(photoView, cx, cy,\r\n                        0, finalRadius);\r\n                anim.setDuration(500);\r\n                anim.addListener(new AnimatorListenerAdapter() {\r\n                    @Override\r\n                    public void onAnimationEnd(Animator animation) {\r\n                        super.onAnimationEnd(animation);\r\n                        photoViewTempBackground.setVisibility(View.GONE);\r\n                    }\r\n                });\r\n                anim.start();\r\n\r\n\r\n            } else {\r\n                photoView.setAlpha(0f);\r\n                photoView.animate()\r\n                        .alpha(1f)\r\n                        .setListener(new AnimatorListenerAdapter() {\r\n                            @Override\r\n                            public void onAnimationEnd(Animator animation) {\r\n                                super.onAnimationEnd(animation);\r\n                                photoView.setAlpha(1f);\r\n                                photoViewTempBackground.setVisibility(View.GONE);\r\n                            }\r\n                        })\r\n                        .start();\r\n            }\r\n        }\r\n    }\r\n```\r\n\r\nSpecially in the line `  Animator anim = ViewAnimationUtils.createCircularReveal(photoView, cx, cy,\r\n                        0, finalRadius);`. How can I solve it? Thanks."},"comment":{"url":"https://api.github.com/repos/klinker41/android-slidingactivity/issues/comments/256762399","html_url":"https://github.com/klinker41/android-slidingactivity/issues/20#issuecomment-256762399","issue_url":"https://api.github.com/repos/klinker41/android-slidingactivity/issues/20","id":256762399,"user":{"login":"klinker24","id":4874287,"avatar_url":"https://avatars.githubusercontent.com/u/4874287?v=3","gravatar_id":"","url":"https://api.github.com/users/klinker24","html_url":"https://github.com/klinker24","followers_url":"https://api.github.com/users/klinker24/followers","following_url":"https://api.github.com/users/klinker24/following{/other_user}","gists_url":"https://api.github.com/users/klinker24/gists{/gist_id}","starred_url":"https://api.github.com/users/klinker24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klinker24/subscriptions","organizations_url":"https://api.github.com/users/klinker24/orgs","repos_url":"https://api.github.com/users/klinker24/repos","events_url":"https://api.github.com/users/klinker24/events{/privacy}","received_events_url":"https://api.github.com/users/klinker24/received_events","type":"User","site_admin":false},"created_at":"2016-10-27T20:39:37Z","updated_at":"2016-10-27T20:39:37Z","body":"Not really sure about your code to know why it would be happening, but looks like it is trying to use an old instance of the header photo `ImageView`.\r\n\r\nIt is pretty easy to bypass the `setImage()` usage, you could just do:\r\n\r\n```java\r\nGlide.with(context)\r\n        .load(photoUri)\r\n        .into((ImageView) findViewById(R.id.photo));\r\n```"}}
{"actor":{"display_login":"klinker24"}}