Demos should use main activity context, not getApplicationContext()
Change-Id: I561defd90760864a975b905f13cf30c422da6125
diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java b/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java
index 88df19f..910ee28 100644
--- a/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java
+++ b/samples/ApiDemos/src/com/example/android/apis/animation/AnimationLoading.java
@@ -81,14 +81,16 @@
}
private void createAnimation() {
+ Context appContext = AnimationLoading.this;
+
if (animation == null) {
ObjectAnimator anim = (ObjectAnimator) AnimatorInflater.
- loadAnimator(getApplicationContext(), R.anim.object_animator);
+ loadAnimator(appContext, R.anim.object_animator);
anim.addUpdateListener(this);
anim.setTarget(balls.get(0));
ValueAnimator fader = (ValueAnimator) AnimatorInflater.
- loadAnimator(getApplicationContext(), R.anim.animator);
+ loadAnimator(appContext, R.anim.animator);
fader.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
balls.get(1).setAlpha((Float) animation.getAnimatedValue());
@@ -96,12 +98,12 @@
});
AnimatorSet seq =
- (AnimatorSet) AnimatorInflater.loadAnimator(getApplicationContext(),
+ (AnimatorSet) AnimatorInflater.loadAnimator(appContext,
R.anim.animator_set);
seq.setTarget(balls.get(2));
ObjectAnimator colorizer = (ObjectAnimator) AnimatorInflater.
- loadAnimator(getApplicationContext(), R.anim.color_animator);
+ loadAnimator(appContext, R.anim.color_animator);
colorizer.setTarget(balls.get(3));
animation = new AnimatorSet();
diff --git a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsByDefault.java b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsByDefault.java
index 81d3469..67b9b51 100644
--- a/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsByDefault.java
+++ b/samples/ApiDemos/src/com/example/android/apis/animation/LayoutAnimationsByDefault.java
@@ -48,7 +48,7 @@
Button addButton = (Button) findViewById(R.id.addNewButton);
addButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- Button newButton = new Button(getApplicationContext());
+ Button newButton = new Button(LayoutAnimationsByDefault.this);
newButton.setText("Click To Remove " + (numButtons++));
newButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -57,7 +57,7 @@
});
horizontalContainer.addView(newButton, Math.min(1, horizontalContainer.getChildCount()));
- newButton = new Button(getApplicationContext());
+ newButton = new Button(LayoutAnimationsByDefault.this);
newButton.setText("Click To Remove " + (numButtons++));
newButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {