Skip to content

Commit 732f0a6

Browse files
Merge branch 'fernando'
2 parents 6c38800 + f15e006 commit 732f0a6

File tree

7 files changed

+51
-11
lines changed

7 files changed

+51
-11
lines changed

MaterialDialogLibrary/src/main/java/com/shreyaspatil/MaterialDialog/AbstractDialog.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class AbstractDialog implements DialogInterface {
4444
protected String mAnimationFile;
4545
protected LottieAnimationView mAnimationView;
4646
protected Boolean showInLandscape;
47+
protected Integer height;
4748

4849
protected OnDismissListener mOnDismissListener;
4950
protected OnCancelListener mOnCancelListener;
@@ -59,7 +60,9 @@ protected AbstractDialog(@NonNull Activity mActivity,
5960
@NonNull DialogButton mNegativeButton,
6061
@RawRes int mAnimationResId,
6162
@NonNull String mAnimationFile,
62-
@NonNull Boolean showInLandscape) {
63+
@NonNull Boolean showInLandscape,
64+
@NonNull Integer height
65+
) {
6366
this.mActivity = mActivity;
6467
this.title = title;
6568
this.message = message;
@@ -69,6 +72,7 @@ protected AbstractDialog(@NonNull Activity mActivity,
6972
this.mAnimationResId = mAnimationResId;
7073
this.mAnimationFile = mAnimationFile;
7174
this.showInLandscape = showInLandscape;
75+
this.height = height;
7276
}
7377

7478
protected View createView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) {
@@ -154,6 +158,13 @@ public void onClick(View view) {
154158
}
155159
}
156160

161+
if (mAnimationView.getVisibility() == View.VISIBLE && height != -1) {
162+
ViewGroup.LayoutParams params = mAnimationView.getLayoutParams();
163+
params.height = this.height;
164+
mAnimationView.setLayoutParams(params);
165+
mAnimationView.requestLayout();
166+
}
167+
157168
// Apply Styles
158169
TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.MaterialDialog);
159170

MaterialDialogLibrary/src/main/java/com/shreyaspatil/MaterialDialog/BottomSheetMaterialDialog.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ protected BottomSheetMaterialDialog(@NonNull final Activity mActivity,
3333
@NonNull DialogButton mNegativeButton,
3434
@RawRes int mAnimationResId,
3535
@NonNull String mAnimationFile,
36-
@NonNull Boolean mShowInLandscape) {
37-
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape);
36+
@NonNull Boolean mShowInLandscape,
37+
@NonNull Integer mHeight
38+
) {
39+
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape, mHeight);
3840

3941
// Init Dialog, Create Bottom Sheet Dialog
4042
mDialog = new BottomSheetDialog(mActivity);
@@ -94,6 +96,7 @@ public static class Builder {
9496
private int animationResId = NO_ANIMATION;
9597
private String animationFile;
9698
private Boolean showInLandscape = false;
99+
private Integer height = -1;
97100

98101
/**
99102
* @param activity where BottomSheet Material Dialog is to be built.
@@ -219,12 +222,23 @@ public Builder setShowInLandscape(@NonNull Boolean showInLandscape) {
219222
return this;
220223
}
221224

225+
/** It sets the showInLandscape property to allow or not the animation to be shown in landscape orientation
226+
*
227+
* @param height sets the height of the animation wrapper
228+
* @return this, for chaining.
229+
*/
230+
@NonNull
231+
public Builder setAnimationHeight(@NonNull Integer height) {
232+
this.height = height;
233+
return this;
234+
}
235+
222236
/**
223237
* Build the {@link BottomSheetMaterialDialog}.
224238
*/
225239
@NonNull
226240
public BottomSheetMaterialDialog build() {
227-
return new BottomSheetMaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape);
241+
return new BottomSheetMaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape, height);
228242
}
229243
}
230244

MaterialDialogLibrary/src/main/java/com/shreyaspatil/MaterialDialog/MaterialDialog.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ protected MaterialDialog(@NonNull final Activity mActivity,
2626
@NonNull DialogButton mNegativeButton,
2727
@RawRes int mAnimationResId,
2828
@NonNull String mAnimationFile,
29-
@NonNull Boolean mShowInLandscape) {
30-
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape);
29+
@NonNull Boolean mShowInLandscape,
30+
@NonNull Integer mHeight
31+
) {
32+
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape, mHeight);
3133

3234
// Init Dialog
3335
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
@@ -58,6 +60,7 @@ public static class Builder {
5860
private int animationResId = NO_ANIMATION;
5961
private String animationFile;
6062
private Boolean showInLandscape = false;
63+
private Integer height = -1;
6164

6265
/**
6366
* @param activity where Material Dialog is to be built.
@@ -171,12 +174,23 @@ public Builder setShowInLandscape(@NonNull Boolean showInLandscape) {
171174
return this;
172175
}
173176

177+
/** It sets the showInLandscape property to allow or not the animation to be shown in landscape orientation
178+
*
179+
* @param height sets the height of the animation wrapper
180+
* @return this, for chaining.
181+
*/
182+
@NonNull
183+
public Builder setAnimationHeight(@NonNull Integer height) {
184+
this.height = height;
185+
return this;
186+
}
187+
174188
/**
175189
* Build the {@link MaterialDialog}.
176190
*/
177191
@NonNull
178192
public MaterialDialog build() {
179-
return new MaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape);
193+
return new MaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape, height);
180194
}
181195
}
182196
}

MaterialDialogLibrary/src/main/res/layout-land/layout_alert_dialog.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
android:layout_width="match_parent"
2222
android:layout_height="175dp"
2323
android:layout_alignParentTop="true"
24-
android:scaleType="centerCrop"
24+
android:scaleType="fitCenter"
2525
android:visibility="visible"
2626
app:lottie_autoPlay="true"
2727
app:lottie_loop="true" />

MaterialDialogLibrary/src/main/res/layout/layout_alert_dialog.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
app:lottie_loop="true"
2525
android:visibility="visible"
2626
android:layout_alignParentTop="true"
27-
android:scaleType="centerCrop"
27+
android:scaleType="fitCenter"
2828
app:lottie_autoPlay="true"/>
2929

3030
<TextView

app/src/main/java/com/shreyaspatil/MaterialDialogExample/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void onClick(DialogInterface dialogInterface, int which) {
9292
dialogInterface.dismiss();
9393
}
9494
})*/
95-
.setAnimation("delete_anim.json")
95+
.setAnimation(R.raw.connection_error)
9696
.setShowInLandscape(true)
9797
.build();
9898

@@ -115,7 +115,7 @@ public void onClick(DialogInterface dialogInterface, int which) {
115115
dialogInterface.dismiss();
116116
}
117117
})*/
118-
.setAnimation("delete_anim.json")
118+
.setAnimation(R.raw.connection_error)
119119
.setShowInLandscape(true)
120120
.build();
121121

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"v":"5.1.5","fr":29.9700012207031,"ip":0,"op":42.0000017106951,"w":32,"h":32,"nm":"System-states-Sin conexión","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":3,"ty":4,"nm":"! contornos","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[16,16,0],"ix":2},"a":{"a":0,"k":[8.25,8.25,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.847,0.847,0.667],"y":[1,1,1]},"o":{"x":[1,1,0.333],"y":[0,0,0]},"n":["0p847_1_1_0","0p847_1_1_0","0p667_1_0p333_0"],"t":0,"s":[100,100,100],"e":[130,130,100]},{"i":{"x":[0,0,0.667],"y":[1,1,1]},"o":{"x":[0.127,0.127,0.333],"y":[0,0,0]},"n":["0_1_0p127_0","0_1_0p127_0","0p667_1_0p333_0"],"t":21,"s":[130,130,100],"e":[100,100,100]},{"t":42.0000017106951}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.442,0],[0,-0.443],[-0.442,0],[0,0.441]],"o":[[-0.442,0],[0,0.441],[0.442,0],[0,-0.443]],"v":[[0,-0.8],[-0.8,0],[0,0.8],[0.8,0]],"c":true},"ix":2},"nm":"Trazado 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Relleno 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[8.25,12.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transformar"}],"nm":"Grupo 1","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.221,0],[0,0.221],[0,0],[0.221,0],[0,-0.221],[0,0]],"o":[[0.221,0],[0,0],[0,-0.221],[-0.221,0],[0,0],[0,0.221]],"v":[[0,2.544],[0.4,2.144],[0.4,-2.144],[0,-2.544],[-0.4,-2.144],[-0.4,2.144]],"c":true},"ix":2},"nm":"Trazado 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Relleno 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[8.25,7.194],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transformar"}],"nm":"Grupo 2","np":2,"cix":2,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-4.416],[-4.416,0],[0,4.416],[4.416,0]],"o":[[0,4.416],[4.416,0],[0,-4.416],[-4.416,0]],"v":[[-8,0],[0,8],[8,0],[0,-8]],"c":true},"ix":2},"nm":"Trazado 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.987999949736,0.172999991623,0.340999977261,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Relleno 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[8.25,8.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transformar"}],"nm":"Grupo 3","np":2,"cix":2,"ix":3,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":3597.00014650881,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Sombra contornos","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":8.4,"s":[100],"e":[0]},{"t":23.8000009693939}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[16,16,0],"ix":2},"a":{"a":0,"k":[8.25,8.25,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.847,0.847,0.667],"y":[1,1,1]},"o":{"x":[1,1,0.333],"y":[0,0,0]},"n":["0p847_1_1_0","0p847_1_1_0","0p667_1_0p333_0"],"t":0,"s":[100,100,100],"e":[180,180,100]},{"i":{"x":[0,0,0.667],"y":[1,1,1]},"o":{"x":[0.127,0.127,0.333],"y":[0,0,0]},"n":["0_1_0p127_0","0_1_0p127_0","0p667_1_0p333_0"],"t":21,"s":[180,180,100],"e":[100,100,100]},{"t":42.0000017106951}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-4.416],[-4.416,0],[0,4.416],[4.416,0]],"o":[[0,4.416],[4.416,0],[0,-4.416],[-4.416,0]],"v":[[-8,0],[0,8],[8,0],[0,-8]],"c":true},"ix":2},"nm":"Trazado 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.987999949736,0.172999991623,0.340999977261,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Relleno 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[8.25,8.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transformar"}],"nm":"Grupo 3","np":2,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":3597.00014650881,"st":0,"bm":0}],"markers":[]}

0 commit comments

Comments
 (0)