Project

General

Profile

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

magiccube / src / main / java / org / distorted / dialogs / RubikDialogNewRecord.java @ 4483b119

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.main.RubikActivity;
22
import org.distorted.external.RubikScores;
23
import org.distorted.screens.ScreenList;
24

    
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26

    
27
public class RubikDialogNewRecord extends RubikDialogAbstract
28
  {
29
  public int getResource()      { return R.layout.dialog_new_record; }
30
  public int getTitleResource() { return R.string.new_record; }
31
  public boolean hasArgument()  { return true; }
32
  public int getPositive()      { return R.string.yes; }
33
  public int getNegative()      { return R.string.no; }
34

    
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36

    
37
  public void positiveAction()
38
    {
39
    RubikActivity act = (RubikActivity)getActivity();
40
    RubikScores scores = RubikScores.getInstance();
41
    String name = scores.getName();
42
    Bundle bundle = new Bundle();
43
    ScreenList.switchScreen(act, ScreenList.PLAY);
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
  public void negativeAction()
64
    {
65
    RubikActivity act = (RubikActivity)getActivity();
66
    ScreenList.switchScreen(act, ScreenList.PLAY);
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

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

    
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81

    
82
  public static String getDialogTag()
83
    {
84
    return "DialogNewRecord";
85
    }
86
  }
(7-7/26)