Home | History | Annotate | Download | only in shadows
      1 package com.xtremelabs.robolectric.shadows;
      2 
      3 import android.widget.AbsListView;
      4 import com.xtremelabs.robolectric.internal.Implementation;
      5 import com.xtremelabs.robolectric.internal.Implements;
      6 
      7 @Implements(AbsListView.class)
      8 public class ShadowAbsListView extends ShadowAdapterView {
      9     private AbsListView.OnScrollListener onScrollListener;
     10     private int smoothScrolledPosition;
     11     private int lastSmoothScrollByDistance;
     12     private int lastSmoothScrollByDuration;
     13 
     14     @Implementation
     15     public void setOnScrollListener(AbsListView.OnScrollListener l) {
     16         onScrollListener = l;
     17     }
     18 
     19     @Implementation
     20     public void smoothScrollToPosition(int position) {
     21         smoothScrolledPosition = position;
     22     }
     23 
     24     @Implementation
     25     public void smoothScrollBy(int distance, int duration) {
     26         this.lastSmoothScrollByDistance = distance;
     27         this.lastSmoothScrollByDuration = duration;
     28     }
     29 
     30     /**
     31      * Robolectric accessor for the onScrollListener
     32      *
     33      * @return AbsListView.OnScrollListener
     34      */
     35     public AbsListView.OnScrollListener getOnScrollListener() {
     36         return onScrollListener;
     37     }
     38 
     39     /**
     40      * Robolectric accessor for the last smoothScrolledPosition
     41      *
     42      * @return int position
     43      */
     44     public int getSmoothScrolledPosition() {
     45         return smoothScrolledPosition;
     46     }
     47 
     48     /**
     49      * Robolectric accessor for the last smoothScrollBy distance
     50      *
     51      * @return int distance
     52      */
     53     public int getLastSmoothScrollByDistance() {
     54         return lastSmoothScrollByDistance;
     55     }
     56 
     57     /**
     58      * Robolectric accessor for the last smoothScrollBy duration
     59      *
     60      * @return int duration
     61      */
     62     public int getLastSmoothScrollByDuration() {
     63         return lastSmoothScrollByDuration;
     64     }
     65 }
     66