Project

General

Profile

Download (3.64 KB) Statistics
| Branch: | Revision:

examples / src / main / java / org / distorted / examples / effects3d / Effects3DTabViewPager.java @ 06c636a5

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2018 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.examples.effects3d;
21

    
22
import android.support.v4.app.Fragment;
23
import android.support.v4.app.FragmentManager;
24
import android.support.v4.app.FragmentPagerAdapter;
25
import android.os.Bundle;
26

    
27
import org.distorted.examples.R;
28

    
29
import java.lang.ref.WeakReference;
30

    
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
public class Effects3DTabViewPager extends FragmentPagerAdapter
34
  {
35
  private WeakReference<Effects3DActivity2> mAct;
36

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

    
39
  Effects3DTabViewPager(Effects3DActivity2 act, FragmentManager fm)
40
    {
41
    super(fm);
42
    mAct = new WeakReference<>(act);
43

    
44
    android.util.Log.e("viewPager"," CONSTRUCTOR ");
45
    }
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  @Override
50
  public Fragment getItem(int position)
51
    {
52
    android.util.Log.e("viewPager","creating tab "+position);
53

    
54
    if( position>=0 && position<Effects3DActivity2.NUM_TABS )
55
      {
56
      Bundle bundle = new Bundle();
57
      bundle.putInt("position", position);
58

    
59
      Effects3DTab tab = new Effects3DTab();
60
      tab.setArguments(bundle);
61
      return tab;
62
      }
63

    
64
    return null;
65
    }
66

    
67
///////////////////////////////////////////////////////////////////////////////////////////////////
68

    
69
  @Override
70
  public int getCount()
71
    {
72
    return Effects3DActivity2.NUM_TABS;
73
    }
74

    
75
///////////////////////////////////////////////////////////////////////////////////////////////////
76

    
77
  @Override
78
  public CharSequence getPageTitle(int position)
79
    {
80
    switch (position)
81
      {
82
      case 0 : return mAct.get().getString(R.string.type_vertex);
83
      case 1 : return mAct.get().getString(R.string.type_fragment);
84
      case 2 : return mAct.get().getString(R.string.type_postprocess);
85
      default: return null;
86
      }
87
    }
88
  }
(7-7/7)