Project

General

Profile

« Previous | Next » 

Revision 2a1f50b0

Added by Leszek Koltunski almost 2 years ago

Records dialog: support objects with less than 8 number of scrambles.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java
23 23
import org.distorted.main.R;
24 24
import org.distorted.external.RubikScores;
25 25
import org.distorted.external.RubikNetwork;
26
import org.distorted.objects.RubikObject;
26 27
import org.distorted.objects.RubikObjectList;
27 28
import org.distorted.screens.RubikScreenPlay;
28 29

  
......
65 66

  
66 67
///////////////////////////////////////////////////////////////////////////////////////////////////
67 68

  
68
  private void addSection(int tab, int level, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time)
69
  private void addSection(int tab, int level, int numLevels, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time)
69 70
    {
70
    String title = level==RubikScreenPlay.LEVELS_SHOWN ?
71
    String title = level==numLevels ?
71 72
                   mAct.getString(R.string.levelM) :
72 73
                   mAct.getString(R.string.lv_placeholder,level+1);
73 74

  
......
94 95

  
95 96
///////////////////////////////////////////////////////////////////////////////////////////////////
96 97

  
97
  private void getNext(int currentTab, int[] toDoTab)
98
  private void getNext(int currentTab, int[] toDoTab, int[] numLevels)
98 99
    {
99
    int MAX = RubikScreenPlay.LEVELS_SHOWN;
100

  
101
    if( toDoTab[currentTab]<=MAX )
100
    if( toDoTab[currentTab]<=numLevels[currentTab] )
102 101
      {
103 102
      mToDoTab = currentTab;
104 103
      mToDoLvl = toDoTab[currentTab];
......
108 107
      {
109 108
      for(int tab=0; tab<mNumTabs; tab++)
110 109
        {
111
        if( toDoTab[tab]<=MAX )
110
        if( toDoTab[tab]<=numLevels[currentTab] )
112 111
          {
113 112
          mToDoTab = tab;
114 113
          mToDoLvl = toDoTab[tab];
......
125 124
    {
126 125
    prepareView();
127 126
    int toDo=0;
128
    int[] toDoTab = new int[mNumTabs];
127
    int[] toDoTab   = new int[mNumTabs];
128
    int[] numLevels = new int[mNumTabs];
129 129

  
130 130
    for(int i=0; i<mNumTabs; i++)
131 131
      {
132 132
      toDoTab[i]= 0;
133
      toDo += (RubikScreenPlay.LEVELS_SHOWN+1);
133
      RubikObject object = RubikObjectList.getObject(i);
134
      int numScramble = object==null ? 1 : object.getNumScramble();
135
      numLevels[i] = Math.min(numScramble-1,RubikScreenPlay.LEVELS_SHOWN);
136
      toDo += (numLevels[i]+1);
134 137
      }
135 138

  
136 139
    while( toDo>0 )
137 140
      {
138 141
      toDo--;
139
      getNext(mViewPager.getCurrentItem(), toDoTab);
140
      addSection( mToDoTab, mToDoLvl, mViews[mToDoTab], country[mToDoTab][mToDoLvl], name[mToDoTab][mToDoLvl], time[mToDoTab][mToDoLvl]);
142
      getNext(mViewPager.getCurrentItem(), toDoTab, numLevels);
143
      addSection( mToDoTab, mToDoLvl, numLevels[mToDoTab], mViews[mToDoTab], country[mToDoTab][mToDoLvl], name[mToDoTab][mToDoLvl], time[mToDoTab][mToDoLvl]);
141 144
      }
142 145
    }
143 146

  

Also available in: Unified diff