Revision 1d9b0500
Added by Leszek Koltunski 1 day ago
| src/main/java/org/distorted/helpers/RubikRememberedSolves.java | ||
|---|---|---|
| 66 | 66 |
return data; |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 70 |
|
|
| 71 |
public long getTime(JSONObject object) throws JSONException |
|
| 72 |
{
|
|
| 73 |
return object.getLong("time");
|
|
| 74 |
} |
|
| 75 |
|
|
| 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 77 |
|
|
| 78 |
public Static4D getRotQuat(JSONObject object) throws JSONException |
|
| 79 |
{
|
|
| 80 |
float r0 = (float)object.getDouble("rot0");
|
|
| 81 |
float r1 = (float)object.getDouble("rot1");
|
|
| 82 |
float r2 = (float)object.getDouble("rot2");
|
|
| 83 |
float r3 = (float)object.getDouble("rot3");
|
|
| 84 |
|
|
| 85 |
return new Static4D(r0,r1,r2,r3); |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 89 |
|
|
| 90 |
public int[] getQuats(JSONObject object) throws JSONException |
|
| 91 |
{
|
|
| 92 |
JSONArray quats = object.getJSONArray("quats");
|
|
| 93 |
int len = quats.length(); |
|
| 94 |
int[] ret = new int[len]; |
|
| 95 |
for(int i=0; i<len; i++) ret[i] = quats.getInt(i); |
|
| 96 |
return ret; |
|
| 97 |
} |
|
| 98 |
|
|
| 69 | 99 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 70 | 100 |
|
| 71 | 101 |
public JSONArray readFile(Activity act, String objname) |
| src/main/java/org/distorted/main/MainActivity.java | ||
|---|---|---|
| 40 | 40 |
import org.distorted.helpers.RubikNetwork; |
| 41 | 41 |
import org.distorted.helpers.RubikScores; |
| 42 | 42 |
import org.distorted.helpers.RubikUpdates; |
| 43 |
import org.distorted.library.type.Static4D; |
|
| 43 | 44 |
import org.distorted.messaging.RubikInAppMessanging; |
| 44 | 45 |
import org.distorted.objects.RubikObject; |
| 45 | 46 |
import org.distorted.objects.RubikObjectList; |
| ... | ... | |
| 337 | 338 |
|
| 338 | 339 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 339 | 340 |
|
| 340 |
public void switchToPlay(RubikObject object, int ordinal, int scrambles, int level) |
|
| 341 |
public void switchToPlay(RubikObject object, int ordinal, int scrambles, int level, long time, Static4D rot, int[] quats)
|
|
| 341 | 342 |
{
|
| 342 | 343 |
boolean local = object.isLocal(); |
| 343 | 344 |
String name = local ? object.getLowerName() : object.getUpperName(); |
| ... | ... | |
| 348 | 349 |
intent.putExtra("scrambles", scrambles);
|
| 349 | 350 |
intent.putExtra("local", local );
|
| 350 | 351 |
intent.putExtra("ordinal", ordinal );
|
| 352 |
intent.putExtra("time", time);
|
|
| 353 |
|
|
| 354 |
if( rot!=null ) |
|
| 355 |
{
|
|
| 356 |
intent.putExtra("rot0", rot.get0() );
|
|
| 357 |
intent.putExtra("rot1", rot.get0() );
|
|
| 358 |
intent.putExtra("rot2", rot.get0() );
|
|
| 359 |
intent.putExtra("rot3", rot.get0() );
|
|
| 360 |
} |
|
| 361 |
if( quats!=null ) |
|
| 362 |
{
|
|
| 363 |
intent.putExtra("quats", quats);
|
|
| 364 |
} |
|
| 351 | 365 |
|
| 352 | 366 |
startActivity(intent); |
| 353 | 367 |
} |
| src/main/java/org/distorted/main/MainObjectPopup.java | ||
|---|---|---|
| 286 | 286 |
MainSolvesPopup popup = new MainSolvesPopup(act,object,mObjectOrdinal,scrambles,ll,json,height); |
| 287 | 287 |
popup.show(v); |
| 288 | 288 |
} |
| 289 |
else act.switchToPlay(object,mObjectOrdinal,scrambles,ll); |
|
| 289 |
else act.switchToPlay(object,mObjectOrdinal,scrambles,ll,0,null,null);
|
|
| 290 | 290 |
} |
| 291 | 291 |
}); |
| 292 | 292 |
} |
| src/main/java/org/distorted/main/MainSolvesPopup.java | ||
|---|---|---|
| 22 | 22 |
import android.widget.TextView; |
| 23 | 23 |
|
| 24 | 24 |
import org.distorted.helpers.RubikRememberedSolves; |
| 25 |
import org.distorted.library.type.Static4D; |
|
| 25 | 26 |
import org.distorted.objects.RubikObject; |
| 26 | 27 |
import org.json.JSONArray; |
| 27 | 28 |
import org.json.JSONException; |
| ... | ... | |
| 79 | 80 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, textH ); |
| 80 | 81 |
|
| 81 | 82 |
int numSolves = array.length(); |
| 83 |
RubikRememberedSolves solves = RubikRememberedSolves.getInstance(); |
|
| 82 | 84 |
|
| 83 | 85 |
try |
| 84 | 86 |
{
|
| 85 | 87 |
for(int s=0; s<numSolves; s++) |
| 86 | 88 |
{
|
| 87 | 89 |
JSONObject object = array.getJSONObject(s); |
| 88 |
long time = object.getLong("time");
|
|
| 89 |
View pane = createOldPane(act, s, time, pL, pT); |
|
| 90 |
long time = solves.getTime(object); |
|
| 91 |
Static4D rotQuat = solves.getRotQuat(object); |
|
| 92 |
int[] quats = solves.getQuats(object); |
|
| 93 |
View pane = createOldPane(act, s, time, rotQuat, quats, pL, pT); |
|
| 90 | 94 |
mLayout.addView(pane); |
| 91 | 95 |
} |
| 92 | 96 |
} |
| ... | ... | |
| 117 | 121 |
|
| 118 | 122 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 119 | 123 |
|
| 120 |
private View createOldPane(MainActivity act, int index, long time, LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText) |
|
| 124 |
private View createOldPane(MainActivity act, int index, long time, Static4D rot, int[] quats, LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText)
|
|
| 121 | 125 |
{
|
| 122 | 126 |
View view = act.getLayoutInflater().inflate(R.layout.dialog_solve_old_pane, null); |
| 123 | 127 |
TextView title = view.findViewById(R.id.solves_pane_title); |
| ... | ... | |
| 161 | 165 |
@Override |
| 162 | 166 |
public void onClick(View v) |
| 163 | 167 |
{
|
| 164 |
android.util.Log.e("D", "RESUME");
|
|
| 168 |
mPopup.dismiss(); |
|
| 169 |
act.switchToPlay(mObject,mObjectOrdinal,mNumScrambles,mLevel, time, rot, quats); |
|
| 165 | 170 |
} |
| 166 | 171 |
}); |
| 167 | 172 |
|
| ... | ... | |
| 190 | 195 |
public void onClick(View v) |
| 191 | 196 |
{
|
| 192 | 197 |
mPopup.dismiss(); |
| 193 |
act.switchToPlay(mObject,mObjectOrdinal,mNumScrambles,mLevel); |
|
| 198 |
act.switchToPlay(mObject,mObjectOrdinal,mNumScrambles,mLevel,0,null,null);
|
|
| 194 | 199 |
} |
| 195 | 200 |
}); |
| 196 | 201 |
|
| src/main/java/org/distorted/play/PlayActivity.java | ||
|---|---|---|
| 53 | 53 |
|
| 54 | 54 |
private String mObjectName; |
| 55 | 55 |
private int mNumScrambles; |
| 56 |
private long mTime; |
|
| 57 |
private Static4D mRotQuat; |
|
| 58 |
private int[] mQuats; |
|
| 56 | 59 |
private boolean mObjectLocal; |
| 57 | 60 |
private int mObjectOrdinal; |
| 58 | 61 |
private int mLevel; |
| ... | ... | |
| 81 | 84 |
mNumScrambles = b.getInt("scrambles");
|
| 82 | 85 |
mObjectLocal = b.getBoolean("local");
|
| 83 | 86 |
mObjectOrdinal = b.getInt("ordinal");
|
| 87 |
mTime = b.getLong("time");
|
|
| 88 |
|
|
| 89 |
if( mTime>0 ) |
|
| 90 |
{
|
|
| 91 |
float r0 = b.getFloat("rot0");
|
|
| 92 |
float r1 = b.getFloat("rot1");
|
|
| 93 |
float r2 = b.getFloat("rot2");
|
|
| 94 |
float r3 = b.getFloat("rot3");
|
|
| 95 |
mRotQuat = new Static4D(r0,r1,r2,r3); |
|
| 96 |
mQuats = b.getIntArray("quqts");
|
|
| 97 |
} |
|
| 84 | 98 |
} |
| 85 | 99 |
else |
| 86 | 100 |
{
|
| ... | ... | |
| 89 | 103 |
mNumScrambles = 0; |
| 90 | 104 |
mObjectLocal = true; |
| 91 | 105 |
mObjectOrdinal = 0; |
| 106 |
mTime = 0; |
|
| 107 |
mRotQuat = null; |
|
| 108 |
mQuats = null; |
|
| 92 | 109 |
} |
| 93 | 110 |
|
| 94 | 111 |
mModeFree = (mLevel<0); |
Also available in: Unified diff
progress with remembering solves.