diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_bg.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_bg.png new file mode 100644 index 000000000..c3668ead5 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_bg.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_1.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_1.png new file mode 100644 index 000000000..93a221217 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_1.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_10.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_10.png new file mode 100644 index 000000000..6ae91d91d Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_10.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_11.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_11.png new file mode 100644 index 000000000..556a24760 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_11.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_12.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_12.png new file mode 100644 index 000000000..80f8e8532 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_12.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_13.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_13.png new file mode 100644 index 000000000..1e080a138 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_13.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_14.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_14.png new file mode 100644 index 000000000..b854bbde1 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_14.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_15.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_15.png new file mode 100644 index 000000000..f08383dd3 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_15.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_16.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_16.png new file mode 100644 index 000000000..ed54ef0f4 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_16.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_17.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_17.png new file mode 100644 index 000000000..e5c197d2c Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_17.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_18.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_18.png new file mode 100644 index 000000000..100dd8191 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_18.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_19.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_19.png new file mode 100644 index 000000000..cf8909b36 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_19.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_2.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_2.png new file mode 100644 index 000000000..386720fd1 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_2.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_20.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_20.png new file mode 100644 index 000000000..613157b44 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_20.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_21.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_21.png new file mode 100644 index 000000000..9bab3a86c Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_21.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_22.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_22.png new file mode 100644 index 000000000..956adf4e2 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_22.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_23.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_23.png new file mode 100644 index 000000000..ac703d32f Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_23.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_24.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_24.png new file mode 100644 index 000000000..2522c668d Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_24.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_25.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_25.png new file mode 100644 index 000000000..f8d21d2ff Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_25.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_26.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_26.png new file mode 100644 index 000000000..92d9583e7 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_26.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_27.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_27.png new file mode 100644 index 000000000..9ccc088dc Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_27.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_28.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_28.png new file mode 100644 index 000000000..673d449e5 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_28.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_29.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_29.png new file mode 100644 index 000000000..3d3301f68 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_29.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_3.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_3.png new file mode 100644 index 000000000..f51f6b4af Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_3.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_30.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_30.png new file mode 100644 index 000000000..f43893d34 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_30.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_31.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_31.png new file mode 100644 index 000000000..a3afd81d9 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_31.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_32.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_32.png new file mode 100644 index 000000000..70a24db00 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_32.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_33.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_33.png new file mode 100644 index 000000000..447e5bb1b Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_33.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_34.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_34.png new file mode 100644 index 000000000..e3dc09383 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_34.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_35.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_35.png new file mode 100644 index 000000000..4d7f43a62 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_35.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_36.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_36.png new file mode 100644 index 000000000..c2e4a62b2 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_36.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_37.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_37.png new file mode 100644 index 000000000..1690677a2 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_37.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_38.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_38.png new file mode 100644 index 000000000..e40c9dabb Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_38.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_39.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_39.png new file mode 100644 index 000000000..c399e7fe2 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_39.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_4.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_4.png new file mode 100644 index 000000000..70fdb5a5d Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_4.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_40.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_40.png new file mode 100644 index 000000000..9361a1472 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_40.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_41.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_41.png new file mode 100644 index 000000000..682844015 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_41.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_42.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_42.png new file mode 100644 index 000000000..6bee09081 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_42.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_43.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_43.png new file mode 100644 index 000000000..6a76da185 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_43.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_44.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_44.png new file mode 100644 index 000000000..ac8624256 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_44.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_5.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_5.png new file mode 100644 index 000000000..08bc451e7 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_5.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_6.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_6.png new file mode 100644 index 000000000..6939974c7 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_6.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_7.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_7.png new file mode 100644 index 000000000..01637e4c6 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_7.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_8.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_8.png new file mode 100644 index 000000000..bedf8fbf4 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_8.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_9.png b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_9.png new file mode 100644 index 000000000..33cada166 Binary files /dev/null and b/samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_9.png differ diff --git a/samples/SupportLeanbackDemos/res/drawable/tv_content.xml b/samples/SupportLeanbackDemos/res/drawable/tv_content.xml new file mode 100644 index 000000000..5007e879f --- /dev/null +++ b/samples/SupportLeanbackDemos/res/drawable/tv_content.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/SupportLeanbackDemos/res/layout/onboarding_content.xml b/samples/SupportLeanbackDemos/res/layout/onboarding_content.xml new file mode 100644 index 000000000..7a3edf963 --- /dev/null +++ b/samples/SupportLeanbackDemos/res/layout/onboarding_content.xml @@ -0,0 +1,35 @@ + + + + + + + diff --git a/samples/SupportLeanbackDemos/res/layout/onboarding_image.xml b/samples/SupportLeanbackDemos/res/layout/onboarding_image.xml index 69206453f..2962b01b3 100644 --- a/samples/SupportLeanbackDemos/res/layout/onboarding_image.xml +++ b/samples/SupportLeanbackDemos/res/layout/onboarding_image.xml @@ -20,4 +20,5 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitCenter" - android:src="@drawable/bg"/> + android:src="@drawable/bg" + android:contentDescription="@null" /> diff --git a/samples/SupportLeanbackDemos/res/values/arrays.xml b/samples/SupportLeanbackDemos/res/values/arrays.xml index dd524765b..307f49d62 100644 --- a/samples/SupportLeanbackDemos/res/values/arrays.xml +++ b/samples/SupportLeanbackDemos/res/values/arrays.xml @@ -27,7 +27,7 @@ Announce your new features. - Just override OnbaordingFragment and provide the messages and images. + Just override OnboardingFragment and provide the messages and images. Customize your own logo image, splash animation and the contents animations. diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoFragment.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoFragment.java index 3ac8c3b38..5868c26b3 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoFragment.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoFragment.java @@ -17,11 +17,11 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.graphics.drawable.AnimationDrawable; import android.support.v17.leanback.app.OnboardingFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.ViewGroup.MarginLayoutParams; import android.widget.ImageView; import java.util.ArrayList; @@ -29,18 +29,25 @@ import java.util.ArrayList; public class OnboardingDemoFragment extends OnboardingFragment { private static final long ANIMATION_DURATION = 1000; - private static final int[] CONTENT_IMAGES = { - R.drawable.gallery_photo_1, - R.drawable.gallery_photo_2, - R.drawable.gallery_photo_3 + private static final int[] CONTENT_BACKGROUNDS = { + R.drawable.tv_bg, + R.drawable.gallery_photo_6, + R.drawable.gallery_photo_8 }; + + private static final int[] CONTENT_ANIMATIONS = { + R.drawable.tv_content, + android.R.drawable.stat_sys_download, + android.R.drawable.ic_popup_sync + }; + private String[] mTitles; private String[] mDescriptions; private View mBackgroundView; - private ImageView mContentView; - private ImageView mImage1; - private ImageView mImage2; + private View mContentView; + private ImageView mContentBackgroundView; + private ImageView mContentAnimationView; private Animator mContentAnimator; @@ -75,11 +82,9 @@ public class OnboardingDemoFragment extends OnboardingFragment { @Override protected View onCreateContentView(LayoutInflater layoutInflater, ViewGroup viewGroup) { - mContentView = (ImageView) layoutInflater.inflate(R.layout.onboarding_image, viewGroup, - false); - MarginLayoutParams layoutParams = ((MarginLayoutParams) mContentView.getLayoutParams()); - layoutParams.topMargin = 30; - layoutParams.bottomMargin = 60; + mContentView = layoutInflater.inflate(R.layout.onboarding_content, viewGroup, false); + mContentBackgroundView = (ImageView) mContentView.findViewById(R.id.background_image); + mContentAnimationView = (ImageView) mContentView.findViewById(R.id.animation_image); return mContentView; } @@ -92,31 +97,45 @@ public class OnboardingDemoFragment extends OnboardingFragment { protected Animator onCreateEnterAnimation() { ArrayList animators = new ArrayList<>(); animators.add(createFadeInAnimator(mBackgroundView)); - mContentView.setImageResource(CONTENT_IMAGES[0]); + mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[0]); + mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[0]); mContentAnimator = createFadeInAnimator(mContentView); animators.add(mContentAnimator); AnimatorSet set = new AnimatorSet(); set.playTogether(animators); + set.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + ((AnimationDrawable) mContentAnimationView.getDrawable()).start(); + } + }); return set; } @Override protected void onPageChanged(final int newPage, int previousPage) { if (mContentAnimator != null) { - mContentAnimator.end(); + mContentAnimator.cancel(); } + ((AnimationDrawable) mContentAnimationView.getDrawable()).stop(); ArrayList animators = new ArrayList<>(); Animator fadeOut = createFadeOutAnimator(mContentView); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - mContentView.setImageResource(CONTENT_IMAGES[newPage]); + mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[newPage]); + mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[newPage]); + } + }); + Animator fadeIn = createFadeInAnimator(mContentView); + fadeIn.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + ((AnimationDrawable) mContentAnimationView.getDrawable()).start(); } }); - animators.add(fadeOut); - animators.add(createFadeInAnimator(mContentView)); AnimatorSet set = new AnimatorSet(); - set.playSequentially(animators); + set.playSequentially(fadeOut, fadeIn); set.start(); mContentAnimator = set; } diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoSupportFragment.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoSupportFragment.java index 30ae0779b..32f38f399 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoSupportFragment.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/OnboardingDemoSupportFragment.java @@ -19,11 +19,11 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; +import android.graphics.drawable.AnimationDrawable; import android.support.v17.leanback.app.OnboardingSupportFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.ViewGroup.MarginLayoutParams; import android.widget.ImageView; import java.util.ArrayList; @@ -31,18 +31,25 @@ import java.util.ArrayList; public class OnboardingDemoSupportFragment extends OnboardingSupportFragment { private static final long ANIMATION_DURATION = 1000; - private static final int[] CONTENT_IMAGES = { - R.drawable.gallery_photo_1, - R.drawable.gallery_photo_2, - R.drawable.gallery_photo_3 + private static final int[] CONTENT_BACKGROUNDS = { + R.drawable.tv_bg, + R.drawable.gallery_photo_6, + R.drawable.gallery_photo_8 }; + + private static final int[] CONTENT_ANIMATIONS = { + R.drawable.tv_content, + android.R.drawable.stat_sys_download, + android.R.drawable.ic_popup_sync + }; + private String[] mTitles; private String[] mDescriptions; private View mBackgroundView; - private ImageView mContentView; - private ImageView mImage1; - private ImageView mImage2; + private View mContentView; + private ImageView mContentBackgroundView; + private ImageView mContentAnimationView; private Animator mContentAnimator; @@ -77,11 +84,9 @@ public class OnboardingDemoSupportFragment extends OnboardingSupportFragment { @Override protected View onCreateContentView(LayoutInflater layoutInflater, ViewGroup viewGroup) { - mContentView = (ImageView) layoutInflater.inflate(R.layout.onboarding_image, viewGroup, - false); - MarginLayoutParams layoutParams = ((MarginLayoutParams) mContentView.getLayoutParams()); - layoutParams.topMargin = 30; - layoutParams.bottomMargin = 60; + mContentView = layoutInflater.inflate(R.layout.onboarding_content, viewGroup, false); + mContentBackgroundView = (ImageView) mContentView.findViewById(R.id.background_image); + mContentAnimationView = (ImageView) mContentView.findViewById(R.id.animation_image); return mContentView; } @@ -94,31 +99,45 @@ public class OnboardingDemoSupportFragment extends OnboardingSupportFragment { protected Animator onCreateEnterAnimation() { ArrayList animators = new ArrayList<>(); animators.add(createFadeInAnimator(mBackgroundView)); - mContentView.setImageResource(CONTENT_IMAGES[0]); + mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[0]); + mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[0]); mContentAnimator = createFadeInAnimator(mContentView); animators.add(mContentAnimator); AnimatorSet set = new AnimatorSet(); set.playTogether(animators); + set.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + ((AnimationDrawable) mContentAnimationView.getDrawable()).start(); + } + }); return set; } @Override protected void onPageChanged(final int newPage, int previousPage) { if (mContentAnimator != null) { - mContentAnimator.end(); + mContentAnimator.cancel(); } + ((AnimationDrawable) mContentAnimationView.getDrawable()).stop(); ArrayList animators = new ArrayList<>(); Animator fadeOut = createFadeOutAnimator(mContentView); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - mContentView.setImageResource(CONTENT_IMAGES[newPage]); + mContentBackgroundView.setImageResource(CONTENT_BACKGROUNDS[newPage]); + mContentAnimationView.setImageResource(CONTENT_ANIMATIONS[newPage]); + } + }); + Animator fadeIn = createFadeInAnimator(mContentView); + fadeIn.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + ((AnimationDrawable) mContentAnimationView.getDrawable()).start(); } }); - animators.add(fadeOut); - animators.add(createFadeInAnimator(mContentView)); AnimatorSet set = new AnimatorSet(); - set.playSequentially(animators); + set.playSequentially(fadeOut, fadeIn); set.start(); mContentAnimator = set; }