diff options
Diffstat (limited to 'InCallUI')
-rw-r--r-- | InCallUI/src/com/android/incallui/VideoCallFragment.java | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/InCallUI/src/com/android/incallui/VideoCallFragment.java b/InCallUI/src/com/android/incallui/VideoCallFragment.java index c4d10c569..a2511f23d 100644 --- a/InCallUI/src/com/android/incallui/VideoCallFragment.java +++ b/InCallUI/src/com/android/incallui/VideoCallFragment.java @@ -108,7 +108,7 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, * changes. */ private static class VideoCallSurface implements TextureView.SurfaceTextureListener, - View.OnClickListener { + View.OnClickListener, View.OnAttachStateChangeListener { private int mSurfaceId; private VideoCallPresenter mPresenter; private TextureView mTextureView; @@ -159,17 +159,7 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, mTextureView = view; mTextureView.setSurfaceTextureListener(this); mTextureView.setOnClickListener(this); - - final boolean areSameSurfaces = - Objects.equal(mSavedSurfaceTexture, mTextureView.getSurfaceTexture()); - Log.d(this, "recreateView: SavedSurfaceTexture=" + mSavedSurfaceTexture - + " areSameSurfaces=" + areSameSurfaces); - if (mSavedSurfaceTexture != null && !areSameSurfaces) { - mTextureView.setSurfaceTexture(mSavedSurfaceTexture); - if (createSurface(mWidth, mHeight)) { - onSurfaceCreated(); - } - } + mTextureView.addOnAttachStateChangeListener(this); mIsDoneWithSurface = false; } @@ -281,6 +271,23 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, // Not Handled } + @Override + public void onViewAttachedToWindow(View v) { + final boolean areSameSurfaces = + Objects.equal(mSavedSurfaceTexture, mTextureView.getSurfaceTexture()); + Log.d(this, "onViewAttachedToWindow: SavedSurfaceTexture=" + mSavedSurfaceTexture + + " areSameSurfaces=" + areSameSurfaces); + if (mSavedSurfaceTexture != null && !areSameSurfaces) { + mTextureView.setSurfaceTexture(mSavedSurfaceTexture); + if (createSurface(mWidth, mHeight)) { + onSurfaceCreated(); + } + } + } + + @Override + public void onViewDetachedFromWindow(View v) {} + /** * Retrieves the current {@link TextureView}. * |