Project

General

Profile

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

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

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
    }
61

    
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

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

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

    
72
  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
    text.setText(mArgument);
77
    TextView submit = view.findViewById(R.id.new_record_submit);
78
    submit.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
79
    }
80

    
81
///////////////////////////////////////////////////////////////////////////////////////////////////
82

    
83
  public static String getDialogTag()
84
    {
85
    return "DialogNewRecord";
86
    }
87
  }
(11-11/25)