Merge pull request #15824 from tkunic/f_xml_animation
Move SpeechActivity animation to XML.
This commit is contained in:
commit
00b1261db0
30
tensorflow/examples/android/res/animator/color_animation.xml
Normal file
30
tensorflow/examples/android/res/animator/color_animation.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Copyright 2017 The TensorFlow Authors. All Rights Reserved.
|
||||||
|
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:ordering="sequentially">
|
||||||
|
<objectAnimator
|
||||||
|
android:propertyName="backgroundColor"
|
||||||
|
android:duration="375"
|
||||||
|
android:valueFrom="0x00b3ccff"
|
||||||
|
android:valueTo="0xffb3ccff"
|
||||||
|
android:valueType="colorType"/>
|
||||||
|
<objectAnimator
|
||||||
|
android:propertyName="backgroundColor"
|
||||||
|
android:duration="375"
|
||||||
|
android:valueFrom="0xffb3ccff"
|
||||||
|
android:valueTo="0x00b3ccff"
|
||||||
|
android:valueType="colorType"/>
|
||||||
|
</set>
|
@ -31,7 +31,8 @@ the RecognizeCommands helper class.
|
|||||||
|
|
||||||
package org.tensorflow.demo;
|
package org.tensorflow.demo;
|
||||||
|
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.AnimatorInflater;
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.media.AudioFormat;
|
import android.media.AudioFormat;
|
||||||
@ -329,17 +330,11 @@ public class SpeechActivity extends Activity {
|
|||||||
labelIndex = i;
|
labelIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final View labelView = (View) labelsListView.getChildAt(labelIndex - 2);
|
final View labelView = labelsListView.getChildAt(labelIndex - 2);
|
||||||
ValueAnimator colorAnimation =
|
|
||||||
ValueAnimator.ofArgb(0x00b3ccff, 0xffb3ccff, 0x00b3ccff);
|
AnimatorSet colorAnimation = (AnimatorSet) AnimatorInflater.loadAnimator(
|
||||||
colorAnimation.setDuration(750);
|
SpeechActivity.this, R.animator.color_animation);
|
||||||
colorAnimation.addUpdateListener(
|
colorAnimation.setTarget(labelView);
|
||||||
new ValueAnimator.AnimatorUpdateListener() {
|
|
||||||
@Override
|
|
||||||
public void onAnimationUpdate(ValueAnimator animator) {
|
|
||||||
labelView.setBackgroundColor((int) animator.getAnimatedValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
colorAnimation.start();
|
colorAnimation.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user