Project

General

Profile

« Previous | Next » 

Revision 32f60dec

Added by Leszek Koltunski over 4 years ago

Downloading High Scores: make the Scores Dialog always start from appropriate tab

View differences:

src/main/java/org/distorted/magic/RubikActivity.java
45 45
    public static final int DEF_SCRAMBLE =  1;
46 46
    public static final int MAX_SCRAMBLE = 18;
47 47

  
48
    private static int mSize = RubikSize.DEFAULT_SIZE;
48
    private static int mButton = RubikSize.SIZE3.ordinal();
49 49
    private HorizontalNumberPicker mPicker;
50 50

  
51 51
///////////////////////////////////////////////////////////////////////////////////////////////////
52 52

  
53
    private void markButton(int size)
53
    private void markButton(int button)
54 54
      {
55
      mSize = size;
55
      mButton = button;
56 56

  
57 57
      for(int b=0; b<RubikSize.LENGTH; b++)
58 58
        {
59 59
        Drawable d = findViewById(b).getBackground();
60 60

  
61
        if( size == RubikSize.getSize(b).getCubeSize() )
61
        if( b==button )
62 62
          {
63 63
          d.setColorFilter(ContextCompat.getColor(this,R.color.red), PorterDuff.Mode.MULTIPLY);
64 64
          }
......
128 128

  
129 129
///////////////////////////////////////////////////////////////////////////////////////////////////
130 130

  
131
    static int getSize()
131
    static int getRedButton()
132 132
      {
133
      return mSize;
133
      return mButton;
134 134
      }
135 135

  
136 136
///////////////////////////////////////////////////////////////////////////////////////////////////
......
142 142
      setTheme(R.style.CustomActivityThemeNoActionBar);
143 143
      setContentView(R.layout.main);
144 144
      addSizeButtons();
145
      markButton(mSize);
145
      markButton(mButton);
146 146

  
147 147
      mPicker = findViewById(R.id.rubikNumberPicker);
148 148
      mPicker.setMin(MIN_SCRAMBLE);
......
199 199

  
200 200
        if( success )
201 201
          {
202
          markButton(size);
202
          markButton(id);
203 203
          }
204 204
        }
205 205
      }
......
219 219
    public void Scores(View v)
220 220
      {
221 221
      RubikScores scores = new RubikScores();
222
      Bundle bundle = new Bundle();
223
      bundle.putInt("button", mButton);
224
      scores.setArguments(bundle);
222 225
      scores.show(getSupportFragmentManager(), null);
223 226
      }
224 227

  
src/main/java/org/distorted/magic/RubikRenderer.java
84 84
      mEffectID = new long[BaseEffect.Type.LENGTH];
85 85

  
86 86
      mMesh= new MeshFlat(20,20);
87
      mNextCubeSize = RubikActivity.getSize();
87
      mNextCubeSize = RubikSize.getSize(RubikActivity.getRedButton()).getCubeSize();
88 88
      }
89 89

  
90 90
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/magic/RubikScores.java
72 72
    mPagerAdapter = new RubikScoresPagerAdapter(act,viewPager);
73 73
    tabLayout.setupWithViewPager(viewPager);
74 74

  
75
    viewPager.setCurrentItem(0);
75
    Bundle args = getArguments();
76
    int button = args.getInt("button");
77
    viewPager.setCurrentItem(button);
76 78

  
77 79
    for (int i = 0; i< RubikSize.LENGTH; i++)
78 80
      {
src/main/java/org/distorted/magic/RubikSize.java
29 29
  SIZE5 ( 5, R.drawable.button5 ),
30 30
  ;
31 31

  
32
  static final int DEFAULT_SIZE  = 3;
33 32
  static final int LENGTH = values().length;
34 33
  private final int mCubeSize, mIconID;
35 34
  private static final RubikSize[] sizes;

Also available in: Unified diff