Project

General

Profile

« Previous | Next » 

Revision 0c96b376

Added by Leszek Koltunski almost 5 years ago

RubikCube: further fixes for RubikSettings

View differences:

src/main/java/org/distorted/magic/RubikSettings.java
25 25
import android.support.v4.app.FragmentActivity;
26 26
import android.support.v7.app.AlertDialog;
27 27
import android.support.v7.app.AppCompatDialogFragment;
28
import android.util.DisplayMetrics;
28 29
import android.view.Gravity;
29 30
import android.view.LayoutInflater;
30 31
import android.view.View;
......
48 49
  private void createSettingsSection(FragmentActivity act, LinearLayout layout, int index)
49 50
    {
50 51
    BaseEffect.Type beType = BaseEffect.Type.getType(index);
51
    float scale = act.getResources().getDisplayMetrics().density;
52
    DisplayMetrics metrics = act.getResources().getDisplayMetrics();
53
    float scale = metrics.density;
54

  
55
    int textH;
56
    int layoH;
57

  
58
    if( metrics.widthPixels > metrics.heightPixels )
59
      {
60
      textH = 20;
61
      layoH = 26;
62
      }
63
    else
64
      {
65
      textH = 32;
66
      layoH = 36;
67
      }
52 68

  
53 69
    ///// OUTER LAYOUT ///////////////////////////////////////////////////////////////////
54 70

  
......
69 85

  
70 86
    ///// TEXT ///////////////////////////////////////////////////////////////////////////
71 87

  
72
    int layoutHeight = (int)(scale*32 + 0.5f);
73
    int padding      = (int)(scale*10 + 0.5f);
88
    int layoutHeight = (int)(scale*textH + 0.5f);
89
    int padding      = (int)(scale*10    + 0.5f);
74 90

  
75 91
    LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,layoutHeight);
76 92

  
......
84 100

  
85 101
    ///// INNER LAYOUT1 //////////////////////////////////////////////////////////////////
86 102

  
87
    int innerLayout1Height = (int)(scale*36 + 0.5f);
103
    int innerLayout1Height = (int)(scale*layoH + 0.5f);
88 104
    LinearLayout innerLayout1 = new LinearLayout(act);
89 105
    LinearLayout.LayoutParams innerLayout1Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,innerLayout1Height);
90 106

  
......
130 146

  
131 147
    ///// INNER LAYOUT2 //////////////////////////////////////////////////////////////////
132 148

  
133
    int innerLayout2Height = (int)(scale*36 + 0.5f);
149
    int innerLayout2Height = (int)(scale*layoH + 0.5f);
134 150
    LinearLayout innerLayout2 = new LinearLayout(act);
135 151
    LinearLayout.LayoutParams innerLayout2Params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,innerLayout2Height);
136 152

  
......
159 175
    spinner.setLayoutParams(spinnerLayoutParams);
160 176
    spinner.setPadding(spinnerPadding,0,spinnerPadding,0);
161 177
    spinner.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
162
    spinner.setId(index);
178
    spinner.setId(index+BaseEffect.Type.LENGTH);
163 179
    innerLayout2.addView(spinner);
164 180

  
165 181
    spinner.setOnItemSelectedListener(this);
......
216 232
  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
217 233
    {
218 234
    int parentID = parent.getId();
235
    int len = BaseEffect.Type.LENGTH;
219 236

  
220
    if( parentID>=0 && parentID< BaseEffect.Type.LENGTH) // ith spinner's ID is equal to i (see createSettingSection)
237
    if( parentID>=len && parentID< 2*len) // ith spinner's ID is equal to i+LENGTH (see createSettingSection)
221 238
      {
222
      BaseEffect.Type.getType(parentID).setCurrentType(pos);
239
      BaseEffect.Type.getType(parentID-len).setCurrentType(pos);
223 240
      }
224 241
    }
225 242

  

Also available in: Unified diff