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 |
|
|
import android.app.Fragment;
|
23 |
|
|
import android.app.FragmentManager;
|
24 |
|
|
import android.support.v13.app.FragmentPagerAdapter;
|
25 |
|
|
import android.view.View;
|
26 |
|
|
|
27 |
|
|
import org.distorted.examples.R;
|
28 |
|
|
import org.distorted.library.effect.EffectType;
|
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<Effects3DActivity> mAct;
|
39 |
|
|
private Effects3DTab[] mTab;
|
40 |
|
|
|
41 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42 |
|
|
|
43 |
|
|
public Effects3DTabViewPager(Effects3DActivity act, FragmentManager fm)
|
44 |
|
|
{
|
45 |
|
|
super(fm);
|
46 |
|
|
mAct = new WeakReference<>(act);
|
47 |
|
|
mTab = new Effects3DTab[NUM_TABS];
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
51 |
|
|
|
52 |
|
|
void newEffect(View v, int pos)
|
53 |
|
|
{
|
54 |
|
|
if( pos>=0 && pos<NUM_TABS ) mTab[pos].newEffect();
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
58 |
|
|
|
59 |
|
|
void removeAll(View v, int pos)
|
60 |
|
|
{
|
61 |
|
|
if( pos>=0 && pos<NUM_TABS ) mTab[pos].removeAll();
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65 |
|
|
|
66 |
|
|
void remove(View v, int pos)
|
67 |
|
|
{
|
68 |
|
|
if( pos>=0 && pos<NUM_TABS ) mTab[pos].remove(v);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
72 |
|
|
|
73 |
|
|
@Override
|
74 |
|
|
public Fragment getItem(int position)
|
75 |
|
|
{
|
76 |
|
|
android.util.Log.e("viewPager","creating tab "+position);
|
77 |
|
|
|
78 |
|
|
switch(position)
|
79 |
|
|
{
|
80 |
|
|
case 0: mTab[0] = new Effects3DTab();
|
81 |
|
|
mTab[0].setParams(EffectType.VERTEX , mAct, R.layout.effects3dtab1, R.id.effects3dlayout1, R.id.effects3dspinner1);
|
82 |
|
|
return mTab[0];
|
83 |
|
|
case 1: mTab[1] = new Effects3DTab();
|
84 |
|
|
mTab[1].setParams(EffectType.FRAGMENT , mAct, R.layout.effects3dtab2, R.id.effects3dlayout2, R.id.effects3dspinner2);
|
85 |
|
|
return mTab[1];
|
86 |
|
|
case 2: mTab[2] = new Effects3DTab();
|
87 |
|
|
mTab[2].setParams(EffectType.POSTPROCESS, mAct, R.layout.effects3dtab3, R.id.effects3dlayout3, R.id.effects3dspinner3);
|
88 |
|
|
return mTab[2];
|
89 |
|
|
default: return null;
|
90 |
|
|
}
|
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 |
|
|
}
|