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.view.View;
|
26
|
import android.os.Bundle;
|
27
|
|
28
|
import org.distorted.examples.R;
|
29
|
|
30
|
import java.lang.ref.WeakReference;
|
31
|
|
32
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
33
|
|
34
|
public class Effects3DTabViewPager extends FragmentPagerAdapter
|
35
|
{
|
36
|
private static final int NUM_TABS = 3;
|
37
|
|
38
|
private WeakReference<Effects3DActivity2> mAct;
|
39
|
private Effects3DTab[] mTab;
|
40
|
|
41
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42
|
|
43
|
public Effects3DTabViewPager(Effects3DActivity2 act, FragmentManager fm)
|
44
|
{
|
45
|
super(fm);
|
46
|
mAct = new WeakReference<>(act);
|
47
|
mTab = new Effects3DTab[NUM_TABS];
|
48
|
|
49
|
android.util.Log.e("viewPager"," CONSTRUCTOR ");
|
50
|
}
|
51
|
|
52
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53
|
|
54
|
void newEffect(View v, int pos)
|
55
|
{
|
56
|
if( pos>=0 && pos<NUM_TABS ) mTab[pos].newEffect();
|
57
|
}
|
58
|
|
59
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
60
|
|
61
|
void removeAll(View v, int pos)
|
62
|
{
|
63
|
if( pos>=0 && pos<NUM_TABS ) mTab[pos].removeAll();
|
64
|
}
|
65
|
|
66
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67
|
|
68
|
void remove(View v, int pos)
|
69
|
{
|
70
|
if( pos>=0 && pos<NUM_TABS ) mTab[pos].remove(v);
|
71
|
}
|
72
|
|
73
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
74
|
|
75
|
@Override
|
76
|
public Fragment getItem(int position)
|
77
|
{
|
78
|
android.util.Log.e("viewPager","creating tab "+position);
|
79
|
|
80
|
if( position>=0 && position<NUM_TABS )
|
81
|
{
|
82
|
Bundle bundle = new Bundle();
|
83
|
bundle.putInt("position", position);
|
84
|
|
85
|
mTab[position] = new Effects3DTab();
|
86
|
mTab[position].setArguments(bundle);
|
87
|
return mTab[position];
|
88
|
}
|
89
|
|
90
|
return null;
|
91
|
}
|
92
|
|
93
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
94
|
|
95
|
@Override
|
96
|
public int getCount()
|
97
|
{
|
98
|
return NUM_TABS;
|
99
|
}
|
100
|
|
101
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
102
|
|
103
|
@Override
|
104
|
public CharSequence getPageTitle(int position)
|
105
|
{
|
106
|
switch (position)
|
107
|
{
|
108
|
case 0 : return mAct.get().getString(R.string.type_vertex);
|
109
|
case 1 : return mAct.get().getString(R.string.type_fragment);
|
110
|
case 2 : return mAct.get().getString(R.string.type_postprocess);
|
111
|
default: return null;
|
112
|
}
|
113
|
}
|
114
|
}
|