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
|
|
45
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46
|
|
47
|
@Override
|
48
|
public Fragment getItem(int position)
|
49
|
{
|
50
|
if( position>=0 && position<Effects3DActivity2.NUM_TABS )
|
51
|
{
|
52
|
Effects3DTab tab = new Effects3DTab();
|
53
|
|
54
|
Bundle bundle = new Bundle();
|
55
|
bundle.putInt("position", position);
|
56
|
tab.setArguments(bundle);
|
57
|
|
58
|
return tab;
|
59
|
}
|
60
|
|
61
|
return null;
|
62
|
}
|
63
|
|
64
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65
|
|
66
|
@Override
|
67
|
public int getCount()
|
68
|
{
|
69
|
return Effects3DActivity2.NUM_TABS;
|
70
|
}
|
71
|
|
72
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
73
|
|
74
|
@Override
|
75
|
public CharSequence getPageTitle(int position)
|
76
|
{
|
77
|
switch (position)
|
78
|
{
|
79
|
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
|
default: return null;
|
84
|
}
|
85
|
}
|
86
|
}
|