Commit 12278932 authored by Zhiheng Vincent Li's avatar Zhiheng Vincent Li Committed by Commit Bot

[Chromecast] Toggle fragment visibility to avoid flash when attach or detach

Set cast fragment to invisible when detach from activity to avoid a flash of cast app view at the last frame

Bug: internal b/77214997

Change-Id: I18b11a8159f2d308dea6c3a8294b4059cbe1864a
Reviewed-on: https://chromium-review.googlesource.com/1023056
Commit-Queue: Zhiheng(Vincent) Li <vincentli@google.com>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553424}
parent 316143da
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/web_contents_container" android:id="@+id/web_contents_container"
android:background="#000000" android:background="#FFFFFF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"> android:layout_weight="1">
......
...@@ -113,6 +113,9 @@ public class CastWebContentsFragment extends Fragment { ...@@ -113,6 +113,9 @@ public class CastWebContentsFragment extends Fragment {
public void onPause() { public void onPause() {
Log.d(TAG, "onPause"); Log.d(TAG, "onPause");
super.onPause(); super.onPause();
// Set mFragmentRootView to invisible to avoid dismiss fragment animation -> activity back
// ground -> one frame of cast app UI -> acivity back ground
mFragmentRootView.setVisibility(View.INVISIBLE);
mResumedState.reset(); mResumedState.reset();
} }
...@@ -120,9 +123,19 @@ public class CastWebContentsFragment extends Fragment { ...@@ -120,9 +123,19 @@ public class CastWebContentsFragment extends Fragment {
public void onResume() { public void onResume() {
Log.d(TAG, "onResume"); Log.d(TAG, "onResume");
super.onResume(); super.onResume();
// Delayed set mFragmentRootView to visible to avoid activity UI -> one frame of fragment
// background -> cast app rendered UI
mFragmentRootView.setVisibility(View.INVISIBLE);
mFragmentRootView.postDelayed(this ::setToVisible, 150);
mResumedState.set(Unit.unit()); mResumedState.set(Unit.unit());
} }
private void setToVisible() {
if (isResumed()) {
mFragmentRootView.setVisibility(View.VISIBLE);
}
}
@Override @Override
public void onStop() { public void onStop() {
Log.d(TAG, "onStop"); Log.d(TAG, "onStop");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment