• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.support.v4.app.Fragment;
4 import android.support.v4.app.FragmentManager;
5 import android.support.v4.app.FragmentPagerAdapter;
6 import android.view.ViewGroup;
7 import com.xtremelabs.robolectric.internal.Implementation;
8 import com.xtremelabs.robolectric.internal.Implements;
9 import com.xtremelabs.robolectric.internal.RealObject;
10 
11 @Implements(FragmentPagerAdapter.class)
12 public class ShadowFragmentPagerAdapter extends ShadowPagerAdapter{
13     @RealObject
14     private FragmentPagerAdapter realAdapter;
15 
16     private FragmentManager fragmentManager;
17 
18     @Implementation
__constructor__(FragmentManager fm)19     public void __constructor__(FragmentManager fm) {
20         this.fragmentManager = fm;
21     }
22 
23     @Implementation
setPrimaryItem(ViewGroup container, int position, Object object)24     public void setPrimaryItem(ViewGroup container, int position, Object object) {
25         fragmentManager.beginTransaction().add(container.getId(), (Fragment) object).commit();
26     }
27 
28     @Implementation
instantiateItem(ViewGroup container, int position)29     public Object instantiateItem(ViewGroup container, int position) {
30         return realAdapter.getItem(position);
31     }
32 }