Project

General

Profile

Download (3.27 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / dialogs / RubikDialogNewRecord.java @ master

1 bc511ea5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6 68191e7d Leszek Koltunski
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8 bc511ea5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10 1f9772f3 Leszek Koltunski
package org.distorted.dialogs;
11 bc511ea5 Leszek Koltunski
12
import android.app.Dialog;
13
import android.os.Bundle;
14 66e777b0 Leszek Koltunski
import androidx.fragment.app.FragmentActivity;
15 fb37b424 Leszek Koltunski
16
import android.util.TypedValue;
17 bc511ea5 Leszek Koltunski
import android.view.View;
18
import android.widget.TextView;
19
20 1f9772f3 Leszek Koltunski
import org.distorted.main.R;
21 acabdd83 Leszek Koltunski
import org.distorted.external.RubikScores;
22 e9397ae9 leszek
import org.distorted.playui.PlayActivity;
23 bc511ea5 Leszek Koltunski
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
26 c02fa107 Leszek Koltunski
public class RubikDialogNewRecord extends RubikDialogAbstract
27 bc511ea5 Leszek Koltunski
  {
28 f8a21f6b Leszek Koltunski
  public int getResource()      { return R.layout.dialog_new_record; }
29
  public int getTitleResource() { return R.string.new_record; }
30
  public boolean hasArgument()  { return true; }
31
  public int getPositive()      { return R.string.yes; }
32
  public int getNegative()      { return R.string.no; }
33 c02fa107 Leszek Koltunski
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35
36 f8a21f6b Leszek Koltunski
  public void positiveAction()
37 c02fa107 Leszek Koltunski
    {
38 f8a21f6b Leszek Koltunski
    RubikScores scores = RubikScores.getInstance();
39
    String name = scores.getName();
40
    Bundle bundle = new Bundle();
41 e9397ae9 leszek
    PlayActivity act = (PlayActivity)getActivity();
42 c02fa107 Leszek Koltunski
43 e9397ae9 leszek
    if( act!=null )
44 bc511ea5 Leszek Koltunski
      {
45 e9397ae9 leszek
      if(name.length()>0)
46
        {
47
        bundle.putString("argument", "true");
48
        RubikDialogScores scoresDiag = new RubikDialogScores();
49
        scoresDiag.setArguments(bundle);
50
        scoresDiag.show(act.getSupportFragmentManager(), null);
51
        }
52
      else
53
        {
54
        bundle.putString("argument", name);
55
        RubikDialogSetName nameDiag = new RubikDialogSetName();
56
        nameDiag.setArguments(bundle);
57
        nameDiag.show(act.getSupportFragmentManager(), null);
58
        }
59 f8a21f6b Leszek Koltunski
      }
60 c02fa107 Leszek Koltunski
    }
61 bc511ea5 Leszek Koltunski
62 c02fa107 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
63 bc511ea5 Leszek Koltunski
64 f8a21f6b Leszek Koltunski
  public void negativeAction()
65 c02fa107 Leszek Koltunski
    {
66 e9397ae9 leszek
    PlayActivity act = (PlayActivity)getActivity();
67
    if( act!=null ) act.finish();
68 c02fa107 Leszek Koltunski
    }
69 bc511ea5 Leszek Koltunski
70 c02fa107 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
71 bc511ea5 Leszek Koltunski
72 c02fa107 Leszek Koltunski
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
73
    {
74
    TextView text = view.findViewById(R.id.new_record_time);
75
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
76 4483b119 Leszek Koltunski
    text.setText(mArgument);
77 fb37b424 Leszek Koltunski
    TextView submit = view.findViewById(R.id.new_record_submit);
78 c02fa107 Leszek Koltunski
    submit.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
79 bc511ea5 Leszek Koltunski
    }
80 dca3888a Leszek Koltunski
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82
83
  public static String getDialogTag()
84
    {
85
    return "DialogNewRecord";
86
    }
87 bc511ea5 Leszek Koltunski
  }