Project

General

Profile

« Previous | Next » 

Revision 06c636a5

Added by Leszek Koltunski almost 6 years ago

More progress with Effects3D app.

View differences:

src/main/java/org/distorted/examples/effects3d/Effects3DActivity2.java
47 47

  
48 48
public class Effects3DActivity2 extends AppCompatActivity
49 49
  {
50
  public static final int NUM_TABS = 3;
51

  
50 52
  private int mNumCols;
51 53
  private int mNumRows;
52 54
  private int mNumSlic;
......
69 71
  private static boolean mShowNormal = true;
70 72
  private static boolean mUseOIT     = false;
71 73

  
74
  private Effects3DTab[] mTab;
75

  
72 76
///////////////////////////////////////////////////////////////////////////////////////////////////
73 77

  
74 78
  @Override
......
78 82

  
79 83
    setTheme(R.style.Theme_AppCompat_NoActionBar);
80 84

  
85
    mTab = new Effects3DTab[NUM_TABS];
86

  
81 87
    Bundle b = getIntent().getExtras();
82 88

  
83 89
    mObjectType = b.getInt("type");
......
102 108
    setContentView(view);
103 109

  
104 110
    mViewPager = findViewById(R.id.effects3d_viewpager);
105
    mViewPager.setOffscreenPageLimit(2);
111
    mViewPager.setOffscreenPageLimit( (NUM_TABS+1)/2 );
106 112
    mPager = new Effects3DTabViewPager(this, getSupportFragmentManager() );
107 113
    mViewPager.setAdapter(mPager);
108 114
    TabLayout tabLayout = findViewById(R.id.effects3d_sliding_tabs);
......
291 297

  
292 298
  public void newEffect(View v)
293 299
    {
294
    mPager.newEffect(v,mViewPager.getCurrentItem());
300
    int pos = mViewPager.getCurrentItem();
301

  
302
    if( pos>=0 && pos<NUM_TABS ) mTab[pos].newEffect();
295 303
    }
296 304

  
297 305
///////////////////////////////////////////////////////////////////////////////////////////////////
298 306

  
299 307
  public void removeAll(View v)
300 308
    {
301
    mPager.removeAll(v,mViewPager.getCurrentItem());
309
    int pos = mViewPager.getCurrentItem();
310

  
311
    if( pos>=0 && pos<NUM_TABS ) mTab[pos].removeAll();
302 312
    }
303 313

  
304 314
///////////////////////////////////////////////////////////////////////////////////////////////////
305 315

  
306 316
  public void remove(View v)
307 317
    {
308
    mPager.remove(v,mViewPager.getCurrentItem());
318
    int pos = mViewPager.getCurrentItem();
319

  
320
    if( pos>=0 && pos<NUM_TABS ) mTab[pos].remove(v);
321
    }
322

  
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

  
325
  void setTab(int pos, Effects3DTab tab)
326
    {
327
    if( pos>=0 && pos<NUM_TABS ) mTab[pos] = tab;
309 328
    }
310 329

  
311 330
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff