Merge "Change contents animations" into nyc-dev
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_bg.png
Normal file
|
After Width: | Height: | Size: 765 B |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_1.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_2.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_3.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_4.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_5.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_6.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_7.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_8.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
samples/SupportLeanbackDemos/res/drawable-xhdpi/tv_content_9.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
64
samples/SupportLeanbackDemos/res/drawable/tv_content.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:oneshot="true">
|
||||
<item android:drawable="@drawable/tv_content_1" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_2" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_3" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_4" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_5" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_6" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_7" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_8" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_9" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_10" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_11" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_12" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_13" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_14" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_15" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_16" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_17" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_18" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_19" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_20" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_21" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_22" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_23" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_24" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_25" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_26" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_27" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_28" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_29" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_30" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_31" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_32" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_33" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_34" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_35" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_36" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_37" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_38" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_39" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_40" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_41" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_42" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_43" android:duration="33" />
|
||||
<item android:drawable="@drawable/tv_content_44" android:duration="33" />
|
||||
</animation-list>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/background_image"
|
||||
android:layout_width="215dp"
|
||||
android:layout_height="128dp"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="fitCenter"
|
||||
android:contentDescription="@null" />
|
||||
<ImageView
|
||||
android:id="@+id/animation_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="center"
|
||||
android:contentDescription="@null" />
|
||||
</FrameLayout>
|
||||
@@ -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" />
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<!-- Descriptions in the onboarding page. -->
|
||||
<string-array name="onboarding_page_descriptions">
|
||||
<item>Announce your new features.</item>
|
||||
<item>Just override OnbaordingFragment and provide the messages and images.</item>
|
||||
<item>Just override OnboardingFragment and provide the messages and images.</item>
|
||||
<item>Customize your own logo image, splash animation and the contents animations.</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -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<Animator> 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<Animator> 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;
|
||||
}
|
||||
|
||||
@@ -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<Animator> 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<Animator> 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;
|
||||
}
|
||||
|
||||