Revision 52547ba7
Added by Leszek Koltunski over 2 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 |
Also available in: Unified diff
Simplification