Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// 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
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.dialogs;
11

    
12
import android.app.Dialog;
13
import android.os.Bundle;
14
import androidx.fragment.app.FragmentActivity;
15

    
16
import android.util.TypedValue;
17
import android.view.View;
18
import android.widget.TextView;
19

    
20
import org.distorted.main.R;
21
import org.distorted.external.RubikScores;
22
import org.distorted.playui.PlayActivity;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
public class RubikDialogNewRecord extends RubikDialogAbstract
27
  {
28
  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

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
  public void positiveAction()
37
    {
38
    RubikScores scores = RubikScores.getInstance();
39
    String name = scores.getName();
40
    Bundle bundle = new Bundle();
41
    PlayActivity act = (PlayActivity)getActivity();
42

    
43
    if( act!=null )
44
      {
45
      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

    
60
      act.finish();
61
      }
62
    }
63

    
64
///////////////////////////////////////////////////////////////////////////////////////////////////
65

    
66
  public void negativeAction()
67
    {
68
    PlayActivity act = (PlayActivity)getActivity();
69
    if( act!=null ) act.finish();
70
    }
71

    
72
///////////////////////////////////////////////////////////////////////////////////////////////////
73

    
74
  public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
75
    {
76
    TextView text = view.findViewById(R.id.new_record_time);
77
    text.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
78
    text.setText(mArgument);
79
    TextView submit = view.findViewById(R.id.new_record_submit);
80
    submit.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
81
    }
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

    
85
  public static String getDialogTag()
86
    {
87
    return "DialogNewRecord";
88
    }
89
  }
(10-10/33)