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