Project

General

Profile

« Previous | Next » 

Revision 90fd47b0

Added by Leszek Koltunski about 4 years ago

Lots of bugfixes.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogSetName.java
47 47

  
48 48
public class RubikDialogSetName extends AppCompatDialogFragment
49 49
  {
50
  private EditText mEdit;
51

  
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

  
50 54
  @Override
51 55
  public void onStart()
52 56
    {
......
56 60

  
57 61
    if (dialog != null)
58 62
      {
59
      Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE);
60
      positiveButton.setEnabled(false);
61 63
      dialog.setCanceledOnTouchOutside(false);
62 64

  
63 65
      Window window = dialog.getWindow();
64 66

  
65 67
      if( window!=null )
66 68
        {
67
        window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
68
                        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
69 69
        window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
70 70
        }
71 71
      }
72

  
73
    Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE);
74

  
75
    if( positiveButton!=null )
76
      {
77
      String editName = mEdit.getText().toString();
78
      positiveButton.setEnabled(editName.length()>0);
79
      }
72 80
    }
73 81

  
74 82
///////////////////////////////////////////////////////////////////////////////////////////////////
......
101 109

  
102 110
    final View view = inflater.inflate(R.layout.dialog_set_name, null);
103 111
    TextView text = view.findViewById(R.id.set_name_message);
112
    mEdit = view.findViewById(R.id.set_name);
104 113

  
105 114
    if( first )
106 115
      {
......
118 127
      @Override
119 128
      public void onClick(DialogInterface dialog, int which)
120 129
        {
121
        RubikActivity act = (RubikActivity)getActivity();
122
        RubikState.switchState(act,RubikState.PLAY);
123

  
124
        EditText edit = view.findViewById(R.id.set_name);
125
        String name = edit.getText().toString();
126
        RubikScores.getInstance().setName(name);
127

  
128
        RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass();
129
        int object = play.getObject();
130
        int size   = play.getSize();
131
        int sizeIndex = RubikObjectList.getSizeIndex(object,size);
132

  
133
        Bundle bundle = new Bundle();
134
        bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
135
        bundle.putBoolean("submitting", true);
136

  
137
        RubikDialogScores scores = new RubikDialogScores();
138
        scores.setArguments(bundle);
139
        scores.show(act.getSupportFragmentManager(), null);
130
        String name = mEdit.getText().toString();
131

  
132
        if( name.length()>0 )
133
          {
134
          RubikActivity act = (RubikActivity)getActivity();
135
          RubikState.switchState(act,RubikState.PLAY);
136
          RubikScores.getInstance().setName(name);
137
          RubikStatePlay play = (RubikStatePlay) RubikState.PLAY.getStateClass();
138

  
139
          int object = play.getObject();
140
          int size   = play.getSize();
141
          int sizeIndex = RubikObjectList.getSizeIndex(object,size);
142

  
143
          Bundle bundle = new Bundle();
144
          bundle.putInt("tab", RubikObjectList.pack(object,sizeIndex) );
145
          bundle.putBoolean("submitting", true);
146

  
147
          RubikDialogScores scores = new RubikDialogScores();
148
          scores.setArguments(bundle);
149
          scores.show(act.getSupportFragmentManager(), null);
150
          }
140 151
        }
141 152
      });
142 153

  
......
144 155
    final Dialog dialog = builder.create();
145 156
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
146 157

  
147
    EditText edit = view.findViewById(R.id.set_name);
148
    edit.requestFocus();
158
    mEdit.requestFocus();
149 159

  
150
    edit.addTextChangedListener(new TextWatcher()
160
    mEdit.addTextChangedListener(new TextWatcher()
151 161
      {
152 162
      @Override
153 163
      public void afterTextChanged(Editable s) {}

Also available in: Unified diff