• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.example.android.wearable.jumpingjack;
18 
19 import android.app.Fragment;
20 import android.app.FragmentManager;
21 import android.support.v13.app.FragmentPagerAdapter;
22 
23 import java.util.ArrayList;
24 import java.util.List;
25 
26 /**
27  * A simple adapter for the {@link android.support.v4.view.ViewPager}
28  */
29 public class PagerAdapter extends FragmentPagerAdapter {
30 
31     List<Fragment> mFragments = null;
32 
PagerAdapter(FragmentManager fm)33     public PagerAdapter(FragmentManager fm) {
34         super(fm);
35         mFragments = new ArrayList<Fragment>();
36     }
37 
38     @Override
getItem(int position)39     public Fragment getItem(int position) {
40         return mFragments.get(position);
41     }
42 
43     @Override
getCount()44     public int getCount() {
45         return mFragments.size();
46     }
47 
addFragment(Fragment fragment)48     public void addFragment(Fragment fragment) {
49         mFragments.add(fragment);
50         notifyDataSetChanged();
51     }
52 }
53