10
10
import android .view .animation .AlphaAnimation ;
11
11
import android .view .animation .Animation ;
12
12
import android .view .animation .AnimationSet ;
13
+ import android .view .animation .Transformation ;
13
14
import android .widget .Button ;
14
15
import android .widget .FrameLayout ;
15
16
import android .widget .ImageView ;
20
21
21
22
public class SweetAlertDialog extends Dialog implements View .OnClickListener {
22
23
private View mDialogView ;
23
- private AnimationSet mScaleInAnim ;
24
- private AnimationSet mScaleOutAnim ;
24
+ private AnimationSet mModalInAnim ;
25
+ private AnimationSet mModalOutAnim ;
26
+ private Animation mOverlayOutAnim ;
25
27
private Animation mErrorInAnim ;
26
28
private AnimationSet mErrorXInAnim ;
27
29
private AnimationSet mSuccessLayoutAnimSet ;
@@ -85,9 +87,9 @@ public SweetAlertDialog(Context context, int alertType) {
85
87
}
86
88
mSuccessBowAnim = OptAnimationLoader .loadAnimation (getContext (), R .anim .success_bow_roate );
87
89
mSuccessLayoutAnimSet = (AnimationSet )OptAnimationLoader .loadAnimation (getContext (), R .anim .success_mask_layout );
88
- mScaleInAnim = (AnimationSet ) OptAnimationLoader .loadAnimation (getContext (), R .anim .dialog_scale_in );
89
- mScaleOutAnim = (AnimationSet ) OptAnimationLoader .loadAnimation (getContext (), R .anim .dialog_scale_out );
90
- mScaleOutAnim .setAnimationListener (new Animation .AnimationListener () {
90
+ mModalInAnim = (AnimationSet ) OptAnimationLoader .loadAnimation (getContext (), R .anim .modal_in );
91
+ mModalOutAnim = (AnimationSet ) OptAnimationLoader .loadAnimation (getContext (), R .anim .modal_out );
92
+ mModalOutAnim .setAnimationListener (new Animation .AnimationListener () {
91
93
@ Override
92
94
public void onAnimationStart (Animation animation ) {
93
95
@@ -109,6 +111,14 @@ public void onAnimationRepeat(Animation animation) {
109
111
110
112
}
111
113
});
114
+ // dialog overlay fade out
115
+ mOverlayOutAnim = new Animation () {
116
+ @ Override
117
+ protected void applyTransformation (float interpolatedTime , Transformation t ) {
118
+ getWindow ().getDecorView ().getBackground ().setAlpha ((int )((1 - interpolatedTime ) * 255 ));
119
+ }
120
+ };
121
+ mOverlayOutAnim .setDuration (150 );
112
122
}
113
123
114
124
protected void onCreate (Bundle savedInstanceState ) {
@@ -289,12 +299,13 @@ public SweetAlertDialog setConfirmClickListener (OnSweetClickListener listener)
289
299
}
290
300
291
301
protected void onStart () {
292
- mDialogView .startAnimation (mScaleInAnim );
302
+ mDialogView .startAnimation (mModalInAnim );
293
303
playAnimation ();
294
304
}
295
305
296
306
public void dismiss () {
297
- mDialogView .startAnimation (mScaleOutAnim );
307
+ mConfirmButton .startAnimation (mOverlayOutAnim );
308
+ mDialogView .startAnimation (mModalOutAnim );
298
309
}
299
310
300
311
@ Override
0 commit comments