diff options
author | John Reck <jreck@google.com> | 2014-07-15 14:29:33 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-07-18 22:10:22 +0000 |
commit | d3de42cae84fadfa1befd082a2cf1bf72f9ad82a (patch) | |
tree | e3bff6900caa9cc6546dc6e843f37414192fcc74 /tests | |
parent | fac77c46fe03466cb4bd728da3dc49b40652964b (diff) | |
download | frameworks_base-d3de42cae84fadfa1befd082a2cf1bf72f9ad82a.zip frameworks_base-d3de42cae84fadfa1befd082a2cf1bf72f9ad82a.tar.gz frameworks_base-d3de42cae84fadfa1befd082a2cf1bf72f9ad82a.tar.bz2 |
Add RT-enabled reveal animator
Bug: 16161431
Also re-writes RevealAnimator to avoid using any listeners internally,
removing the logic around shadowing the update listeners.
Change-Id: I6ed8126398eed971a87f20bccb7584c9acafbb6c
Diffstat (limited to 'tests')
-rw-r--r-- | tests/HwAccelerationTest/AndroidManifest.xml | 28 | ||||
-rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/RevealActivity.java | 91 |
2 files changed, 110 insertions, 9 deletions
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 544553e..bc2f1fd 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -306,15 +306,6 @@ </activity> <activity - android:name="CirclePropActivity" - android:label="Draw/Circle Props"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="com.android.test.hwui.TEST" /> - </intent-filter> - </activity> - - <activity android:name="ClearActivity" android:label="Window/Clear"> <intent-filter> @@ -920,5 +911,24 @@ <category android:name="com.android.test.hwui.TEST" /> </intent-filter> </activity> + + <activity + android:name="CirclePropActivity" + android:label="Animation/Circle Props"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + + <activity + android:name="RevealActivity" + android:label="Animation/Reveal Animation"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="com.android.test.hwui.TEST" /> + </intent-filter> + </activity> + </application> </manifest> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/RevealActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/RevealActivity.java new file mode 100644 index 0000000..d27be69 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/RevealActivity.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2014 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. + */ + +package com.android.test.hwui; + +import android.animation.ValueAnimator; +import android.app.Activity; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.os.Bundle; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewAnimationUtils; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.ProgressBar; + +public class RevealActivity extends Activity implements OnClickListener { + + private static final int DURATION = 800; + + private boolean mShouldBlock; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final LinearLayout layout = new LinearLayout(this); + layout.setOrientation(LinearLayout.VERTICAL); + + ProgressBar spinner = new ProgressBar(this, null, android.R.attr.progressBarStyleLarge); + layout.addView(spinner, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + View revealView = new MyView(this); + layout.addView(revealView, + new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); + setContentView(layout); + + revealView.setOnClickListener(this); + } + + @Override + public void onClick(View view) { + ValueAnimator animator = ViewAnimationUtils.createCircularReveal(view, + view.getWidth() / 2, view.getHeight() / 2, + 0, Math.max(view.getWidth(), view.getHeight())); + animator.setDuration(DURATION); + animator.setAllowRunningAsynchronously(true); + animator.start(); + + mShouldBlock = !mShouldBlock; + if (mShouldBlock) { + view.post(sBlockThread); + } + } + + private final static Runnable sBlockThread = new Runnable() { + @Override + public void run() { + try { + Thread.sleep(DURATION); + } catch (InterruptedException e) { + } + } + }; + + static class MyView extends View { + + public MyView(Context context) { + super(context); + } + + @Override + protected void onDraw(Canvas canvas) { + canvas.drawColor(Color.RED); + } + } +} |