Revision 52547ba7
Added by Leszek Koltunski about 4 years ago
| src/main/java/org/distorted/dialogs/RubikDialogPattern.java | ||
|---|---|---|
| 44 | 44 |
import org.distorted.main.R; |
| 45 | 45 |
import org.distorted.main.RubikActivity; |
| 46 | 46 |
import org.distorted.patterns.RubikPatternList; |
| 47 |
import org.distorted.screens.RubikScreenPlay; |
|
| 48 |
import org.distorted.screens.ScreenList; |
|
| 47 | 49 |
|
| 48 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 49 | 51 |
|
| ... | ... | |
| 80 | 82 |
} |
| 81 | 83 |
}); |
| 82 | 84 |
|
| 83 |
Bundle args = getArguments(); |
|
| 84 |
int curTab; |
|
| 85 |
|
|
| 86 |
try |
|
| 87 |
{
|
|
| 88 |
curTab = args.getInt("tab");
|
|
| 89 |
} |
|
| 90 |
catch(Exception e) |
|
| 91 |
{
|
|
| 92 |
curTab = 0; |
|
| 93 |
} |
|
| 94 |
|
|
| 95 | 85 |
LayoutInflater inflater = act.getLayoutInflater(); |
| 96 | 86 |
final View view = inflater.inflate(R.layout.dialog_tabbed, null); |
| 97 | 87 |
builder.setView(view); |
| ... | ... | |
| 100 | 90 |
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs); |
| 101 | 91 |
mPagerAdapter = new RubikDialogPatternPagerAdapter(act, viewPager, this); |
| 102 | 92 |
tabLayout.setupWithViewPager(viewPager); |
| 103 |
viewPager.setCurrentItem(curTab);
|
|
| 93 |
viewPager.setCurrentItem(getPatternOrdinal());
|
|
| 104 | 94 |
|
| 105 | 95 |
for(int i=0; i< RubikPatternList.NUM_OBJECTS; i++) |
| 106 | 96 |
{
|
| ... | ... | |
| 136 | 126 |
return dialog; |
| 137 | 127 |
} |
| 138 | 128 |
|
| 129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 130 |
|
|
| 131 |
private int getPatternOrdinal() |
|
| 132 |
{
|
|
| 133 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
| 134 |
ObjectType obj = play.getObject(); |
|
| 135 |
int ret = RubikPatternList.getOrdinal(obj); |
|
| 136 |
|
|
| 137 |
if( ret<0 ) |
|
| 138 |
{
|
|
| 139 |
ret = RubikPatternList.getOrdinal(RubikScreenPlay.DEF_OBJECT); |
|
| 140 |
} |
|
| 141 |
|
|
| 142 |
return ret; |
|
| 143 |
} |
|
| 144 |
|
|
| 139 | 145 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 140 | 146 |
|
| 141 | 147 |
@Override |
| src/main/java/org/distorted/dialogs/RubikDialogTutorial.java | ||
|---|---|---|
| 43 | 43 |
|
| 44 | 44 |
import org.distorted.main.R; |
| 45 | 45 |
import org.distorted.main.RubikActivity; |
| 46 |
import org.distorted.objectlib.main.ObjectType; |
|
| 47 |
import org.distorted.screens.RubikScreenPlay; |
|
| 48 |
import org.distorted.screens.ScreenList; |
|
| 46 | 49 |
import org.distorted.tutorials.TutorialList; |
| 47 | 50 |
|
| 48 | 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 80 | 83 |
} |
| 81 | 84 |
}); |
| 82 | 85 |
|
| 83 |
Bundle args = getArguments(); |
|
| 84 |
int curTab; |
|
| 85 |
|
|
| 86 |
try |
|
| 87 |
{
|
|
| 88 |
curTab = args.getInt("tab");
|
|
| 89 |
} |
|
| 90 |
catch(Exception e) |
|
| 91 |
{
|
|
| 92 |
curTab = 0; |
|
| 93 |
} |
|
| 94 |
|
|
| 95 | 86 |
LayoutInflater inflater = act.getLayoutInflater(); |
| 96 | 87 |
final View view = inflater.inflate(R.layout.dialog_tabbed, null); |
| 97 | 88 |
builder.setView(view); |
| ... | ... | |
| 100 | 91 |
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs); |
| 101 | 92 |
mPagerAdapter = new RubikDialogTutorialPagerAdapter(act,viewPager); |
| 102 | 93 |
tabLayout.setupWithViewPager(viewPager); |
| 103 |
viewPager.setCurrentItem(curTab);
|
|
| 94 |
viewPager.setCurrentItem(getTutorialOrdinal());
|
|
| 104 | 95 |
|
| 105 | 96 |
for(int i=0; i<TutorialList.NUM_OBJECTS; i++) |
| 106 | 97 |
{
|
| ... | ... | |
| 134 | 125 |
return dialog; |
| 135 | 126 |
} |
| 136 | 127 |
|
| 128 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 129 |
|
|
| 130 |
private int getTutorialOrdinal() |
|
| 131 |
{
|
|
| 132 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
| 133 |
ObjectType obj = play.getObject(); |
|
| 134 |
|
|
| 135 |
int ret = TutorialList.getOrdinal(obj); |
|
| 136 |
|
|
| 137 |
if( ret<0 ) |
|
| 138 |
{
|
|
| 139 |
ret = TutorialList.getOrdinal(RubikScreenPlay.DEF_OBJECT); |
|
| 140 |
} |
|
| 141 |
|
|
| 142 |
return ret; |
|
| 143 |
} |
|
| 144 |
|
|
| 137 | 145 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 138 | 146 |
|
| 139 | 147 |
@Override |
| src/main/java/org/distorted/screens/RubikScreenAbstract.java | ||
|---|---|---|
| 1 | 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 |
// Copyright 2020 Leszek Koltunski //
|
|
| 2 |
// Copyright 2021 Leszek Koltunski //
|
|
| 3 | 3 |
// // |
| 4 | 4 |
// This file is part of Magic Cube. // |
| 5 | 5 |
// // |
| ... | ... | |
| 22 | 22 |
import android.content.SharedPreferences; |
| 23 | 23 |
|
| 24 | 24 |
import org.distorted.main.RubikActivity; |
| 25 |
import org.distorted.objectlib.main.ObjectType; |
|
| 26 |
import org.distorted.patterns.RubikPatternList; |
|
| 27 |
import org.distorted.tutorials.TutorialList; |
|
| 28 | 25 |
|
| 29 | 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 30 | 27 |
|
| 31 | 28 |
public abstract class RubikScreenAbstract |
| 32 | 29 |
{
|
| 33 |
int getPatternOrdinal() |
|
| 34 |
{
|
|
| 35 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
| 36 |
ObjectType obj = play.getObject(); |
|
| 37 |
int ret = RubikPatternList.getOrdinal(obj); |
|
| 38 |
|
|
| 39 |
if( ret<0 ) |
|
| 40 |
{
|
|
| 41 |
ret = RubikPatternList.getOrdinal(RubikScreenPlay.DEF_OBJECT); |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
return ret; |
|
| 45 |
} |
|
| 46 |
|
|
| 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 |
|
|
| 49 |
int getTutorialOrdinal() |
|
| 50 |
{
|
|
| 51 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
|
| 52 |
ObjectType obj = play.getObject(); |
|
| 53 |
|
|
| 54 |
int ret = TutorialList.getOrdinal(obj); |
|
| 55 |
|
|
| 56 |
if( ret<0 ) |
|
| 57 |
{
|
|
| 58 |
ret = TutorialList.getOrdinal(RubikScreenPlay.DEF_OBJECT); |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
return ret; |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 65 |
|
|
| 66 | 30 |
abstract void enterScreen(RubikActivity act); |
| 67 | 31 |
abstract void leaveScreen(RubikActivity act); |
| 68 | 32 |
public abstract void savePreferences(SharedPreferences.Editor editor); |
| src/main/java/org/distorted/screens/RubikScreenPattern.java | ||
|---|---|---|
| 20 | 20 |
package org.distorted.screens; |
| 21 | 21 |
|
| 22 | 22 |
import android.content.SharedPreferences; |
| 23 |
import android.os.Bundle; |
|
| 24 | 23 |
import androidx.fragment.app.FragmentManager; |
| 25 | 24 |
import android.util.TypedValue; |
| 26 | 25 |
import android.view.Gravity; |
| ... | ... | |
| 78 | 77 |
float width = act.getScreenWidthInPixels(); |
| 79 | 78 |
mButtonSize = width*RubikActivity.BUTTON_TEXT_SIZE; |
| 80 | 79 |
float titleSize = width*RubikActivity.TITLE_TEXT_SIZE; |
| 81 |
mPatternOrdinal = getPatternOrdinal(); |
|
| 82 | 80 |
LayoutInflater inflater = act.getLayoutInflater(); |
| 83 | 81 |
|
| 84 | 82 |
// TOP //////////////////////////// |
| ... | ... | |
| 128 | 126 |
private void showDialog(FragmentManager manager) |
| 129 | 127 |
{
|
| 130 | 128 |
RubikDialogPattern diag = new RubikDialogPattern(); |
| 131 |
Bundle bundle = new Bundle(); |
|
| 132 |
bundle.putInt("tab", mPatternOrdinal );
|
|
| 133 |
diag.setArguments(bundle); |
|
| 134 | 129 |
diag.show( manager, RubikDialogPattern.getDialogTag() ); |
| 135 | 130 |
} |
| 136 | 131 |
|
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 366 | 366 |
scores.show(act.getSupportFragmentManager(), null); |
| 367 | 367 |
break; |
| 368 | 368 |
case 1: RubikDialogPattern pDiag = new RubikDialogPattern(); |
| 369 |
Bundle pBundle = new Bundle(); |
|
| 370 |
int pOrd = getPatternOrdinal(); |
|
| 371 |
pBundle.putInt("tab", pOrd );
|
|
| 372 |
pDiag.setArguments(pBundle); |
|
| 373 | 369 |
pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() ); |
| 374 | 370 |
break; |
| 375 | 371 |
case 2: ScreenList.switchScreen(act, ScreenList.SVER); |
| 376 | 372 |
break; |
| 377 | 373 |
case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial(); |
| 378 |
Bundle tBundle = new Bundle(); |
|
| 379 |
int tOrd = getTutorialOrdinal(); |
|
| 380 |
tBundle.putInt("tab", tOrd );
|
|
| 381 |
tDiag.setArguments(tBundle); |
|
| 382 | 374 |
tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() ); |
| 383 | 375 |
break; |
| 384 | 376 |
case 4: RubikDialogAbout aDiag = new RubikDialogAbout(); |
Also available in: Unified diff
Simplification