Revision 017f24b3
Added by Leszek Koltunski almost 2 years ago
| src/main/java/org/distorted/dialogs/RubikDialogPatternListAdapter.java | ||
|---|---|---|
| 26 | 26 |
class RubikDialogPatternListAdapter extends BaseExpandableListAdapter |
| 27 | 27 |
{
|
| 28 | 28 |
private final Context mContext; |
| 29 |
private final int mTab, mWidth;
|
|
| 29 |
private final int mTab, mHeight;
|
|
| 30 | 30 |
|
| 31 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | 32 |
|
| 33 |
public RubikDialogPatternListAdapter(Context context, int tab, int width)
|
|
| 33 |
public RubikDialogPatternListAdapter(Context context, int tab, int height)
|
|
| 34 | 34 |
{
|
| 35 | 35 |
mContext = context; |
| 36 | 36 |
mTab = tab; |
| 37 |
mWidth = width;
|
|
| 37 |
mHeight = height;
|
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 | 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 67 | 67 |
view = infalInflater.inflate(R.layout.dialog_pattern_child_item, null); |
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 |
int size = (int)(mWidth* RubikActivity.PATTERN_CHILD_TEXT);
|
|
| 70 |
int size = (int)(mHeight* RubikActivity.PATTERN_CHILD_TEXT);
|
|
| 71 | 71 |
|
| 72 | 72 |
TextView childItem = view.findViewById(R.id.child); |
| 73 | 73 |
childItem.setText(childName); |
| ... | ... | |
| 124 | 124 |
view = inf.inflate(R.layout.dialog_pattern_group_item, null); |
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 |
int size = (int)(mWidth* RubikActivity.PATTERN_GROUP_TEXT);
|
|
| 127 |
int size = (int)(mHeight* RubikActivity.PATTERN_GROUP_TEXT);
|
|
| 128 | 128 |
|
| 129 | 129 |
TextView heading = view.findViewById(R.id.heading); |
| 130 | 130 |
heading.setText(groupName); |
| src/main/java/org/distorted/dialogs/RubikDialogPatternSingle.java | ||
|---|---|---|
| 47 | 47 |
{
|
| 48 | 48 |
WindowManager.LayoutParams params = window.getAttributes(); |
| 49 | 49 |
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f ); |
| 50 |
params.height = (int)Math.min( mHeight*0.80f,mWidth*1.30f ); |
|
| 50 |
//params.height = (int)Math.min( mHeight*0.80f,mWidth*1.30f );
|
|
| 51 | 51 |
window.setAttributes(params); |
| 52 | 52 |
} |
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 | 55 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 56 | 56 |
|
| 57 |
public int getResource() { return R.layout.dialog_pattern_tab; }
|
|
| 57 |
public int getResource() { return R.layout.dialog_pattern_single; }
|
|
| 58 | 58 |
public int getTitleResource() { return R.string.choose_pattern; }
|
| 59 | 59 |
public boolean hasArgument() { return true; }
|
| 60 | 60 |
public int getPositive() { return -1; }
|
| ... | ... | |
| 82 | 82 |
return; |
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 |
android.util.Log.e("D", "prepareBody: object "+mArgument);
|
|
| 86 |
|
|
| 85 | 87 |
final PatternActivity pact = (PatternActivity)getContext(); |
| 86 | 88 |
int height = pact!=null ? pact.getScreenHeightInPixels() : 100; |
| 87 | 89 |
final ObjectControl control = pact!=null ? pact.getControl() : null; |
| ... | ... | |
| 93 | 95 |
RubikDialogPatternListAdapter listAdapter = new RubikDialogPatternListAdapter(act,mPatternOrdinal,height); |
| 94 | 96 |
mListView.setAdapter(listAdapter); |
| 95 | 97 |
|
| 96 |
if( mExpandedGroup>=0 ) |
|
| 97 |
{
|
|
| 98 |
mListView.expandGroup(mExpandedGroup); |
|
| 99 |
} |
|
| 98 |
if( mExpandedGroup>=0 ) mListView.expandGroup(mExpandedGroup); |
|
| 100 | 99 |
|
| 101 | 100 |
int visible = pattern.recallVisiblePos(mPatternOrdinal); |
| 102 | 101 |
mListView.setSelectionFromTop(visible,0); |
| 103 | 102 |
|
| 104 |
|
|
| 105 | 103 |
mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() |
| 106 | 104 |
{
|
| 107 | 105 |
@Override |
| ... | ... | |
| 109 | 107 |
{
|
| 110 | 108 |
RubikPattern pattern = RubikPattern.getInstance(); |
| 111 | 109 |
int[][] moves = pattern.reInitialize(mPatternOrdinal, groupPosition, childPosition); |
| 112 |
control.initializeObject(moves); |
|
| 110 |
if( control!=null ) control.initializeObject(moves);
|
|
| 113 | 111 |
|
| 114 | 112 |
ScreenPattern state = (ScreenPattern) ScreenList.PATT.getScreenClass(); |
| 115 | 113 |
state.setPattern(pact, mPatternOrdinal, groupPosition, childPosition); |
| src/main/java/org/distorted/patternui/PatternActivity.java | ||
|---|---|---|
| 46 | 46 |
public static final float PADDING = 0.010f; |
| 47 | 47 |
public static final float SMALL_MARGIN = 0.004f; |
| 48 | 48 |
public static final float BUTTON_TEXT_SIZE= 0.050f; |
| 49 |
public static final float TITLE_TEXT_SIZE = 0.060f;
|
|
| 49 |
public static final float TITLE_TEXT_SIZE = 0.045f;
|
|
| 50 | 50 |
|
| 51 | 51 |
private static final int ACTIVITY_NUMBER = 1; |
| 52 | 52 |
private static final float RATIO_INSET= 0.09f; |
| ... | ... | |
| 194 | 194 |
|
| 195 | 195 |
createObject(); |
| 196 | 196 |
RubikObjectList.setCurrObject(mObjectOrdinal); |
| 197 |
|
|
| 198 | 197 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
| 199 |
restorePreferences(preferences,mJustStarted);
|
|
| 198 |
restorePreferences(preferences); |
|
| 200 | 199 |
ScreenList.setScreen(this); |
| 201 | 200 |
|
| 202 | 201 |
if( mJustStarted ) |
| ... | ... | |
| 222 | 221 |
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); |
| 223 | 222 |
SharedPreferences.Editor editor = preferences.edit(); |
| 224 | 223 |
|
| 225 |
for(int i = 0; i< ScreenList.LENGTH; i++ ) |
|
| 226 |
{
|
|
| 224 |
for(int i=0; i< ScreenList.LENGTH; i++ ) |
|
| 227 | 225 |
ScreenList.getScreen(i).getScreenClass().savePreferences(editor); |
| 228 |
} |
|
| 229 | 226 |
|
| 230 |
RubikObjectList.savePreferences(editor); |
|
| 231 |
RubikObjectList.saveMeshState(editor); |
|
| 232 | 227 |
ScreenList.savePreferences(editor); |
| 233 |
PatternSurfaceView view = findViewById(R.id.patternSurfaceView); |
|
| 234 |
OSInterface os = view.getInterface(); |
|
| 235 |
os.setEditor(editor); |
|
| 236 |
view.getObjectControl().savePreferences(); |
|
| 237 | 228 |
|
| 238 | 229 |
boolean success = editor.commit(); |
| 239 | 230 |
if( !success ) android.util.Log.e("D", "Failed to save preferences");
|
| ... | ... | |
| 241 | 232 |
|
| 242 | 233 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 243 | 234 |
|
| 244 |
private void restorePreferences(SharedPreferences preferences, boolean justStarted)
|
|
| 235 |
private void restorePreferences(SharedPreferences preferences) |
|
| 245 | 236 |
{
|
| 246 |
RubikObjectList.restorePreferences(this,preferences,justStarted); |
|
| 247 |
|
|
| 248 |
for (int i = 0; i<ScreenList.LENGTH; i++) |
|
| 249 |
{
|
|
| 237 |
for (int i=0; i<ScreenList.LENGTH; i++) |
|
| 250 | 238 |
ScreenList.getScreen(i).getScreenClass().restorePreferences(preferences); |
| 251 |
} |
|
| 252 | 239 |
|
| 253 | 240 |
ScreenList.restorePreferences(preferences); |
| 254 |
|
|
| 255 |
PatternSurfaceView view = findViewById(R.id.patternSurfaceView); |
|
| 256 |
OSInterface os = view.getInterface(); |
|
| 257 |
os.setPreferences(preferences); |
|
| 258 |
view.getObjectControl().restorePreferences(); |
|
| 259 | 241 |
} |
| 260 | 242 |
|
| 261 | 243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/patternui/ScreenPattern.java | ||
|---|---|---|
| 13 | 13 |
import android.os.Bundle; |
| 14 | 14 |
import android.util.TypedValue; |
| 15 | 15 |
import android.view.Gravity; |
| 16 |
import android.view.LayoutInflater; |
|
| 17 | 16 |
import android.view.View; |
| 18 | 17 |
import android.widget.LinearLayout; |
| 19 | 18 |
import android.widget.TextView; |
| 20 | 19 |
|
| 21 |
import org.distorted.dialogs.RubikDialogError; |
|
| 22 | 20 |
import org.distorted.dialogs.RubikDialogPatternSingle; |
| 21 |
import org.distorted.helpers.TransparentButton; |
|
| 23 | 22 |
import org.distorted.helpers.TransparentImageButton; |
| 24 | 23 |
import org.distorted.main.R; |
| 25 | 24 |
import org.distorted.objectlib.main.ObjectControl; |
| ... | ... | |
| 30 | 29 |
|
| 31 | 30 |
public class ScreenPattern extends ScreenAbstract |
| 32 | 31 |
{
|
| 33 |
private TextView mText; |
|
| 34 | 32 |
private TransparentImageButton mPrevButton, mNextButton, mBackButton; |
| 33 |
private TransparentImageButton mPrevPatt, mNextPatt; |
|
| 34 |
private TransparentButton mTextButton; |
|
| 35 | 35 |
private TextView mMovesText; |
| 36 | 36 |
private int mNumMoves; |
| 37 | 37 |
private int mPatternOrdinal, mCategory, mPattern; |
| ... | ... | |
| 57 | 57 |
{
|
| 58 | 58 |
float width = act.getScreenWidthInPixels(); |
| 59 | 59 |
mButtonSize = width*PatternActivity.BUTTON_TEXT_SIZE; |
| 60 |
float titleSize = width*PatternActivity.TITLE_TEXT_SIZE; |
|
| 61 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 62 | 60 |
|
| 63 | 61 |
mPatternOrdinal = -1; |
| 64 | 62 |
mCategory = -1; |
| ... | ... | |
| 67 | 65 |
// TOP //////////////////////////// |
| 68 | 66 |
LinearLayout layoutTop = act.findViewById(R.id.upperBar); |
| 69 | 67 |
layoutTop.removeAllViews(); |
| 70 |
mText = (TextView)inflater.inflate(R.layout.upper_pattern_text, null); |
|
| 71 |
mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize); |
|
| 72 |
mText.setText(R.string.patterns); |
|
| 73 |
layoutTop.addView(mText); |
|
| 68 |
|
|
| 69 |
setupPrevPatt(act); |
|
| 70 |
setupNextPatt(act); |
|
| 71 |
setupTextButton(act,width); |
|
| 72 |
|
|
| 73 |
LinearLayout.LayoutParams pTL = new LinearLayout.LayoutParams((int)( width/6),LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 74 |
LinearLayout.LayoutParams pTM = new LinearLayout.LayoutParams((int)(2*width/3),LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 75 |
LinearLayout.LayoutParams pTR = new LinearLayout.LayoutParams((int)( width/6),LinearLayout.LayoutParams.MATCH_PARENT); |
|
| 76 |
|
|
| 77 |
LinearLayout layoutTL = new LinearLayout(act); |
|
| 78 |
layoutTL.setLayoutParams(pTL); |
|
| 79 |
LinearLayout layoutTM = new LinearLayout(act); |
|
| 80 |
layoutTM.setLayoutParams(pTM); |
|
| 81 |
LinearLayout layoutTR = new LinearLayout(act); |
|
| 82 |
layoutTR.setLayoutParams(pTR); |
|
| 83 |
|
|
| 84 |
layoutTL.addView(mPrevPatt); |
|
| 85 |
layoutTM.addView(mTextButton); |
|
| 86 |
layoutTR.addView(mNextPatt); |
|
| 87 |
|
|
| 88 |
layoutTop.addView(layoutTL); |
|
| 89 |
layoutTop.addView(layoutTM); |
|
| 90 |
layoutTop.addView(layoutTR); |
|
| 74 | 91 |
|
| 75 | 92 |
// BOT //////////////////////////// |
| 76 | 93 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
| ... | ... | |
| 80 | 97 |
setupNextButton(act); |
| 81 | 98 |
setupTextView(act,width); |
| 82 | 99 |
|
| 83 |
LinearLayout.LayoutParams paramsL = new LinearLayout.LayoutParams((int)(width/2),LinearLayout.LayoutParams.MATCH_PARENT);
|
|
| 84 |
LinearLayout.LayoutParams paramsM = new LinearLayout.LayoutParams((int)(width/6),LinearLayout.LayoutParams.MATCH_PARENT);
|
|
| 85 |
LinearLayout.LayoutParams paramsR = new LinearLayout.LayoutParams((int)(width/3),LinearLayout.LayoutParams.MATCH_PARENT);
|
|
| 100 |
LinearLayout.LayoutParams pBL = new LinearLayout.LayoutParams((int)(width/2),LinearLayout.LayoutParams.MATCH_PARENT);
|
|
| 101 |
LinearLayout.LayoutParams pBM = new LinearLayout.LayoutParams((int)(width/6),LinearLayout.LayoutParams.MATCH_PARENT);
|
|
| 102 |
LinearLayout.LayoutParams pBR = new LinearLayout.LayoutParams((int)(width/3),LinearLayout.LayoutParams.MATCH_PARENT);
|
|
| 86 | 103 |
|
| 87 |
LinearLayout layoutLeft = new LinearLayout(act);
|
|
| 88 |
layoutLeft.setLayoutParams(paramsL);
|
|
| 89 |
LinearLayout layoutMid = new LinearLayout(act);
|
|
| 90 |
layoutMid.setLayoutParams(paramsM);
|
|
| 91 |
LinearLayout layoutRight = new LinearLayout(act);
|
|
| 92 |
layoutRight.setLayoutParams(paramsR);
|
|
| 104 |
LinearLayout layoutBL = new LinearLayout(act);
|
|
| 105 |
layoutBL.setLayoutParams(pBL);
|
|
| 106 |
LinearLayout layoutBM = new LinearLayout(act);
|
|
| 107 |
layoutBM.setLayoutParams(pBM);
|
|
| 108 |
LinearLayout layoutBR = new LinearLayout(act);
|
|
| 109 |
layoutBR.setLayoutParams(pBR);
|
|
| 93 | 110 |
|
| 94 |
layoutLeft.addView(mPrevButton);
|
|
| 95 |
layoutLeft.addView(mMovesText);
|
|
| 96 |
layoutLeft.addView(mNextButton);
|
|
| 111 |
layoutBL.addView(mPrevButton);
|
|
| 112 |
layoutBL.addView(mMovesText);
|
|
| 113 |
layoutBL.addView(mNextButton);
|
|
| 97 | 114 |
|
| 98 | 115 |
setupBackButton(act); |
| 99 | 116 |
|
| 100 |
layoutRight.addView(mBackButton);
|
|
| 117 |
layoutBR.addView(mBackButton);
|
|
| 101 | 118 |
|
| 102 |
layoutBot.addView(layoutLeft); |
|
| 103 |
layoutBot.addView(layoutMid); |
|
| 104 |
layoutBot.addView(layoutRight); |
|
| 119 |
layoutBot.addView(layoutBL); |
|
| 120 |
layoutBot.addView(layoutBM); |
|
| 121 |
layoutBot.addView(layoutBR); |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 105 | 125 |
|
| 126 |
private void showDialog(final PatternActivity act) |
|
| 127 |
{
|
|
| 106 | 128 |
Bundle bundle = new Bundle(); |
| 107 | 129 |
bundle.putString("argument",RubikObjectList.getCurrentName());
|
| 108 | 130 |
RubikDialogPatternSingle diag = new RubikDialogPatternSingle(); |
| ... | ... | |
| 110 | 132 |
diag.show( act.getSupportFragmentManager(), RubikDialogPatternSingle.getDialogTag() ); |
| 111 | 133 |
} |
| 112 | 134 |
|
| 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 136 |
|
|
| 137 |
private void setupPrevPatt(final PatternActivity act) |
|
| 138 |
{
|
|
| 139 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 140 |
mPrevPatt = new TransparentImageButton(act,R.drawable.ui_left,params); |
|
| 141 |
|
|
| 142 |
mPrevPatt.setOnClickListener( new View.OnClickListener() |
|
| 143 |
{
|
|
| 144 |
@Override |
|
| 145 |
public void onClick(View v) |
|
| 146 |
{
|
|
| 147 |
if( mPatternOrdinal<0 ) showDialog(act); |
|
| 148 |
else prevPattern(act); |
|
| 149 |
} |
|
| 150 |
}); |
|
| 151 |
} |
|
| 152 |
|
|
| 153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 154 |
|
|
| 155 |
private void setupNextPatt(final PatternActivity act) |
|
| 156 |
{
|
|
| 157 |
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LinearLayout.LayoutParams.MATCH_PARENT,1.0f); |
|
| 158 |
mNextPatt = new TransparentImageButton(act,R.drawable.ui_right,params); |
|
| 159 |
|
|
| 160 |
mNextPatt.setOnClickListener( new View.OnClickListener() |
|
| 161 |
{
|
|
| 162 |
@Override |
|
| 163 |
public void onClick(View v) |
|
| 164 |
{
|
|
| 165 |
if( mPatternOrdinal<0 ) showDialog(act); |
|
| 166 |
else nextPattern(act); |
|
| 167 |
} |
|
| 168 |
}); |
|
| 169 |
} |
|
| 170 |
|
|
| 171 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 172 |
|
|
| 173 |
private void setupTextButton(final PatternActivity act, float width) |
|
| 174 |
{
|
|
| 175 |
float textSize = width*PatternActivity.TITLE_TEXT_SIZE; |
|
| 176 |
mTextButton = new TransparentButton(act,R.string.choose_pattern,textSize); |
|
| 177 |
|
|
| 178 |
mTextButton.setOnClickListener( new View.OnClickListener() |
|
| 179 |
{
|
|
| 180 |
@Override |
|
| 181 |
public void onClick(View v) |
|
| 182 |
{
|
|
| 183 |
showDialog(act); |
|
| 184 |
} |
|
| 185 |
}); |
|
| 186 |
} |
|
| 187 |
|
|
| 113 | 188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 114 | 189 |
|
| 115 | 190 |
private void setupBackButton(final PatternActivity act) |
| ... | ... | |
| 139 | 214 |
@Override |
| 140 | 215 |
public void onClick(View v) |
| 141 | 216 |
{
|
| 142 |
RubikPattern pattern = RubikPattern.getInstance(); |
|
| 143 |
ObjectControl control = act.getControl(); |
|
| 144 |
pattern.backMove( control, mPatternOrdinal, mCategory, mPattern); |
|
| 145 |
int currMove = pattern.getCurMove(mPatternOrdinal, mCategory, mPattern); |
|
| 146 |
mMovesText.setText(act.getString(R.string.mo_placeholder,currMove,mNumMoves)); |
|
| 217 |
if( mPatternOrdinal>=0 ) |
|
| 218 |
{
|
|
| 219 |
RubikPattern pattern = RubikPattern.getInstance(); |
|
| 220 |
ObjectControl control = act.getControl(); |
|
| 221 |
pattern.backMove(control, mPatternOrdinal, mCategory, mPattern); |
|
| 222 |
int currMove = pattern.getCurMove(mPatternOrdinal, mCategory, mPattern); |
|
| 223 |
mMovesText.setText(act.getString(R.string.mo_placeholder, currMove, mNumMoves)); |
|
| 224 |
} |
|
| 147 | 225 |
} |
| 148 | 226 |
}); |
| 149 | 227 |
} |
| ... | ... | |
| 160 | 238 |
@Override |
| 161 | 239 |
public void onClick(View v) |
| 162 | 240 |
{
|
| 163 |
RubikPattern pattern = RubikPattern.getInstance(); |
|
| 164 |
ObjectControl control = act.getControl(); |
|
| 165 |
pattern.makeMove( control, mPatternOrdinal, mCategory, mPattern); |
|
| 166 |
int currMove = pattern.getCurMove(mPatternOrdinal, mCategory, mPattern); |
|
| 167 |
mMovesText.setText(act.getString(R.string.mo_placeholder,currMove,mNumMoves)); |
|
| 241 |
if( mPatternOrdinal>=0 ) |
|
| 242 |
{
|
|
| 243 |
RubikPattern pattern = RubikPattern.getInstance(); |
|
| 244 |
ObjectControl control = act.getControl(); |
|
| 245 |
pattern.makeMove(control, mPatternOrdinal, mCategory, mPattern); |
|
| 246 |
int currMove = pattern.getCurMove(mPatternOrdinal, mCategory, mPattern); |
|
| 247 |
mMovesText.setText(act.getString(R.string.mo_placeholder, currMove, mNumMoves)); |
|
| 248 |
} |
|
| 168 | 249 |
} |
| 169 | 250 |
}); |
| 170 | 251 |
} |
| ... | ... | |
| 201 | 282 |
|
| 202 | 283 |
RubikPattern patt = RubikPattern.getInstance(); |
| 203 | 284 |
String patternName = patt.getPatternName(ordinal,category,pattern); |
| 204 |
mText.setText(patternName); |
|
| 285 |
mTextButton.setText(patternName);
|
|
| 205 | 286 |
|
| 206 | 287 |
mNumMoves = patt.getNumMoves(ordinal,category,pattern); |
| 207 | 288 |
int currMove= patt.getCurMove(ordinal,category,pattern); |
| ... | ... | |
| 209 | 290 |
mMovesText.setText(act.getString(R.string.mo_placeholder,currMove,mNumMoves)); |
| 210 | 291 |
} |
| 211 | 292 |
|
| 293 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 294 |
|
|
| 295 |
private void prevPattern(final PatternActivity act) |
|
| 296 |
{
|
|
| 297 |
RubikPattern patt = RubikPattern.getInstance(); |
|
| 298 |
|
|
| 299 |
if( mPattern>0 ) |
|
| 300 |
{
|
|
| 301 |
setPattern(act,mPatternOrdinal,mCategory,mPattern-1); |
|
| 302 |
} |
|
| 303 |
else |
|
| 304 |
{
|
|
| 305 |
if( mCategory>0 ) |
|
| 306 |
{
|
|
| 307 |
int numPat = patt.getNumPatterns(mPatternOrdinal,mCategory-1); |
|
| 308 |
setPattern(act,mPatternOrdinal,mCategory-1,numPat-1); |
|
| 309 |
} |
|
| 310 |
else |
|
| 311 |
{
|
|
| 312 |
int numCat = patt.getNumCategories(mPatternOrdinal); |
|
| 313 |
int numPat = patt.getNumPatterns(mPatternOrdinal,numCat-1); |
|
| 314 |
setPattern(act,mPatternOrdinal,numCat-1,numPat-1); |
|
| 315 |
} |
|
| 316 |
} |
|
| 317 |
|
|
| 318 |
int[][] moves = patt.reInitialize(mPatternOrdinal, mCategory, mPattern); |
|
| 319 |
ObjectControl control = act.getControl(); |
|
| 320 |
if( control!=null ) control.initializeObject(moves); |
|
| 321 |
} |
|
| 322 |
|
|
| 323 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 324 |
|
|
| 325 |
private void nextPattern(final PatternActivity act) |
|
| 326 |
{
|
|
| 327 |
RubikPattern patt = RubikPattern.getInstance(); |
|
| 328 |
int numPat = patt.getNumPatterns(mPatternOrdinal,mCategory); |
|
| 329 |
|
|
| 330 |
if( mPattern<numPat-1 ) |
|
| 331 |
{
|
|
| 332 |
setPattern(act,mPatternOrdinal,mCategory,mPattern+1); |
|
| 333 |
} |
|
| 334 |
else |
|
| 335 |
{
|
|
| 336 |
int numCat = patt.getNumCategories(mPatternOrdinal); |
|
| 337 |
|
|
| 338 |
if( mCategory<numCat-1 ) |
|
| 339 |
{
|
|
| 340 |
setPattern(act,mPatternOrdinal,mCategory+1,0); |
|
| 341 |
} |
|
| 342 |
else |
|
| 343 |
{
|
|
| 344 |
setPattern(act,mPatternOrdinal,0,0); |
|
| 345 |
} |
|
| 346 |
} |
|
| 347 |
|
|
| 348 |
int[][] moves = patt.reInitialize(mPatternOrdinal, mCategory, mPattern); |
|
| 349 |
ObjectControl control = act.getControl(); |
|
| 350 |
if( control!=null ) control.initializeObject(moves); |
|
| 351 |
} |
|
| 352 |
|
|
| 212 | 353 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 213 | 354 |
|
| 214 | 355 |
public void savePreferences(SharedPreferences.Editor editor) |
| src/main/res/layout/dialog_pattern_single.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
|
|
| 3 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 4 |
android:layout_width="fill_parent" |
|
| 5 |
android:layout_height="fill_parent" |
|
| 6 |
android:gravity="center" |
|
| 7 |
android:orientation="horizontal" |
|
| 8 |
android:background="@android:color/transparent"> |
|
| 9 |
|
|
| 10 |
<ExpandableListView |
|
| 11 |
android:id="@+id/patternListView" |
|
| 12 |
android:background="@color/grey" |
|
| 13 |
android:layout_marginLeft="10dp" |
|
| 14 |
android:layout_marginRight="10dp" |
|
| 15 |
android:layout_marginBottom="10dp" |
|
| 16 |
android:paddingLeft="5dp" |
|
| 17 |
android:paddingRight="5dp" |
|
| 18 |
android:paddingTop="10dp" |
|
| 19 |
android:paddingBottom="10dp" |
|
| 20 |
android:layout_width="fill_parent" |
|
| 21 |
android:layout_height="fill_parent"/> |
|
| 22 |
</LinearLayout> |
|
Also available in: Unified diff
new Pattern Activity!