Merge pull request #15824 from tkunic/f_xml_animation

Move SpeechActivity animation to XML.
This commit is contained in:
Martin Wicke 2018-02-15 17:20:35 -08:00 committed by GitHub
commit 00b1261db0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 12 deletions

View 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>

View File

@ -31,7 +31,8 @@ the RecognizeCommands helper class.
package org.tensorflow.demo;
import android.animation.ValueAnimator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.media.AudioFormat;
@ -329,17 +330,11 @@ public class SpeechActivity extends Activity {
labelIndex = i;
}
}
final View labelView = (View) labelsListView.getChildAt(labelIndex - 2);
ValueAnimator colorAnimation =
ValueAnimator.ofArgb(0x00b3ccff, 0xffb3ccff, 0x00b3ccff);
colorAnimation.setDuration(750);
colorAnimation.addUpdateListener(
new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
labelView.setBackgroundColor((int) animator.getAnimatedValue());
}
});
final View labelView = labelsListView.getChildAt(labelIndex - 2);
AnimatorSet colorAnimation = (AnimatorSet) AnimatorInflater.loadAnimator(
SpeechActivity.this, R.animator.color_animation);
colorAnimation.setTarget(labelView);
colorAnimation.start();
}
}