Project

General

Profile

« Previous | Next » 

Revision 4888e97c

Added by Leszek Koltunski about 4 years ago

Major restructuring around making it possible to include different kinds of RubikObjects in the UI.

View differences:

src/main/java/org/distorted/dialog/RubikDialogScoresPagerAdapter.java
28 28
import android.widget.LinearLayout;
29 29

  
30 30
import org.distorted.network.RubikScoresDownloader;
31
import static org.distorted.object.RubikObjectList.LENGTH;
31
import org.distorted.object.RubikObjectList;
32

  
32 33
import static org.distorted.uistate.RubikStatePlay.MAX_SCRAMBLE;
33 34

  
34 35
///////////////////////////////////////////////////////////////////////////////////////////////////
......
38 39
  private FragmentActivity mAct;
39 40
  private RubikDialogScoresView[] mViews;
40 41
  private ViewPager mViewPager;
42
  private int mNumTabs;
41 43

  
42 44
///////////////////////////////////////////////////////////////////////////////////////////////////
43 45

  
......
49 51

  
50 52
    addPage(mViews[c],country[c],name[c],time[c]);
51 53

  
52
    for(int i=0; i<LENGTH; i++)
54
    for(int i=0; i<mNumTabs; i++)
53 55
      {
54 56
      if( i==c ) continue;
55 57

  
......
66 68
      @Override
67 69
      public void run()
68 70
        {
69
        for(int i=0; i<LENGTH; i++)
71
        for(int i=0; i<mNumTabs; i++)
70 72
          {
71 73
          mViews[i].prepareView(mAct);
72 74
          }
......
119 121
      @Override
120 122
      public void run()
121 123
        {
122
        for(int i=0; i<LENGTH; i++)
124
        for(int i=0; i<mNumTabs; i++)
123 125
          {
124 126
          mViews[i].exception(exce);
125 127
          }
......
132 134
  RubikDialogScoresPagerAdapter(FragmentActivity act, ViewPager viewPager)
133 135
    {
134 136
    mAct = act;
135
    mViews = new RubikDialogScoresView[LENGTH];
137
    mNumTabs = RubikObjectList.getTotal();
138
    mViews = new RubikDialogScoresView[mNumTabs];
136 139
    mViewPager = viewPager;
137 140

  
138 141
    viewPager.setAdapter(this);
139
    viewPager.setOffscreenPageLimit(LENGTH-1);
142
    viewPager.setOffscreenPageLimit(mNumTabs-1);
140 143
    }
141 144

  
142 145
///////////////////////////////////////////////////////////////////////////////////////////////////
......
150 153

  
151 154
    boolean allCreated = true;
152 155

  
153
    for(int i=0; i<LENGTH; i++)
156
    for(int i=0; i<mNumTabs; i++)
154 157
      {
155 158
      if( mViews[i]==null )
156 159
        {
......
181 184
  @Override
182 185
  public int getCount()
183 186
    {
184
    return LENGTH;
187
    return mNumTabs;
185 188
    }
186 189

  
187 190
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff