Revision f8a21f6b
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/dialogs/RubikDialogAbstract.java | ||
---|---|---|
17 | 17 |
import android.view.LayoutInflater; |
18 | 18 |
import android.view.View; |
19 | 19 |
import android.view.Window; |
20 |
import android.widget.Button; |
|
20 | 21 |
import android.widget.TextView; |
21 | 22 |
|
22 | 23 |
import androidx.annotation.NonNull; |
... | ... | |
39 | 40 |
|
40 | 41 |
abstract int getResource(); |
41 | 42 |
abstract int getTitleResource(); |
43 |
abstract int getPositive(); |
|
44 |
abstract int getNegative(); |
|
42 | 45 |
abstract boolean hasArgument(); |
43 |
abstract void setPositive(AlertDialog.Builder builder); |
|
44 |
abstract void setNegative(AlertDialog.Builder builder); |
|
45 |
abstract void onShowDialog(DialogInterface dialog, float size); |
|
46 |
abstract void positiveAction(); |
|
47 |
abstract void negativeAction(); |
|
46 | 48 |
abstract void prepareBody(Dialog dialog, View view, FragmentActivity act, float size); |
47 | 49 |
|
48 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
91 | 93 |
builder.setCustomTitle(tv); |
92 | 94 |
} |
93 | 95 |
|
94 |
setPositive(builder); |
|
95 |
setNegative(builder); |
|
96 |
int positive = getPositive(); |
|
97 |
if( positive>=0 ) |
|
98 |
{ |
|
99 |
builder.setPositiveButton( positive, new DialogInterface.OnClickListener() |
|
100 |
{ |
|
101 |
@Override |
|
102 |
public void onClick(DialogInterface dialog, int which) |
|
103 |
{ |
|
104 |
positiveAction(); |
|
105 |
} |
|
106 |
}); |
|
107 |
} |
|
108 |
|
|
109 |
int negative = getNegative(); |
|
110 |
if( negative>=0 ) |
|
111 |
{ |
|
112 |
builder.setNegativeButton( positive, new DialogInterface.OnClickListener() |
|
113 |
{ |
|
114 |
@Override |
|
115 |
public void onClick(DialogInterface dialog, int which) |
|
116 |
{ |
|
117 |
negativeAction(); |
|
118 |
} |
|
119 |
}); |
|
120 |
} |
|
96 | 121 |
|
97 | 122 |
Dialog dialog = builder.create(); |
98 | 123 |
dialog.setCanceledOnTouchOutside(false); |
... | ... | |
111 | 136 |
@Override |
112 | 137 |
public void onShow(DialogInterface dialog) |
113 | 138 |
{ |
114 |
onShowDialog(dialog,mButSize); |
|
139 |
if( positive>=0 ) |
|
140 |
{ |
|
141 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
142 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButSize); |
|
143 |
} |
|
144 |
if( negative>=0 ) |
|
145 |
{ |
|
146 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
147 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, mButSize); |
|
148 |
} |
|
115 | 149 |
} |
116 | 150 |
}); |
117 | 151 |
|
Also available in: Unified diff
Unify all dialogs.