Project

General

Profile

« Previous | Next » 

Revision c02fa107

Added by Leszek Koltunski over 1 year ago

Continue unifying all the dialogs under one RubikDialogAbstract.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogAbstract.java
32 32
abstract public class RubikDialogAbstract extends AppCompatDialogFragment
33 33
  {
34 34
  protected float mTitleSize, mButSize, mTextSize;
35
  protected int mWidth, mHeight;
36
  protected String mArgument;
35 37

  
36 38
///////////////////////////////////////////////////////////////////////////////////////////////////
37 39

  
38 40
  abstract int getResource();
39 41
  abstract int getTitleResource();
42
  abstract boolean hasArgument();
40 43
  abstract void setPositive(AlertDialog.Builder builder);
41 44
  abstract void setNegative(AlertDialog.Builder builder);
42 45
  abstract void onShowDialog(DialogInterface dialog, float size);
43
  abstract void prepareBody(View view, FragmentActivity act, float size);
46
  abstract void prepareBody(Dialog dialog, View view, FragmentActivity act, float size);
44 47

  
45 48
///////////////////////////////////////////////////////////////////////////////////////////////////
46 49

  
......
54 57

  
55 58
    DisplayMetrics displaymetrics = new DisplayMetrics();
56 59
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
57
    int h = displaymetrics.heightPixels;
58
    mTitleSize= h * 0.032f;
59
    mButSize  = h * 0.040f;
60
    mTextSize = h * 0.025f;
60
    mWidth    = displaymetrics.widthPixels;
61
    mHeight   = displaymetrics.heightPixels;
62
    mTitleSize= mHeight*0.032f;
63
    mButSize  = mHeight*0.040f;
64
    mTextSize = mHeight*0.025f;
65

  
66
    if( hasArgument() )
67
      {
68
      Bundle args = getArguments();
69

  
70
      try
71
        {
72
        mArgument = args!=null ? args.getString("argument") : "";
73
        }
74
      catch(Exception e)
75
        {
76
        mArgument = "";
77
        }
78
      }
79
    else mArgument = "";
61 80

  
62 81
    final View view = inflater.inflate(getResource(), null);
63 82
    builder.setView(view);
......
74 93

  
75 94
    setPositive(builder);
76 95
    setNegative(builder);
77
    prepareBody(view,act,mTextSize);
78 96

  
79 97
    Dialog dialog = builder.create();
80 98
    dialog.setCanceledOnTouchOutside(false);
99

  
100
    prepareBody(dialog,view,act,mTextSize);
101

  
81 102
    Window window = dialog.getWindow();
82 103

  
83 104
    if( window!=null )

Also available in: Unified diff