Revision 06c636a5
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/examples/effects3d/Effects3DTabViewPager.java | ||
---|---|---|
22 | 22 |
import android.support.v4.app.Fragment; |
23 | 23 |
import android.support.v4.app.FragmentManager; |
24 | 24 |
import android.support.v4.app.FragmentPagerAdapter; |
25 |
import android.view.View; |
|
26 | 25 |
import android.os.Bundle; |
27 | 26 |
|
28 | 27 |
import org.distorted.examples.R; |
... | ... | |
33 | 32 |
|
34 | 33 |
public class Effects3DTabViewPager extends FragmentPagerAdapter |
35 | 34 |
{ |
36 |
private static final int NUM_TABS = 3; |
|
37 |
|
|
38 | 35 |
private WeakReference<Effects3DActivity2> mAct; |
39 |
private Effects3DTab[] mTab; |
|
40 | 36 |
|
41 | 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
42 | 38 |
|
43 |
public Effects3DTabViewPager(Effects3DActivity2 act, FragmentManager fm)
|
|
39 |
Effects3DTabViewPager(Effects3DActivity2 act, FragmentManager fm) |
|
44 | 40 |
{ |
45 | 41 |
super(fm); |
46 | 42 |
mAct = new WeakReference<>(act); |
47 |
mTab = new Effects3DTab[NUM_TABS]; |
|
48 | 43 |
|
49 | 44 |
android.util.Log.e("viewPager"," CONSTRUCTOR "); |
50 | 45 |
} |
51 | 46 |
|
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 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
74 | 48 |
|
75 | 49 |
@Override |
... | ... | |
77 | 51 |
{ |
78 | 52 |
android.util.Log.e("viewPager","creating tab "+position); |
79 | 53 |
|
80 |
if( position>=0 && position<NUM_TABS ) |
|
54 |
if( position>=0 && position<Effects3DActivity2.NUM_TABS )
|
|
81 | 55 |
{ |
82 | 56 |
Bundle bundle = new Bundle(); |
83 | 57 |
bundle.putInt("position", position); |
84 | 58 |
|
85 |
mTab[position] = new Effects3DTab();
|
|
86 |
mTab[position].setArguments(bundle);
|
|
87 |
return mTab[position];
|
|
59 |
Effects3DTab tab = new Effects3DTab();
|
|
60 |
tab.setArguments(bundle);
|
|
61 |
return tab;
|
|
88 | 62 |
} |
89 | 63 |
|
90 | 64 |
return null; |
... | ... | |
95 | 69 |
@Override |
96 | 70 |
public int getCount() |
97 | 71 |
{ |
98 |
return NUM_TABS; |
|
72 |
return Effects3DActivity2.NUM_TABS;
|
|
99 | 73 |
} |
100 | 74 |
|
101 | 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
More progress with Effects3D app.