Project

General

Profile

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

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

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
import org.distorted.main.RubikActivity;
22 acabdd83 Leszek Koltunski
import org.distorted.external.RubikScores;
23 fcd5b990 Leszek Koltunski
import org.distorted.screens.ScreenList;
24 bc511ea5 Leszek Koltunski
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26
27 c02fa107 Leszek Koltunski
public class RubikDialogNewRecord extends RubikDialogAbstract
28 bc511ea5 Leszek Koltunski
  {
29 f8a21f6b Leszek Koltunski
  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 c02fa107 Leszek Koltunski
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36
37 f8a21f6b Leszek Koltunski
  public void positiveAction()
38 c02fa107 Leszek Koltunski
    {
39 f8a21f6b Leszek Koltunski
    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 c02fa107 Leszek Koltunski
45 f8a21f6b Leszek Koltunski
    if( name.length()>0 )
46 bc511ea5 Leszek Koltunski
      {
47 f8a21f6b Leszek Koltunski
      bundle.putString("argument", "true");
48
      RubikDialogScores scoresDiag = new RubikDialogScores();
49
      scoresDiag.setArguments(bundle);
50
      scoresDiag.show(act.getSupportFragmentManager(), null);
51
      }
52
    else
53 bc511ea5 Leszek Koltunski
      {
54 f8a21f6b Leszek Koltunski
      bundle.putString("argument", name );
55
      RubikDialogSetName nameDiag = new RubikDialogSetName();
56
      nameDiag.setArguments(bundle);
57
      nameDiag.show(act.getSupportFragmentManager(), null);
58
      }
59 c02fa107 Leszek Koltunski
    }
60 bc511ea5 Leszek Koltunski
61 c02fa107 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
62 bc511ea5 Leszek Koltunski
63 f8a21f6b Leszek Koltunski
  public void negativeAction()
64 c02fa107 Leszek Koltunski
    {
65 f8a21f6b Leszek Koltunski
    RubikActivity act = (RubikActivity)getActivity();
66
    ScreenList.switchScreen(act, ScreenList.PLAY);
67 c02fa107 Leszek Koltunski
    }
68 bc511ea5 Leszek Koltunski
69 c02fa107 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
70 bc511ea5 Leszek Koltunski
71 c02fa107 Leszek Koltunski
  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 4483b119 Leszek Koltunski
    text.setText(mArgument);
76 fb37b424 Leszek Koltunski
    TextView submit = view.findViewById(R.id.new_record_submit);
77 c02fa107 Leszek Koltunski
    submit.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
78 bc511ea5 Leszek Koltunski
    }
79 dca3888a Leszek Koltunski
80
///////////////////////////////////////////////////////////////////////////////////////////////////
81
82
  public static String getDialogTag()
83
    {
84
    return "DialogNewRecord";
85
    }
86 bc511ea5 Leszek Koltunski
  }