Project

General

Profile

« Previous | Next » 

Revision f8a21f6b

Added by Leszek Koltunski over 1 year ago

Unify all dialogs.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogBandagedDelete.java
10 10
package org.distorted.dialogs;
11 11

  
12 12
import android.app.Dialog;
13
import android.content.DialogInterface;
14 13
import android.util.TypedValue;
15 14
import android.view.View;
16
import android.widget.Button;
17 15
import android.widget.TextView;
18 16

  
19
import androidx.appcompat.app.AlertDialog;
20 17
import androidx.fragment.app.FragmentActivity;
21 18

  
22 19
import org.distorted.bandaged.BandagedCreatorActivity;
......
26 23

  
27 24
public class RubikDialogBandagedDelete extends RubikDialogAbstract
28 25
  {
29
  public int getResource()
30
    {
31
    return R.layout.dialog_delete_object;
32
    }
33

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

  
36
  public int getTitleResource()
37
    {
38
    return R.string.delete_object;
39
    }
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public boolean hasArgument()
44
    {
45
    return true;
46
    }
26
  public int getResource()      { return R.layout.dialog_delete_object; }
27
  public int getTitleResource() { return R.string.delete_object; }
28
  public boolean hasArgument()  { return true; }
29
  public int getPositive()      { return R.string.yes; }
30
  public int getNegative()      { return R.string.no; }
47 31

  
48 32
///////////////////////////////////////////////////////////////////////////////////////////////////
49 33

  
50
  public void setPositive(AlertDialog.Builder builder)
34
  public void positiveAction()
51 35
    {
52
    final String objectName = mArgument;
53

  
54
    builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener()
55
      {
56
      @Override
57
      public void onClick(DialogInterface dialog, int which)
58
        {
59
        BandagedCreatorActivity bact = (BandagedCreatorActivity)getContext();
60
        if( bact!=null ) bact.deleteObject(objectName);
61
        }
62
      });
36
    BandagedCreatorActivity bact = (BandagedCreatorActivity)getContext();
37
    if( bact!=null ) bact.deleteObject(mArgument);
63 38
    }
64 39

  
65 40
///////////////////////////////////////////////////////////////////////////////////////////////////
66 41

  
67
  public void setNegative(AlertDialog.Builder builder)
42
  public void negativeAction()
68 43
    {
69
    builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener()
70
      {
71
      @Override
72
      public void onClick(DialogInterface dialog, int which)
73
        {
74 44

  
75
        }
76
      });
77
    }
78

  
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

  
81
  public void onShowDialog(DialogInterface dialog, float size)
82
    {
83
    Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
84
    btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
85
    Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE);
86
    btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
87 45
    }
88 46

  
89 47
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff