Revision 5bda8973
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java | ||
---|---|---|
40 | 40 |
|
41 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
42 | 42 |
|
43 |
private void addSection(int tab, int level, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time)
|
|
43 |
private void prepareView()
|
|
44 | 44 |
{ |
45 |
if( level>RubikScreenPlay.LEVELS_SHOWN ) level=RubikScreenPlay.LEVELS_SHOWN; |
|
45 |
mAct.runOnUiThread(new Runnable() |
|
46 |
{ |
|
47 |
@Override |
|
48 |
public void run() |
|
49 |
{ |
|
50 |
for(int i=0; i<mNumTabs; i++) |
|
51 |
{ |
|
52 |
mViews[i].prepareView(mAct); |
|
53 |
} |
|
54 |
} |
|
55 |
}); |
|
56 |
try |
|
57 |
{ |
|
58 |
Thread.sleep(150); |
|
59 |
} |
|
60 |
catch( InterruptedException ignored) |
|
61 |
{ |
|
46 | 62 |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
67 |
|
|
68 |
private void addSection(int tab, int level, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time) |
|
69 |
{ |
|
47 | 70 |
String title = level==RubikScreenPlay.LEVELS_SHOWN ? |
48 | 71 |
mAct.getString(R.string.levelM) : |
49 | 72 |
mAct.getString(R.string.lv_placeholder,level+1); |
... | ... | |
71 | 94 |
|
72 | 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
73 | 96 |
|
74 |
private void getNext(int currentTab, int[] toDoTab, int[] lastTab)
|
|
97 |
private void getNext(int currentTab, int[] toDoTab) |
|
75 | 98 |
{ |
76 |
int MAX = RubikScreenPlay.LEVELS_SHOWN+1;
|
|
99 |
int MAX = RubikScreenPlay.LEVELS_SHOWN; |
|
77 | 100 |
|
78 |
if( toDoTab[currentTab]<MAX ) |
|
101 |
if( toDoTab[currentTab]<=MAX )
|
|
79 | 102 |
{ |
80 | 103 |
mToDoTab = currentTab; |
81 |
mToDoLvl = toDoTab[currentTab]<MAX-1 ? toDoTab[currentTab] : lastTab[currentTab]-1;
|
|
104 |
mToDoLvl = toDoTab[currentTab]; |
|
82 | 105 |
toDoTab[currentTab]++; |
83 | 106 |
} |
84 | 107 |
else |
85 | 108 |
{ |
86 | 109 |
for(int tab=0; tab<mNumTabs; tab++) |
87 | 110 |
{ |
88 |
if( toDoTab[tab]<MAX ) |
|
111 |
if( toDoTab[tab]<=MAX )
|
|
89 | 112 |
{ |
90 | 113 |
mToDoTab = tab; |
91 |
mToDoLvl = toDoTab[tab]<MAX-1 ? toDoTab[tab] : lastTab[tab]-1;
|
|
114 |
mToDoLvl = toDoTab[tab]; |
|
92 | 115 |
toDoTab[tab]++; |
93 | 116 |
break; |
94 | 117 |
} |
... | ... | |
101 | 124 |
public void receive(final String[][][] country, final String[][][] name, final float[][][] time) |
102 | 125 |
{ |
103 | 126 |
prepareView(); |
104 |
|
|
105 | 127 |
int toDo=0; |
106 | 128 |
int[] toDoTab = new int[mNumTabs]; |
107 |
int[] lastTab = new int[mNumTabs]; |
|
108 | 129 |
|
109 | 130 |
for(int i=0; i<mNumTabs; i++) |
110 | 131 |
{ |
111 |
lastTab[i]= RubikObjectList.getDBLevel(i); |
|
112 | 132 |
toDoTab[i]= 0; |
113 | 133 |
toDo += (RubikScreenPlay.LEVELS_SHOWN+1); |
114 | 134 |
} |
... | ... | |
116 | 136 |
while( toDo>0 ) |
117 | 137 |
{ |
118 | 138 |
toDo--; |
119 |
getNext(mViewPager.getCurrentItem(), toDoTab, lastTab);
|
|
139 |
getNext(mViewPager.getCurrentItem(), toDoTab); |
|
120 | 140 |
addSection( mToDoTab, mToDoLvl, mViews[mToDoTab], country[mToDoTab][mToDoLvl], name[mToDoTab][mToDoLvl], time[mToDoTab][mToDoLvl]); |
121 | 141 |
} |
122 | 142 |
} |
... | ... | |
165 | 185 |
} |
166 | 186 |
} |
167 | 187 |
|
168 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
169 |
|
|
170 |
private void prepareView() |
|
171 |
{ |
|
172 |
mAct.runOnUiThread(new Runnable() |
|
173 |
{ |
|
174 |
@Override |
|
175 |
public void run() |
|
176 |
{ |
|
177 |
for(int i=0; i<mNumTabs; i++) |
|
178 |
{ |
|
179 |
mViews[i].prepareView(mAct); |
|
180 |
} |
|
181 |
} |
|
182 |
}); |
|
183 |
try |
|
184 |
{ |
|
185 |
Thread.sleep(150); |
|
186 |
} |
|
187 |
catch( InterruptedException ignored) |
|
188 |
{ |
|
189 |
|
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 | 188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
194 | 189 |
|
195 | 190 |
RubikDialogScoresPagerAdapter(FragmentActivity act, ViewPager viewPager, boolean isSubmitting, RubikDialogScores diag) |
Also available in: Unified diff
New way to store records, comopletely independent on the number of scrambles.
Do away with the weird 'getDBLevel' thing.