Project

General

Profile

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

examples / src / main / java / org / distorted / examples / effects3d / Effects3DTabViewPager.java @ 107e4b72

1 fe7fe83e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 c2c45d0a Leszek Koltunski
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 fe7fe83e Leszek Koltunski
27
import org.distorted.examples.R;
28
29
import java.lang.ref.WeakReference;
30
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32
33
public class Effects3DTabViewPager extends FragmentPagerAdapter
34
  {
35 348dbeea Leszek Koltunski
  private WeakReference<Effects3DActivity2> mAct;
36 fe7fe83e Leszek Koltunski
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38
39 06c636a5 Leszek Koltunski
  Effects3DTabViewPager(Effects3DActivity2 act, FragmentManager fm)
40 fe7fe83e Leszek Koltunski
    {
41
    super(fm);
42
    mAct = new WeakReference<>(act);
43
    }
44
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46
47
  @Override
48
  public Fragment getItem(int position)
49
    {
50 06c636a5 Leszek Koltunski
    if( position>=0 && position<Effects3DActivity2.NUM_TABS )
51 fe7fe83e Leszek Koltunski
      {
52 65f622c1 Leszek Koltunski
      Effects3DTab tab = new Effects3DTab();
53
54 cf6fb87f Leszek Koltunski
      Bundle bundle = new Bundle();
55
      bundle.putInt("position", position);
56 06c636a5 Leszek Koltunski
      tab.setArguments(bundle);
57 65f622c1 Leszek Koltunski
58 06c636a5 Leszek Koltunski
      return tab;
59 fe7fe83e Leszek Koltunski
      }
60 cf6fb87f Leszek Koltunski
61
    return null;
62 fe7fe83e Leszek Koltunski
    }
63
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65
66
  @Override
67
  public int getCount()
68
    {
69 06c636a5 Leszek Koltunski
    return Effects3DActivity2.NUM_TABS;
70 fe7fe83e Leszek Koltunski
    }
71
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73
74
  @Override
75
  public CharSequence getPageTitle(int position)
76
    {
77
    switch (position)
78
      {
79 65f622c1 Leszek Koltunski
      case 0 : return mAct.get().getString(R.string.type_matrix);
80
      case 1 : return mAct.get().getString(R.string.type_vertex);
81
      case 2 : return mAct.get().getString(R.string.type_fragment);
82
      case 3 : return mAct.get().getString(R.string.type_postprocess);
83 fe7fe83e Leszek Koltunski
      default: return null;
84
      }
85
    }
86
  }