Revision f8a21f6b
Added by Leszek Koltunski almost 3 years ago
| src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java | ||
|---|---|---|
| 10 | 10 |
package org.distorted.dialogs; |
| 11 | 11 |
|
| 12 | 12 |
import android.app.Dialog; |
| 13 |
import android.content.DialogInterface; |
|
| 14 | 13 |
import android.os.Bundle; |
| 15 | 14 |
import androidx.fragment.app.FragmentActivity; |
| 16 |
import androidx.appcompat.app.AlertDialog; |
|
| 17 | 15 |
|
| 18 | 16 |
import android.util.TypedValue; |
| 19 | 17 |
import android.view.View; |
| 20 |
import android.widget.Button; |
|
| 21 | 18 |
import android.widget.TextView; |
| 22 | 19 |
|
| 23 | 20 |
import org.distorted.main.R; |
| ... | ... | |
| 29 | 26 |
|
| 30 | 27 |
public class RubikDialogNewRecord extends RubikDialogAbstract |
| 31 | 28 |
{
|
| 32 |
public int getResource() |
|
| 33 |
{
|
|
| 34 |
return R.layout.dialog_new_record; |
|
| 35 |
} |
|
| 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; }
|
|
| 36 | 34 |
|
| 37 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 38 | 36 |
|
| 39 |
public int getTitleResource()
|
|
| 37 |
public void positiveAction()
|
|
| 40 | 38 |
{
|
| 41 |
return R.string.new_record; |
|
| 42 |
} |
|
| 43 |
|
|
| 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 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); |
|
| 45 | 44 |
|
| 46 |
public boolean hasArgument() |
|
| 47 |
{
|
|
| 48 |
return true; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public void setPositive(AlertDialog.Builder builder) |
|
| 54 |
{
|
|
| 55 |
builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() |
|
| 45 |
if( name.length()>0 ) |
|
| 56 | 46 |
{
|
| 57 |
@Override |
|
| 58 |
public void onClick(DialogInterface dialog, int which) |
|
| 59 |
{
|
|
| 60 |
RubikActivity act = (RubikActivity)getActivity(); |
|
| 61 |
RubikScores scores = RubikScores.getInstance(); |
|
| 62 |
String name = scores.getName(); |
|
| 63 |
Bundle bundle = new Bundle(); |
|
| 64 |
ScreenList.switchScreen(act, ScreenList.PLAY); |
|
| 65 |
|
|
| 66 |
if( name.length()>0 ) |
|
| 67 |
{
|
|
| 68 |
bundle.putString("argument", "true");
|
|
| 69 |
RubikDialogScores scoresDiag = new RubikDialogScores(); |
|
| 70 |
scoresDiag.setArguments(bundle); |
|
| 71 |
scoresDiag.show(act.getSupportFragmentManager(), null); |
|
| 72 |
} |
|
| 73 |
else |
|
| 74 |
{
|
|
| 75 |
bundle.putString("argument", name );
|
|
| 76 |
RubikDialogSetName nameDiag = new RubikDialogSetName(); |
|
| 77 |
nameDiag.setArguments(bundle); |
|
| 78 |
nameDiag.show(act.getSupportFragmentManager(), null); |
|
| 79 |
} |
|
| 80 |
} |
|
| 81 |
}); |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 85 |
|
|
| 86 |
public void setNegative(AlertDialog.Builder builder) |
|
| 87 |
{
|
|
| 88 |
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() |
|
| 47 |
bundle.putString("argument", "true");
|
|
| 48 |
RubikDialogScores scoresDiag = new RubikDialogScores(); |
|
| 49 |
scoresDiag.setArguments(bundle); |
|
| 50 |
scoresDiag.show(act.getSupportFragmentManager(), null); |
|
| 51 |
} |
|
| 52 |
else |
|
| 89 | 53 |
{
|
| 90 |
@Override |
|
| 91 |
public void onClick(DialogInterface dialog, int which) |
|
| 92 |
{
|
|
| 93 |
RubikActivity act = (RubikActivity)getActivity(); |
|
| 94 |
ScreenList.switchScreen(act, ScreenList.PLAY); |
|
| 95 |
} |
|
| 96 |
}); |
|
| 54 |
bundle.putString("argument", name );
|
|
| 55 |
RubikDialogSetName nameDiag = new RubikDialogSetName(); |
|
| 56 |
nameDiag.setArguments(bundle); |
|
| 57 |
nameDiag.show(act.getSupportFragmentManager(), null); |
|
| 58 |
} |
|
| 97 | 59 |
} |
| 98 | 60 |
|
| 99 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 100 | 62 |
|
| 101 |
public void onShowDialog(DialogInterface dialog, float size)
|
|
| 63 |
public void negativeAction()
|
|
| 102 | 64 |
{
|
| 103 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 104 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 105 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 106 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); |
|
| 65 |
RubikActivity act = (RubikActivity)getActivity(); |
|
| 66 |
ScreenList.switchScreen(act, ScreenList.PLAY); |
|
| 107 | 67 |
} |
| 108 | 68 |
|
| 109 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Unify all dialogs.