• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.view.View;
4 import android.widget.ViewAnimator;
5 
6 import com.xtremelabs.robolectric.internal.Implementation;
7 import com.xtremelabs.robolectric.internal.Implements;
8 
9 @Implements(ViewAnimator.class)
10 public class ShadowViewAnimator extends ShadowFrameLayout {
11     private int mWhichChild = 0;
12 
13     @Implementation
showNext()14     public void showNext() {
15         setDisplayedChild(mWhichChild + 1);
16     }
17 
18     @Implementation
showPrevious()19     public void showPrevious() {
20         setDisplayedChild(mWhichChild - 1);
21     }
22 
23     @Implementation
setDisplayedChild(int whichChild)24     public void setDisplayedChild(int whichChild) {
25         mWhichChild = whichChild;
26         if (whichChild >= getChildCount()) {
27             mWhichChild = 0;
28         } else if (whichChild < 0) {
29             mWhichChild = getChildCount() - 1;
30         }
31     }
32 
33     @Implementation
getDisplayedChild()34     public int getDisplayedChild() {
35         return mWhichChild;
36     }
37 
38     @Implementation
getCurrentView()39     public View getCurrentView() {
40         return getChildAt(mWhichChild);
41     }
42 }
43