summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-05-29 16:15:41 -0700
committerJohn Reck <jreck@google.com>2014-05-29 17:40:09 -0700
commit2dedafb48f85e34a2f48262f12908866fc9de132 (patch)
tree2bfbba60236b884b2d9fb271b2cda528c9694e62 /core
parentaee470c0232afdac4256d13020fa0cf04f30395c (diff)
downloadframeworks_base-2dedafb48f85e34a2f48262f12908866fc9de132.zip
frameworks_base-2dedafb48f85e34a2f48262f12908866fc9de132.tar.gz
frameworks_base-2dedafb48f85e34a2f48262f12908866fc9de132.tar.bz2
Fix NPE in onVisibilityChanged
Bug: 15089790 onVisibilityChanged may happen before the View is attached. Only attempt to re-set the update listener if mLayer is not null, as it means the View is attached and has already drawn once. If mLayer is null then the update listener will be set when the view next draws Change-Id: I406e359a0a0720988f026f9cbde26afdb564ca92
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/TextureView.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 1765c43..2a9f7d5 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -405,7 +405,9 @@ public class TextureView extends View {
// To cancel updates, the easiest thing to do is simply to remove the
// updates listener
if (visibility == VISIBLE) {
- mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);
+ if (mLayer != null) {
+ mSurface.setOnFrameAvailableListener(mUpdateListener, mAttachInfo.mHandler);
+ }
updateLayerAndInvalidate();
} else {
mSurface.setOnFrameAvailableListener(null);