Revision c715128d
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/dialog/RubikDialogPatternView.java | ||
---|---|---|
29 | 29 |
import android.widget.Button; |
30 | 30 |
import android.widget.FrameLayout; |
31 | 31 |
import android.widget.LinearLayout; |
32 |
import android.widget.ScrollView; |
|
32 | 33 |
import android.widget.Spinner; |
33 | 34 |
|
34 | 35 |
import org.distorted.magic.R; |
... | ... | |
43 | 44 |
public class RubikDialogPatternView extends FrameLayout implements AdapterView.OnItemSelectedListener |
44 | 45 |
{ |
45 | 46 |
private LinearLayout mLayout; |
47 |
private ScrollView mScroll; |
|
46 | 48 |
private RubikDialogPattern mDialog; |
47 | 49 |
private int mTab, mPos; |
48 | 50 |
|
... | ... | |
70 | 72 |
mTab = position; |
71 | 73 |
View tab = inflate( act, R.layout.dialog_pattern_tab, null); |
72 | 74 |
mLayout = tab.findViewById(R.id.tabLayout); |
75 |
mScroll = tab.findViewById(R.id.tabScrollView); |
|
73 | 76 |
|
74 | 77 |
String[] categories = createCategories(); |
75 | 78 |
|
... | ... | |
134 | 137 |
|
135 | 138 |
final String[] patterns = createPatterns(category); |
136 | 139 |
int len = patterns.length; |
140 |
final RubikPattern pattern = RubikPattern.getInstance(); |
|
137 | 141 |
|
138 | 142 |
mLayout.removeAllViews(); |
139 | 143 |
|
... | ... | |
150 | 154 |
public void onClick(View view) |
151 | 155 |
{ |
152 | 156 |
int[] sizes = RubikObjectList.CUBE.getSizes(); |
153 |
RubikPattern pattern = RubikPattern.getInstance(); |
|
154 |
int[][] moves = pattern.getMoves(mTab, category, ii); |
|
157 |
int[][] moves = pattern.reInitialize(mTab, category, ii); |
|
155 | 158 |
act.changeObject(RubikObjectList.CUBE,sizes[mTab],moves); |
156 | 159 |
RubikStatePattern state = (RubikStatePattern) RubikState.PATT.getStateClass(); |
157 | 160 |
state.setPattern(act, mTab, category, ii); |
158 |
mDialog.rememberCategories();
|
|
161 |
mDialog.rememberState();
|
|
159 | 162 |
mDialog.dismiss(); |
160 | 163 |
} |
161 | 164 |
}); |
... | ... | |
171 | 174 |
return mPos; |
172 | 175 |
} |
173 | 176 |
|
177 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
178 |
|
|
179 |
int getCurrentScrollPos() |
|
180 |
{ |
|
181 |
return mScroll.getScrollY(); |
|
182 |
} |
|
183 |
|
|
184 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
185 |
|
|
186 |
@Override |
|
187 |
protected void onLayout(boolean changed, int left, int top, int right, int bottom) |
|
188 |
{ |
|
189 |
super.onLayout(changed,left,top,right,bottom); |
|
190 |
|
|
191 |
if( !changed ) |
|
192 |
{ |
|
193 |
final RubikPattern pattern = RubikPattern.getInstance(); |
|
194 |
mScroll.setScrollY( pattern.recallScrollPos(mTab) ); |
|
195 |
} |
|
196 |
} |
|
197 |
|
|
174 | 198 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
175 | 199 |
|
176 | 200 |
@Override |
Also available in: Unified diff
Pretty Patterns Dialog: remember the positions of scrollbars.