diff options
author | Adam Cohen <adamcohen@google.com> | 2010-11-03 13:27:40 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2010-11-10 17:18:37 -0800 |
commit | a02fdf1ba03fad71cc80a89dfc74b17456d5b4a5 (patch) | |
tree | 79c461e2fe264625da73b202c6acf3ef639e9813 /core/java/android/widget | |
parent | ec4d82046bcdaa6ea1d43601c9d0673444f3e3bf (diff) | |
download | frameworks_base-a02fdf1ba03fad71cc80a89dfc74b17456d5b4a5.zip frameworks_base-a02fdf1ba03fad71cc80a89dfc74b17456d5b4a5.tar.gz frameworks_base-a02fdf1ba03fad71cc80a89dfc74b17456d5b4a5.tar.bz2 |
Adding widget auto-advance capability
Change-Id: I058573f40a48fd7b5c2efa5f1041a1199919a51a
Diffstat (limited to 'core/java/android/widget')
-rw-r--r-- | core/java/android/widget/AdapterViewAnimator.java | 9 | ||||
-rw-r--r-- | core/java/android/widget/AdapterViewFlipper.java | 10 | ||||
-rw-r--r-- | core/java/android/widget/Advanceable.java | 38 | ||||
-rw-r--r-- | core/java/android/widget/StackView.java | 3 |
4 files changed, 58 insertions, 2 deletions
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java index 1f98c88..7d78777 100644 --- a/core/java/android/widget/AdapterViewAnimator.java +++ b/core/java/android/widget/AdapterViewAnimator.java @@ -45,7 +45,7 @@ import android.view.ViewGroup; * @attr ref android.R.styleable#AdapterViewAnimator_loopViews */ public abstract class AdapterViewAnimator extends AdapterView<Adapter> - implements RemoteViewsAdapter.RemoteAdapterConnectionCallback { + implements RemoteViewsAdapter.RemoteAdapterConnectionCallback, Advanceable { private static final String TAG = "RemoteViewAnimator"; /** @@ -965,4 +965,11 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter> setAdapter(mRemoteViewsAdapter); } } + + public void advance() { + showNext(); + } + + public void willBeAdvancedByHost() { + } } diff --git a/core/java/android/widget/AdapterViewFlipper.java b/core/java/android/widget/AdapterViewFlipper.java index b09ade7..7721688 100644 --- a/core/java/android/widget/AdapterViewFlipper.java +++ b/core/java/android/widget/AdapterViewFlipper.java @@ -52,6 +52,7 @@ public class AdapterViewFlipper extends AdapterViewAnimator { private boolean mStarted = false; private boolean mVisible = false; private boolean mUserPresent = true; + private boolean mAdvancedByHost = false; public AdapterViewFlipper(Context context) { super(context); @@ -203,7 +204,8 @@ public class AdapterViewFlipper extends AdapterViewAnimator { * true. */ private void updateRunning(boolean flipNow) { - boolean running = mVisible && mStarted && mUserPresent && mAdapter != null; + boolean running = !mAdvancedByHost && mVisible && mStarted && mUserPresent + && mAdapter != null; if (running != mRunning) { if (running) { showOnly(mWhichChild, flipNow); @@ -255,4 +257,10 @@ public class AdapterViewFlipper extends AdapterViewAnimator { } } }; + + @Override + public void willBeAdvancedByHost() { + mAdvancedByHost = true; + updateRunning(false); + } } diff --git a/core/java/android/widget/Advanceable.java b/core/java/android/widget/Advanceable.java new file mode 100644 index 0000000..bb162de --- /dev/null +++ b/core/java/android/widget/Advanceable.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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 android.widget; + +/** + * This interface can be implemented by any collection-type view which has a notion of + * progressing through its set of children. The interface exists to give AppWidgetHosts a way of + * taking responsibility for automatically advancing such collections. + * + * @hide + */ +public interface Advanceable { + + /** + * Advances this collection, eg. shows the next view. + */ + public void advance(); + + /** + * Called by the AppWidgetHost once before it begins to call advance(), allowing the + * collection to do any required setup. + */ + public void willBeAdvancedByHost(); +} diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index a27e1cc..01044d9 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -674,6 +674,8 @@ public class StackView extends AdapterViewAnimator { r = Math.max(0, r); mYProgress = r; + if (mView == null) return; + final LayoutParams viewLp = (LayoutParams) mView.getLayoutParams(); final LayoutParams highlightLp = (LayoutParams) mHighlight.getLayoutParams(); @@ -722,6 +724,7 @@ public class StackView extends AdapterViewAnimator { mXProgress = r; + if (mView == null) return; final LayoutParams viewLp = (LayoutParams) mView.getLayoutParams(); final LayoutParams highlightLp = (LayoutParams) mHighlight.getLayoutParams(); |