| 1 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
// Copyright 2020 Leszek Koltunski //
|
| 3 |
|
|
// //
|
| 4 |
|
|
// This file is part of Magic Cube. //
|
| 5 |
|
|
// //
|
| 6 |
|
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
| 7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
| 8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
| 9 |
|
|
// (at your option) any later version. //
|
| 10 |
|
|
// //
|
| 11 |
|
|
// Magic Cube is distributed in the hope that it will be useful, //
|
| 12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
| 13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
| 14 |
|
|
// GNU General Public License for more details. //
|
| 15 |
|
|
// //
|
| 16 |
|
|
// You should have received a copy of the GNU General Public License //
|
| 17 |
|
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
| 18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 19 |
|
|
|
| 20 |
1f9772f3
|
Leszek Koltunski
|
package org.distorted.states;
|
| 21 |
211b48f2
|
Leszek Koltunski
|
|
| 22 |
4c0cd600
|
Leszek Koltunski
|
import android.content.Context;
|
| 23 |
211b48f2
|
Leszek Koltunski
|
import android.content.SharedPreferences;
|
| 24 |
4c0cd600
|
Leszek Koltunski
|
import android.graphics.drawable.BitmapDrawable;
|
| 25 |
9439f455
|
Leszek Koltunski
|
import android.os.Build;
|
| 26 |
e03e0352
|
Leszek Koltunski
|
import android.os.Bundle;
|
| 27 |
e3c74c0f
|
Leszek Koltunski
|
import android.util.TypedValue;
|
| 28 |
4c0cd600
|
Leszek Koltunski
|
import android.view.Gravity;
|
| 29 |
211b48f2
|
Leszek Koltunski
|
import android.view.LayoutInflater;
|
| 30 |
|
|
import android.view.View;
|
| 31 |
9513f213
|
Leszek Koltunski
|
import android.view.ViewGroup;
|
| 32 |
85b09df4
|
Leszek Koltunski
|
import android.widget.AdapterView;
|
| 33 |
|
|
import android.widget.ArrayAdapter;
|
| 34 |
211b48f2
|
Leszek Koltunski
|
import android.widget.Button;
|
| 35 |
|
|
import android.widget.ImageButton;
|
| 36 |
|
|
import android.widget.LinearLayout;
|
| 37 |
4c0cd600
|
Leszek Koltunski
|
import android.widget.PopupWindow;
|
| 38 |
e3c74c0f
|
Leszek Koltunski
|
import android.widget.TextView;
|
| 39 |
|
|
|
| 40 |
9513f213
|
Leszek Koltunski
|
import androidx.annotation.NonNull;
|
| 41 |
66e777b0
|
Leszek Koltunski
|
import androidx.appcompat.widget.AppCompatSpinner;
|
| 42 |
211b48f2
|
Leszek Koltunski
|
|
| 43 |
e03e0352
|
Leszek Koltunski
|
import org.distorted.dialogs.RubikDialogAbout;
|
| 44 |
|
|
import org.distorted.dialogs.RubikDialogScores;
|
| 45 |
1f9772f3
|
Leszek Koltunski
|
import org.distorted.main.R;
|
| 46 |
|
|
import org.distorted.main.RubikActivity;
|
| 47 |
15846fe4
|
Leszek Koltunski
|
import org.distorted.main.RubikPreRender;
|
| 48 |
|
|
import org.distorted.objects.RubikObject;
|
| 49 |
1f9772f3
|
Leszek Koltunski
|
import org.distorted.objects.RubikObjectList;
|
| 50 |
211b48f2
|
Leszek Koltunski
|
|
| 51 |
15846fe4
|
Leszek Koltunski
|
import java.util.ArrayList;
|
| 52 |
|
|
|
| 53 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 54 |
|
|
|
| 55 |
15846fe4
|
Leszek Koltunski
|
public class RubikStatePlay extends RubikStateAbstract implements AdapterView.OnItemSelectedListener,
|
| 56 |
|
|
RubikPreRender.ActionFinishedListener
|
| 57 |
211b48f2
|
Leszek Koltunski
|
{
|
| 58 |
15846fe4
|
Leszek Koltunski
|
private static final int DURATION_MILLIS = 750;
|
| 59 |
85b09df4
|
Leszek Koltunski
|
private static final int DEF_LEVEL = 1;
|
| 60 |
|
|
public static final int DEF_OBJECT= RubikObjectList.CUBE.ordinal();
|
| 61 |
|
|
public static final int DEF_SIZE = 3;
|
| 62 |
211b48f2
|
Leszek Koltunski
|
|
| 63 |
e03e0352
|
Leszek Koltunski
|
private static int[] BUTTON_LABELS = { R.string.scores, R.string.patterns, R.string.solver, R.string.about };
|
| 64 |
|
|
private static final int NUM_BUTTONS = BUTTON_LABELS.length;
|
| 65 |
|
|
|
| 66 |
15846fe4
|
Leszek Koltunski
|
private ImageButton mObjButton, mMenuButton, mPrevButton, mSolveButton;
|
| 67 |
|
|
private Button mPlayButton;
|
| 68 |
e03e0352
|
Leszek Koltunski
|
private PopupWindow mObjectPopup, mMenuPopup;
|
| 69 |
4888e97c
|
Leszek Koltunski
|
private int mObject = DEF_OBJECT;
|
| 70 |
|
|
private int mSize = DEF_SIZE;
|
| 71 |
e03e0352
|
Leszek Koltunski
|
private int mObjectLayoutWidth, mMenuLayoutHeight;
|
| 72 |
|
|
private LinearLayout mObjectLayout, mMenuLayout;
|
| 73 |
8e3898c8
|
Leszek Koltunski
|
private AppCompatSpinner mLevelSpinner;
|
| 74 |
|
|
private ArrayAdapter<String> mSpinnerAdapter;
|
| 75 |
85b09df4
|
Leszek Koltunski
|
private int mLevelValue;
|
| 76 |
88fb92ba
|
Leszek Koltunski
|
private float mButtonSize, mTitleSize, mMenuItemSize, mMenuTextSize;
|
| 77 |
211b48f2
|
Leszek Koltunski
|
|
| 78 |
15846fe4
|
Leszek Koltunski
|
private ArrayList<Move> mMoves;
|
| 79 |
|
|
private boolean mCanPrevMove;
|
| 80 |
|
|
|
| 81 |
|
|
private static class Move
|
| 82 |
|
|
{
|
| 83 |
|
|
private int mAxis, mRow, mAngle;
|
| 84 |
|
|
|
| 85 |
|
|
Move(int axis, int row, int angle)
|
| 86 |
|
|
{
|
| 87 |
|
|
mAxis = axis;
|
| 88 |
|
|
mRow = row;
|
| 89 |
|
|
mAngle= angle;
|
| 90 |
|
|
}
|
| 91 |
|
|
}
|
| 92 |
|
|
|
| 93 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 94 |
|
|
|
| 95 |
329c0aeb
|
Leszek Koltunski
|
void leaveState(RubikActivity act)
|
| 96 |
211b48f2
|
Leszek Koltunski
|
{
|
| 97 |
85b09df4
|
Leszek Koltunski
|
|
| 98 |
211b48f2
|
Leszek Koltunski
|
}
|
| 99 |
|
|
|
| 100 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 101 |
|
|
|
| 102 |
a6d3b158
|
Leszek Koltunski
|
void enterState(final RubikActivity act)
|
| 103 |
211b48f2
|
Leszek Koltunski
|
{
|
| 104 |
e3c74c0f
|
Leszek Koltunski
|
float width = act.getScreenWidthInPixels();
|
| 105 |
88fb92ba
|
Leszek Koltunski
|
mMenuTextSize = width*RubikActivity.MENU_MEDIUM_TEXT_SIZE;
|
| 106 |
|
|
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE;
|
| 107 |
|
|
mTitleSize = width*RubikActivity.TITLE_TEXT_SIZE;
|
| 108 |
|
|
mMenuItemSize = width*RubikActivity.MENU_ITEM_SIZE;
|
| 109 |
e3c74c0f
|
Leszek Koltunski
|
|
| 110 |
15846fe4
|
Leszek Koltunski
|
mCanPrevMove = true;
|
| 111 |
|
|
|
| 112 |
|
|
if( mMoves==null ) mMoves = new ArrayList<>();
|
| 113 |
|
|
else mMoves.clear();
|
| 114 |
|
|
|
| 115 |
211b48f2
|
Leszek Koltunski
|
// TOP ////////////////////////////
|
| 116 |
7289fd6c
|
Leszek Koltunski
|
LinearLayout layoutTop = act.findViewById(R.id.upperBar);
|
| 117 |
211b48f2
|
Leszek Koltunski
|
layoutTop.removeAllViews();
|
| 118 |
85b09df4
|
Leszek Koltunski
|
|
| 119 |
ad0c8e0e
|
Leszek Koltunski
|
setupObjectButton(act,width);
|
| 120 |
85b09df4
|
Leszek Koltunski
|
layoutTop.addView(mObjButton);
|
| 121 |
ad0c8e0e
|
Leszek Koltunski
|
setupLevelSpinner(act,width);
|
| 122 |
85b09df4
|
Leszek Koltunski
|
layoutTop.addView(mLevelSpinner);
|
| 123 |
ad0c8e0e
|
Leszek Koltunski
|
setupPlayButton(act,width);
|
| 124 |
85b09df4
|
Leszek Koltunski
|
layoutTop.addView(mPlayButton);
|
| 125 |
211b48f2
|
Leszek Koltunski
|
|
| 126 |
ad0c8e0e
|
Leszek Koltunski
|
setupObjectWindow(act,width);
|
| 127 |
e03e0352
|
Leszek Koltunski
|
|
| 128 |
211b48f2
|
Leszek Koltunski
|
// BOT ////////////////////////////
|
| 129 |
|
|
|
| 130 |
4c0cd600
|
Leszek Koltunski
|
LinearLayout layoutLeft = act.findViewById(R.id.mainBarLeft);
|
| 131 |
|
|
layoutLeft.removeAllViews();
|
| 132 |
4888e97c
|
Leszek Koltunski
|
|
| 133 |
ad0c8e0e
|
Leszek Koltunski
|
setupPrevButton(act,width);
|
| 134 |
15846fe4
|
Leszek Koltunski
|
layoutLeft.addView(mPrevButton);
|
| 135 |
ad0c8e0e
|
Leszek Koltunski
|
setupSolveButton(act,width);
|
| 136 |
31227bf6
|
Leszek Koltunski
|
layoutLeft.addView(mSolveButton);
|
| 137 |
769d7b9f
|
Leszek Koltunski
|
|
| 138 |
4c0cd600
|
Leszek Koltunski
|
LinearLayout layoutRight = act.findViewById(R.id.mainBarRight);
|
| 139 |
|
|
layoutRight.removeAllViews();
|
| 140 |
31227bf6
|
Leszek Koltunski
|
|
| 141 |
ad0c8e0e
|
Leszek Koltunski
|
setupMenuButton(act,width);
|
| 142 |
15846fe4
|
Leszek Koltunski
|
layoutRight.addView(mMenuButton);
|
| 143 |
211b48f2
|
Leszek Koltunski
|
|
| 144 |
ad0c8e0e
|
Leszek Koltunski
|
setupMenuWindow(act,width);
|
| 145 |
769d7b9f
|
Leszek Koltunski
|
}
|
| 146 |
211b48f2
|
Leszek Koltunski
|
|
| 147 |
769d7b9f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 148 |
4c0cd600
|
Leszek Koltunski
|
|
| 149 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupObjectButton(final RubikActivity act, final float width)
|
| 150 |
769d7b9f
|
Leszek Koltunski
|
{
|
| 151 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 152 |
|
|
int margin = (int)(width*RubikActivity.MARGIN);
|
| 153 |
31a9f38d
|
Leszek Koltunski
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu, R.drawable.ui_huge_cube_menu);
|
| 154 |
ad0c8e0e
|
Leszek Koltunski
|
|
| 155 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.2f);
|
| 156 |
|
|
params.topMargin = margin;
|
| 157 |
|
|
params.bottomMargin = margin;
|
| 158 |
|
|
params.leftMargin = margin;
|
| 159 |
|
|
params.rightMargin = margin;
|
| 160 |
|
|
|
| 161 |
769d7b9f
|
Leszek Koltunski
|
mObjButton = new ImageButton(act);
|
| 162 |
ad0c8e0e
|
Leszek Koltunski
|
mObjButton.setLayoutParams(params);
|
| 163 |
769d7b9f
|
Leszek Koltunski
|
mObjButton.setPadding(padding,0,padding,0);
|
| 164 |
f6a9c538
|
Leszek Koltunski
|
mObjButton.setImageResource(icon);
|
| 165 |
769d7b9f
|
Leszek Koltunski
|
|
| 166 |
|
|
mObjButton.setOnClickListener( new View.OnClickListener()
|
| 167 |
|
|
{
|
| 168 |
|
|
@Override
|
| 169 |
|
|
public void onClick(View view)
|
| 170 |
4c0cd600
|
Leszek Koltunski
|
{
|
| 171 |
5a4d4fba
|
Leszek Koltunski
|
if( act.getPreRender().canPlay() )
|
| 172 |
a42e25a6
|
Leszek Koltunski
|
{
|
| 173 |
|
|
int total = RubikObjectList.getTotal();
|
| 174 |
|
|
boolean vertical = act.isVertical();
|
| 175 |
e03e0352
|
Leszek Koltunski
|
mObjectLayout.setOrientation(vertical ? LinearLayout.VERTICAL:LinearLayout.HORIZONTAL);
|
| 176 |
4c0cd600
|
Leszek Koltunski
|
|
| 177 |
a42e25a6
|
Leszek Koltunski
|
int width = view.getWidth();
|
| 178 |
e03e0352
|
Leszek Koltunski
|
int layhei = mObjectLayoutWidth * (vertical? total:1);
|
| 179 |
|
|
int laywid = mObjectLayoutWidth * (vertical? 1:total);
|
| 180 |
4c0cd600
|
Leszek Koltunski
|
|
| 181 |
e03e0352
|
Leszek Koltunski
|
mObjectPopup.showAsDropDown(view, (width-laywid)/2, 0, Gravity.LEFT);
|
| 182 |
9439f455
|
Leszek Koltunski
|
|
| 183 |
|
|
if( android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1 )
|
| 184 |
|
|
{
|
| 185 |
e03e0352
|
Leszek Koltunski
|
mObjectPopup.update(view, laywid, layhei);
|
| 186 |
9439f455
|
Leszek Koltunski
|
}
|
| 187 |
a42e25a6
|
Leszek Koltunski
|
}
|
| 188 |
769d7b9f
|
Leszek Koltunski
|
}
|
| 189 |
|
|
});
|
| 190 |
|
|
}
|
| 191 |
4c0cd600
|
Leszek Koltunski
|
|
| 192 |
85b09df4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 193 |
|
|
|
| 194 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupLevelSpinner(final RubikActivity act, final float width)
|
| 195 |
85b09df4
|
Leszek Koltunski
|
{
|
| 196 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 197 |
|
|
int margin = (int)(width*RubikActivity.MARGIN);
|
| 198 |
31a9f38d
|
Leszek Koltunski
|
int spin = RubikActivity.getDrawable(R.drawable.ui_small_spinner,R.drawable.ui_big_spinner, R.drawable.ui_big_spinner, R.drawable.ui_huge_spinner);
|
| 199 |
f6a9c538
|
Leszek Koltunski
|
|
| 200 |
ad0c8e0e
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.0f);
|
| 201 |
|
|
params.topMargin = margin;
|
| 202 |
|
|
params.bottomMargin = margin;
|
| 203 |
|
|
params.leftMargin = margin;
|
| 204 |
|
|
params.rightMargin = margin;
|
| 205 |
85b09df4
|
Leszek Koltunski
|
|
| 206 |
8e3898c8
|
Leszek Koltunski
|
mLevelSpinner = new AppCompatSpinner(act);
|
| 207 |
ad0c8e0e
|
Leszek Koltunski
|
mLevelSpinner.setLayoutParams(params);
|
| 208 |
15846fe4
|
Leszek Koltunski
|
mLevelSpinner.setPadding(padding,0,padding,0);
|
| 209 |
f6a9c538
|
Leszek Koltunski
|
mLevelSpinner.setBackgroundResource(spin);
|
| 210 |
85b09df4
|
Leszek Koltunski
|
mLevelSpinner.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
| 211 |
|
|
|
| 212 |
|
|
mLevelSpinner.setOnItemSelectedListener(this);
|
| 213 |
8e3898c8
|
Leszek Koltunski
|
int sizeIndex = RubikObjectList.getSizeIndex(mObject,mSize);
|
| 214 |
|
|
int maxLevel = RubikObjectList.getMaxLevel(mObject, sizeIndex);
|
| 215 |
|
|
String[] levels = new String[maxLevel];
|
| 216 |
85b09df4
|
Leszek Koltunski
|
|
| 217 |
8e3898c8
|
Leszek Koltunski
|
for(int i=0; i<maxLevel; i++)
|
| 218 |
85b09df4
|
Leszek Koltunski
|
{
|
| 219 |
|
|
levels[i] = act.getString(R.string.lv_placeholder,i+1);
|
| 220 |
|
|
}
|
| 221 |
|
|
|
| 222 |
c7f9e82d
|
Leszek Koltunski
|
if( mLevelValue>maxLevel ) mLevelValue=1;
|
| 223 |
|
|
|
| 224 |
9513f213
|
Leszek Koltunski
|
mSpinnerAdapter = new ArrayAdapter<String>(act, android.R.layout.simple_spinner_item, levels)
|
| 225 |
|
|
{
|
| 226 |
|
|
@NonNull
|
| 227 |
|
|
public View getView(int position, View convertView, @NonNull ViewGroup parent)
|
| 228 |
|
|
{
|
| 229 |
|
|
View v = super.getView(position, convertView, parent);
|
| 230 |
|
|
TextView tv = ((TextView) v);
|
| 231 |
|
|
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize);
|
| 232 |
|
|
return v;
|
| 233 |
|
|
}
|
| 234 |
|
|
};
|
| 235 |
|
|
|
| 236 |
8e3898c8
|
Leszek Koltunski
|
mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
| 237 |
|
|
mLevelSpinner.setAdapter(mSpinnerAdapter);
|
| 238 |
85b09df4
|
Leszek Koltunski
|
mLevelSpinner.setSelection(mLevelValue-1);
|
| 239 |
|
|
}
|
| 240 |
|
|
|
| 241 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 242 |
|
|
|
| 243 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupPlayButton(final RubikActivity act, final float width)
|
| 244 |
85b09df4
|
Leszek Koltunski
|
{
|
| 245 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 246 |
|
|
int margin = (int)(width*RubikActivity.MARGIN);
|
| 247 |
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT, 1.2f);
|
| 248 |
|
|
params.topMargin = margin;
|
| 249 |
|
|
params.bottomMargin = margin;
|
| 250 |
|
|
params.leftMargin = margin;
|
| 251 |
|
|
params.rightMargin = margin;
|
| 252 |
|
|
|
| 253 |
85b09df4
|
Leszek Koltunski
|
mPlayButton = new Button(act);
|
| 254 |
ad0c8e0e
|
Leszek Koltunski
|
mPlayButton.setLayoutParams(params);
|
| 255 |
85b09df4
|
Leszek Koltunski
|
mPlayButton.setPadding(padding,0,padding,0);
|
| 256 |
e3c74c0f
|
Leszek Koltunski
|
mPlayButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize);
|
| 257 |
85b09df4
|
Leszek Koltunski
|
mPlayButton.setText(R.string.play);
|
| 258 |
|
|
|
| 259 |
|
|
mPlayButton.setOnClickListener( new View.OnClickListener()
|
| 260 |
|
|
{
|
| 261 |
|
|
@Override
|
| 262 |
|
|
public void onClick(View v)
|
| 263 |
|
|
{
|
| 264 |
5a4d4fba
|
Leszek Koltunski
|
act.getPreRender().scrambleObject(mLevelValue);
|
| 265 |
85b09df4
|
Leszek Koltunski
|
}
|
| 266 |
|
|
});
|
| 267 |
|
|
}
|
| 268 |
|
|
|
| 269 |
e31abc1e
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 270 |
|
|
|
| 271 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupMenuButton(final RubikActivity act, final float width)
|
| 272 |
e31abc1e
|
Leszek Koltunski
|
{
|
| 273 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 274 |
|
|
int margin = (int)(width*RubikActivity.MARGIN);
|
| 275 |
31a9f38d
|
Leszek Koltunski
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_menu,R.drawable.ui_medium_menu, R.drawable.ui_big_menu, R.drawable.ui_huge_menu);
|
| 276 |
f6a9c538
|
Leszek Koltunski
|
|
| 277 |
ad0c8e0e
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
| 278 |
|
|
params.topMargin = margin;
|
| 279 |
|
|
params.bottomMargin = margin;
|
| 280 |
|
|
params.leftMargin = margin;
|
| 281 |
|
|
params.rightMargin = margin;
|
| 282 |
|
|
|
| 283 |
e03e0352
|
Leszek Koltunski
|
mMenuButton = new ImageButton(act);
|
| 284 |
ad0c8e0e
|
Leszek Koltunski
|
mMenuButton.setLayoutParams(params);
|
| 285 |
e03e0352
|
Leszek Koltunski
|
mMenuButton.setPadding(padding,0,padding,0);
|
| 286 |
f6a9c538
|
Leszek Koltunski
|
mMenuButton.setImageResource(icon);
|
| 287 |
e31abc1e
|
Leszek Koltunski
|
|
| 288 |
88fb92ba
|
Leszek Koltunski
|
final int barHeight = act.getScreenHeightInPixels()/10;
|
| 289 |
|
|
|
| 290 |
e03e0352
|
Leszek Koltunski
|
mMenuButton.setOnClickListener( new View.OnClickListener()
|
| 291 |
e31abc1e
|
Leszek Koltunski
|
{
|
| 292 |
|
|
@Override
|
| 293 |
|
|
public void onClick(View view)
|
| 294 |
|
|
{
|
| 295 |
e03e0352
|
Leszek Koltunski
|
if( act.getPreRender().canPlay() )
|
| 296 |
|
|
{
|
| 297 |
88fb92ba
|
Leszek Koltunski
|
mMenuPopup.showAsDropDown(view, 0, -mMenuLayoutHeight-barHeight, Gravity.LEFT);
|
| 298 |
e03e0352
|
Leszek Koltunski
|
mMenuPopup.update();
|
| 299 |
|
|
}
|
| 300 |
e31abc1e
|
Leszek Koltunski
|
}
|
| 301 |
|
|
});
|
| 302 |
|
|
}
|
| 303 |
|
|
|
| 304 |
85b09df4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 305 |
|
|
|
| 306 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupSolveButton(final RubikActivity act, final float width)
|
| 307 |
85b09df4
|
Leszek Koltunski
|
{
|
| 308 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 309 |
|
|
int margin = (int)(width*RubikActivity.MARGIN);
|
| 310 |
15846fe4
|
Leszek Koltunski
|
int widthBut = (int)(width/6);
|
| 311 |
31a9f38d
|
Leszek Koltunski
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve,R.drawable.ui_medium_cube_solve, R.drawable.ui_big_cube_solve, R.drawable.ui_huge_cube_solve);
|
| 312 |
f6a9c538
|
Leszek Koltunski
|
|
| 313 |
ad0c8e0e
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut, LinearLayout.LayoutParams.MATCH_PARENT);
|
| 314 |
|
|
params.topMargin = margin;
|
| 315 |
|
|
params.bottomMargin = margin;
|
| 316 |
|
|
params.leftMargin = margin;
|
| 317 |
|
|
params.rightMargin = margin;
|
| 318 |
|
|
|
| 319 |
15846fe4
|
Leszek Koltunski
|
mSolveButton = new ImageButton(act);
|
| 320 |
ad0c8e0e
|
Leszek Koltunski
|
mSolveButton.setLayoutParams(params);
|
| 321 |
85b09df4
|
Leszek Koltunski
|
mSolveButton.setPadding(padding,0,padding,0);
|
| 322 |
f6a9c538
|
Leszek Koltunski
|
mSolveButton.setImageResource(icon);
|
| 323 |
85b09df4
|
Leszek Koltunski
|
|
| 324 |
|
|
mSolveButton.setOnClickListener( new View.OnClickListener()
|
| 325 |
|
|
{
|
| 326 |
|
|
@Override
|
| 327 |
|
|
public void onClick(View v)
|
| 328 |
|
|
{
|
| 329 |
5a4d4fba
|
Leszek Koltunski
|
act.getPreRender().solveObject();
|
| 330 |
5b893eee
|
Leszek Koltunski
|
mMoves.clear();
|
| 331 |
85b09df4
|
Leszek Koltunski
|
}
|
| 332 |
|
|
});
|
| 333 |
|
|
}
|
| 334 |
|
|
|
| 335 |
769d7b9f
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 336 |
4c0cd600
|
Leszek Koltunski
|
|
| 337 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupPrevButton(final RubikActivity act, final float width)
|
| 338 |
769d7b9f
|
Leszek Koltunski
|
{
|
| 339 |
ad0c8e0e
|
Leszek Koltunski
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 340 |
|
|
int margin = (int)(width*RubikActivity.MARGIN);
|
| 341 |
15846fe4
|
Leszek Koltunski
|
int widthBut = (int)(width/6);
|
| 342 |
31a9f38d
|
Leszek Koltunski
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_back,R.drawable.ui_medium_cube_back, R.drawable.ui_big_cube_back, R.drawable.ui_huge_cube_back);
|
| 343 |
f6a9c538
|
Leszek Koltunski
|
|
| 344 |
ad0c8e0e
|
Leszek Koltunski
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(widthBut, LinearLayout.LayoutParams.MATCH_PARENT);
|
| 345 |
|
|
params.topMargin = margin;
|
| 346 |
|
|
params.bottomMargin = margin;
|
| 347 |
|
|
params.leftMargin = margin;
|
| 348 |
|
|
params.rightMargin = margin;
|
| 349 |
|
|
|
| 350 |
15846fe4
|
Leszek Koltunski
|
mPrevButton = new ImageButton(act);
|
| 351 |
ad0c8e0e
|
Leszek Koltunski
|
mPrevButton.setLayoutParams(params);
|
| 352 |
15846fe4
|
Leszek Koltunski
|
mPrevButton.setPadding(padding,0,padding,0);
|
| 353 |
f6a9c538
|
Leszek Koltunski
|
mPrevButton.setImageResource(icon);
|
| 354 |
15846fe4
|
Leszek Koltunski
|
|
| 355 |
|
|
mPrevButton.setOnClickListener( new View.OnClickListener()
|
| 356 |
a6d3b158
|
Leszek Koltunski
|
{
|
| 357 |
|
|
@Override
|
| 358 |
|
|
public void onClick(View v)
|
| 359 |
|
|
{
|
| 360 |
15846fe4
|
Leszek Koltunski
|
RubikPreRender pre = act.getPreRender();
|
| 361 |
|
|
backMove(pre);
|
| 362 |
a6d3b158
|
Leszek Koltunski
|
}
|
| 363 |
|
|
});
|
| 364 |
211b48f2
|
Leszek Koltunski
|
}
|
| 365 |
|
|
|
| 366 |
4c0cd600
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 367 |
|
|
|
| 368 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupObjectWindow(final RubikActivity act, final float width)
|
| 369 |
4c0cd600
|
Leszek Koltunski
|
{
|
| 370 |
769d7b9f
|
Leszek Koltunski
|
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
| 371 |
|
|
final View layout = layoutInflater.inflate(R.layout.popup_objects, null);
|
| 372 |
e03e0352
|
Leszek Koltunski
|
mObjectLayout = layout.findViewById(R.id.popup);
|
| 373 |
769d7b9f
|
Leszek Koltunski
|
|
| 374 |
e03e0352
|
Leszek Koltunski
|
mObjectPopup = new PopupWindow(act);
|
| 375 |
|
|
mObjectPopup.setContentView(layout);
|
| 376 |
|
|
mObjectPopup.setFocusable(true);
|
| 377 |
f6a9c538
|
Leszek Koltunski
|
int margin = (int)(width*RubikActivity.LARGE_MARGIN);
|
| 378 |
31a9f38d
|
Leszek Koltunski
|
int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube2,R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2);
|
| 379 |
769d7b9f
|
Leszek Koltunski
|
|
| 380 |
f6a9c538
|
Leszek Koltunski
|
BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(icon);
|
| 381 |
769d7b9f
|
Leszek Koltunski
|
int cubeWidth = bd.getIntrinsicWidth();
|
| 382 |
e03e0352
|
Leszek Koltunski
|
mObjectLayoutWidth = (int)(cubeWidth + 2*margin + 0.5f);
|
| 383 |
4c0cd600
|
Leszek Koltunski
|
|
| 384 |
f6a9c538
|
Leszek Koltunski
|
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
|
| 385 |
|
|
p.setMargins(margin, margin, margin, margin);
|
| 386 |
|
|
|
| 387 |
769d7b9f
|
Leszek Koltunski
|
for(int object=0; object<RubikObjectList.NUM_OBJECTS; object++)
|
| 388 |
|
|
{
|
| 389 |
53f23b64
|
Leszek Koltunski
|
final RubikObjectList list = RubikObjectList.getObject(object);
|
| 390 |
|
|
final int[] sizes = list.getSizes();
|
| 391 |
769d7b9f
|
Leszek Koltunski
|
int[] icons = list.getIconIDs();
|
| 392 |
|
|
int len = sizes.length;
|
| 393 |
|
|
final int obj = object;
|
| 394 |
|
|
|
| 395 |
|
|
for(int i=0; i<len; i++)
|
| 396 |
|
|
{
|
| 397 |
|
|
final int size = i;
|
| 398 |
|
|
|
| 399 |
|
|
ImageButton button = new ImageButton(act);
|
| 400 |
|
|
button.setLayoutParams(p);
|
| 401 |
4c0cd600
|
Leszek Koltunski
|
|
| 402 |
769d7b9f
|
Leszek Koltunski
|
button.setBackgroundResource(icons[i]);
|
| 403 |
|
|
button.setOnClickListener( new View.OnClickListener()
|
| 404 |
|
|
{
|
| 405 |
|
|
@Override
|
| 406 |
|
|
public void onClick(View v)
|
| 407 |
|
|
{
|
| 408 |
5a4d4fba
|
Leszek Koltunski
|
if( act.getPreRender().canPlay() && RubikState.getCurrentState()==RubikState.PLAY )
|
| 409 |
a42e25a6
|
Leszek Koltunski
|
{
|
| 410 |
|
|
mObject = obj;
|
| 411 |
|
|
mSize = sizes[size];
|
| 412 |
7eae2d49
|
Leszek Koltunski
|
act.changeObject(list,sizes[size], true);
|
| 413 |
7b7d65ce
|
Leszek Koltunski
|
adjustSpinner(act);
|
| 414 |
40c8c5fa
|
Leszek Koltunski
|
mMoves.clear();
|
| 415 |
a42e25a6
|
Leszek Koltunski
|
}
|
| 416 |
8e3898c8
|
Leszek Koltunski
|
|
| 417 |
e03e0352
|
Leszek Koltunski
|
mObjectPopup.dismiss();
|
| 418 |
769d7b9f
|
Leszek Koltunski
|
}
|
| 419 |
|
|
});
|
| 420 |
|
|
|
| 421 |
e03e0352
|
Leszek Koltunski
|
mObjectLayout.addView(button);
|
| 422 |
769d7b9f
|
Leszek Koltunski
|
}
|
| 423 |
|
|
}
|
| 424 |
4c0cd600
|
Leszek Koltunski
|
}
|
| 425 |
|
|
|
| 426 |
e03e0352
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 427 |
|
|
|
| 428 |
ad0c8e0e
|
Leszek Koltunski
|
private void setupMenuWindow(final RubikActivity act, final float width)
|
| 429 |
e03e0352
|
Leszek Koltunski
|
{
|
| 430 |
|
|
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
| 431 |
|
|
final View layout = layoutInflater.inflate(R.layout.popup_objects, null);
|
| 432 |
|
|
mMenuLayout = layout.findViewById(R.id.popup);
|
| 433 |
|
|
|
| 434 |
|
|
mMenuPopup = new PopupWindow(act);
|
| 435 |
|
|
mMenuPopup.setContentView(layout);
|
| 436 |
|
|
mMenuPopup.setFocusable(true);
|
| 437 |
ad0c8e0e
|
Leszek Koltunski
|
int margin = (int)(width*RubikActivity.MARGIN);
|
| 438 |
|
|
int padding = (int)(width*RubikActivity.PADDING);
|
| 439 |
e03e0352
|
Leszek Koltunski
|
|
| 440 |
ad0c8e0e
|
Leszek Koltunski
|
LinearLayout.LayoutParams p0 = new LinearLayout.LayoutParams( (int)width/2 - 2*padding, (int)mMenuItemSize);
|
| 441 |
|
|
p0.setMargins(margin, 0, margin, margin);
|
| 442 |
|
|
LinearLayout.LayoutParams p1 = new LinearLayout.LayoutParams( (int)width/2 - 2*padding, (int)mMenuItemSize);
|
| 443 |
|
|
p1.setMargins(margin, margin, margin, margin);
|
| 444 |
e03e0352
|
Leszek Koltunski
|
|
| 445 |
|
|
for(int i=0; i<NUM_BUTTONS; i++)
|
| 446 |
|
|
{
|
| 447 |
|
|
final int but = i;
|
| 448 |
|
|
Button button = new Button(act);
|
| 449 |
ad0c8e0e
|
Leszek Koltunski
|
button.setLayoutParams(i==0 ? p1:p0);
|
| 450 |
e03e0352
|
Leszek Koltunski
|
button.setText(BUTTON_LABELS[i]);
|
| 451 |
88fb92ba
|
Leszek Koltunski
|
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
|
| 452 |
e03e0352
|
Leszek Koltunski
|
|
| 453 |
|
|
button.setOnClickListener( new View.OnClickListener()
|
| 454 |
|
|
{
|
| 455 |
|
|
@Override
|
| 456 |
|
|
public void onClick(View v)
|
| 457 |
|
|
{
|
| 458 |
|
|
mMenuPopup.dismiss();
|
| 459 |
|
|
Action(act,but);
|
| 460 |
|
|
}
|
| 461 |
|
|
});
|
| 462 |
|
|
|
| 463 |
|
|
mMenuLayout.addView(button);
|
| 464 |
|
|
}
|
| 465 |
|
|
|
| 466 |
ad0c8e0e
|
Leszek Koltunski
|
mMenuLayoutHeight= (int)(margin + NUM_BUTTONS*(mMenuItemSize+margin));
|
| 467 |
e03e0352
|
Leszek Koltunski
|
}
|
| 468 |
|
|
|
| 469 |
15846fe4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 470 |
|
|
|
| 471 |
|
|
private void backMove(RubikPreRender pre)
|
| 472 |
|
|
{
|
| 473 |
|
|
if( mCanPrevMove )
|
| 474 |
|
|
{
|
| 475 |
|
|
int numMoves = mMoves.size();
|
| 476 |
|
|
|
| 477 |
|
|
if( numMoves>0 )
|
| 478 |
|
|
{
|
| 479 |
|
|
Move move = mMoves.remove(numMoves-1);
|
| 480 |
|
|
RubikObject object = pre.getObject();
|
| 481 |
|
|
|
| 482 |
|
|
int axis = move.mAxis;
|
| 483 |
|
|
int row = (1<<move.mRow);
|
| 484 |
|
|
int angle = move.mAngle;
|
| 485 |
|
|
int numRot= Math.abs(angle*object.getBasicAngle()/360);
|
| 486 |
|
|
|
| 487 |
|
|
if( angle!=0 )
|
| 488 |
|
|
{
|
| 489 |
|
|
mCanPrevMove = false;
|
| 490 |
|
|
pre.addRotation(this, axis, row, -angle, numRot*DURATION_MILLIS);
|
| 491 |
|
|
}
|
| 492 |
|
|
else
|
| 493 |
|
|
{
|
| 494 |
|
|
android.util.Log.e("solution", "error: trying to back move of angle 0");
|
| 495 |
|
|
}
|
| 496 |
|
|
}
|
| 497 |
|
|
}
|
| 498 |
|
|
}
|
| 499 |
e03e0352
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 500 |
|
|
|
| 501 |
|
|
private void Action(RubikActivity act, int button)
|
| 502 |
|
|
{
|
| 503 |
|
|
switch(button)
|
| 504 |
|
|
{
|
| 505 |
|
|
case 0: RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass();
|
| 506 |
|
|
int object = play.getObject();
|
| 507 |
|
|
int size = play.getSize();
|
| 508 |
|
|
int sizeIndex = RubikObjectList.getSizeIndex(object,size);
|
| 509 |
|
|
|
| 510 |
|
|
Bundle bundle = new Bundle();
|
| 511 |
|
|
bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
|
| 512 |
|
|
bundle.putBoolean("submitting", false);
|
| 513 |
|
|
|
| 514 |
|
|
RubikDialogScores scores = new RubikDialogScores();
|
| 515 |
|
|
scores.setArguments(bundle);
|
| 516 |
|
|
scores.show(act.getSupportFragmentManager(), null);
|
| 517 |
|
|
break;
|
| 518 |
|
|
case 1: RubikState.switchState(act,RubikState.PATT);
|
| 519 |
|
|
break;
|
| 520 |
|
|
case 2: RubikState.switchState(act,RubikState.SVER);
|
| 521 |
|
|
break;
|
| 522 |
|
|
case 3: RubikDialogAbout diag = new RubikDialogAbout();
|
| 523 |
|
|
diag.show(act.getSupportFragmentManager(), null);
|
| 524 |
|
|
break;
|
| 525 |
|
|
}
|
| 526 |
|
|
}
|
| 527 |
|
|
|
| 528 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 529 |
|
|
|
| 530 |
|
|
public void savePreferences(SharedPreferences.Editor editor)
|
| 531 |
|
|
{
|
| 532 |
85b09df4
|
Leszek Koltunski
|
editor.putInt("statePlay_level" , mLevelValue);
|
| 533 |
4888e97c
|
Leszek Koltunski
|
editor.putInt("statePlay_object", mObject);
|
| 534 |
|
|
editor.putInt("statePlay_size" , mSize);
|
| 535 |
4c0cd600
|
Leszek Koltunski
|
|
| 536 |
e03e0352
|
Leszek Koltunski
|
if( mObjectPopup!=null )
|
| 537 |
|
|
{
|
| 538 |
|
|
mObjectPopup.dismiss();
|
| 539 |
|
|
mObjectPopup = null;
|
| 540 |
|
|
}
|
| 541 |
|
|
|
| 542 |
|
|
if( mMenuPopup!=null )
|
| 543 |
4c0cd600
|
Leszek Koltunski
|
{
|
| 544 |
e03e0352
|
Leszek Koltunski
|
mMenuPopup.dismiss();
|
| 545 |
|
|
mMenuPopup = null;
|
| 546 |
4c0cd600
|
Leszek Koltunski
|
}
|
| 547 |
211b48f2
|
Leszek Koltunski
|
}
|
| 548 |
|
|
|
| 549 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 550 |
|
|
|
| 551 |
|
|
public void restorePreferences(SharedPreferences preferences)
|
| 552 |
|
|
{
|
| 553 |
85b09df4
|
Leszek Koltunski
|
mLevelValue = preferences.getInt("statePlay_level" , DEF_LEVEL );
|
| 554 |
|
|
mObject = preferences.getInt("statePlay_object", DEF_OBJECT);
|
| 555 |
|
|
mSize = preferences.getInt("statePlay_size" , DEF_SIZE );
|
| 556 |
211b48f2
|
Leszek Koltunski
|
}
|
| 557 |
|
|
|
| 558 |
53f23b64
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 559 |
|
|
|
| 560 |
7b7d65ce
|
Leszek Koltunski
|
public boolean setObjectAndSize(RubikActivity act, RubikObjectList obj, int size)
|
| 561 |
53f23b64
|
Leszek Koltunski
|
{
|
| 562 |
7b7d65ce
|
Leszek Koltunski
|
if( mObject!=obj.ordinal() || mSize != size )
|
| 563 |
|
|
{
|
| 564 |
|
|
boolean success = false;
|
| 565 |
53f23b64
|
Leszek Koltunski
|
|
| 566 |
7b7d65ce
|
Leszek Koltunski
|
for( int s: obj.getSizes() )
|
| 567 |
|
|
if( s==size )
|
| 568 |
|
|
{
|
| 569 |
|
|
success = true;
|
| 570 |
|
|
break;
|
| 571 |
|
|
}
|
| 572 |
|
|
|
| 573 |
|
|
if( success )
|
| 574 |
53f23b64
|
Leszek Koltunski
|
{
|
| 575 |
7b7d65ce
|
Leszek Koltunski
|
mObject = obj.ordinal();
|
| 576 |
|
|
mSize = size;
|
| 577 |
5f8c532e
|
Leszek Koltunski
|
|
| 578 |
|
|
if( mLevelSpinner!=null ) adjustSpinner(act);
|
| 579 |
53f23b64
|
Leszek Koltunski
|
}
|
| 580 |
|
|
|
| 581 |
7b7d65ce
|
Leszek Koltunski
|
return success;
|
| 582 |
|
|
}
|
| 583 |
|
|
|
| 584 |
|
|
return true;
|
| 585 |
|
|
}
|
| 586 |
|
|
|
| 587 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 588 |
|
|
|
| 589 |
|
|
private void adjustSpinner(RubikActivity act)
|
| 590 |
|
|
{
|
| 591 |
|
|
int sizeIndex = RubikObjectList.getSizeIndex(mObject,mSize);
|
| 592 |
|
|
int maxLevel = RubikObjectList.getMaxLevel(mObject, sizeIndex);
|
| 593 |
|
|
String[] levels = new String[maxLevel];
|
| 594 |
|
|
|
| 595 |
|
|
for(int i=0; i<maxLevel; i++)
|
| 596 |
53f23b64
|
Leszek Koltunski
|
{
|
| 597 |
7b7d65ce
|
Leszek Koltunski
|
levels[i] = act.getString(R.string.lv_placeholder,i+1);
|
| 598 |
53f23b64
|
Leszek Koltunski
|
}
|
| 599 |
|
|
|
| 600 |
011fcfe0
|
Leszek Koltunski
|
mSpinnerAdapter = new ArrayAdapter<String>(act, android.R.layout.simple_spinner_item, levels)
|
| 601 |
|
|
{
|
| 602 |
|
|
@NonNull
|
| 603 |
|
|
public View getView(int position, View convertView, @NonNull ViewGroup parent)
|
| 604 |
|
|
{
|
| 605 |
|
|
View v = super.getView(position, convertView, parent);
|
| 606 |
|
|
TextView tv = ((TextView) v);
|
| 607 |
|
|
tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButtonSize);
|
| 608 |
|
|
return v;
|
| 609 |
|
|
}
|
| 610 |
|
|
};
|
| 611 |
|
|
|
| 612 |
7b7d65ce
|
Leszek Koltunski
|
mSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
| 613 |
|
|
mLevelSpinner.setAdapter(mSpinnerAdapter);
|
| 614 |
53f23b64
|
Leszek Koltunski
|
}
|
| 615 |
|
|
|
| 616 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 617 |
|
|
|
| 618 |
85b09df4
|
Leszek Koltunski
|
int getLevel()
|
| 619 |
211b48f2
|
Leszek Koltunski
|
{
|
| 620 |
85b09df4
|
Leszek Koltunski
|
return mLevelValue;
|
| 621 |
211b48f2
|
Leszek Koltunski
|
}
|
| 622 |
|
|
|
| 623 |
15846fe4
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 624 |
|
|
|
| 625 |
|
|
public void addMove(int axis, int row, int angle)
|
| 626 |
|
|
{
|
| 627 |
|
|
mMoves.add(new Move(axis,row,angle));
|
| 628 |
|
|
}
|
| 629 |
|
|
|
| 630 |
211b48f2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 631 |
|
|
|
| 632 |
4888e97c
|
Leszek Koltunski
|
public int getObject()
|
| 633 |
211b48f2
|
Leszek Koltunski
|
{
|
| 634 |
4888e97c
|
Leszek Koltunski
|
return mObject;
|
| 635 |
211b48f2
|
Leszek Koltunski
|
}
|
| 636 |
|
|
|
| 637 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 638 |
|
|
|
| 639 |
4888e97c
|
Leszek Koltunski
|
public int getSize()
|
| 640 |
211b48f2
|
Leszek Koltunski
|
{
|
| 641 |
4888e97c
|
Leszek Koltunski
|
return mSize;
|
| 642 |
|
|
}
|
| 643 |
85b09df4
|
Leszek Koltunski
|
|
| 644 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 645 |
|
|
|
| 646 |
|
|
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
|
| 647 |
|
|
{
|
| 648 |
|
|
mLevelValue = pos+1;
|
| 649 |
|
|
}
|
| 650 |
|
|
|
| 651 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 652 |
|
|
|
| 653 |
|
|
public void onNothingSelected(AdapterView<?> parent) { }
|
| 654 |
15846fe4
|
Leszek Koltunski
|
|
| 655 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 656 |
|
|
|
| 657 |
|
|
public void onActionFinished(final long effectID)
|
| 658 |
|
|
{
|
| 659 |
|
|
mCanPrevMove = true;
|
| 660 |
|
|
}
|
| 661 |
211b48f2
|
Leszek Koltunski
|
}
|