Skip to content

Commit

Permalink
Merge branch 'fernando'
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoCCNunes committed Oct 27, 2020
2 parents 6c38800 + f15e006 commit 732f0a6
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class AbstractDialog implements DialogInterface {
protected String mAnimationFile;
protected LottieAnimationView mAnimationView;
protected Boolean showInLandscape;
protected Integer height;

protected OnDismissListener mOnDismissListener;
protected OnCancelListener mOnCancelListener;
Expand All @@ -59,7 +60,9 @@ protected AbstractDialog(@NonNull Activity mActivity,
@NonNull DialogButton mNegativeButton,
@RawRes int mAnimationResId,
@NonNull String mAnimationFile,
@NonNull Boolean showInLandscape) {
@NonNull Boolean showInLandscape,
@NonNull Integer height
) {
this.mActivity = mActivity;
this.title = title;
this.message = message;
Expand All @@ -69,6 +72,7 @@ protected AbstractDialog(@NonNull Activity mActivity,
this.mAnimationResId = mAnimationResId;
this.mAnimationFile = mAnimationFile;
this.showInLandscape = showInLandscape;
this.height = height;
}

protected View createView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container) {
Expand Down Expand Up @@ -154,6 +158,13 @@ public void onClick(View view) {
}
}

if (mAnimationView.getVisibility() == View.VISIBLE && height != -1) {
ViewGroup.LayoutParams params = mAnimationView.getLayoutParams();
params.height = this.height;
mAnimationView.setLayoutParams(params);
mAnimationView.requestLayout();
}

// Apply Styles
TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.MaterialDialog);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ protected BottomSheetMaterialDialog(@NonNull final Activity mActivity,
@NonNull DialogButton mNegativeButton,
@RawRes int mAnimationResId,
@NonNull String mAnimationFile,
@NonNull Boolean mShowInLandscape) {
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape);
@NonNull Boolean mShowInLandscape,
@NonNull Integer mHeight
) {
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape, mHeight);

// Init Dialog, Create Bottom Sheet Dialog
mDialog = new BottomSheetDialog(mActivity);
Expand Down Expand Up @@ -94,6 +96,7 @@ public static class Builder {
private int animationResId = NO_ANIMATION;
private String animationFile;
private Boolean showInLandscape = false;
private Integer height = -1;

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

/** It sets the showInLandscape property to allow or not the animation to be shown in landscape orientation
*
* @param height sets the height of the animation wrapper
* @return this, for chaining.
*/
@NonNull
public Builder setAnimationHeight(@NonNull Integer height) {
this.height = height;
return this;
}

/**
* Build the {@link BottomSheetMaterialDialog}.
*/
@NonNull
public BottomSheetMaterialDialog build() {
return new BottomSheetMaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape);
return new BottomSheetMaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape, height);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ protected MaterialDialog(@NonNull final Activity mActivity,
@NonNull DialogButton mNegativeButton,
@RawRes int mAnimationResId,
@NonNull String mAnimationFile,
@NonNull Boolean mShowInLandscape) {
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape);
@NonNull Boolean mShowInLandscape,
@NonNull Integer mHeight
) {
super(mActivity, title, message, mCancelable, mPositiveButton, mNegativeButton, mAnimationResId, mAnimationFile, mShowInLandscape, mHeight);

// Init Dialog
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
Expand Down Expand Up @@ -58,6 +60,7 @@ public static class Builder {
private int animationResId = NO_ANIMATION;
private String animationFile;
private Boolean showInLandscape = false;
private Integer height = -1;

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

/** It sets the showInLandscape property to allow or not the animation to be shown in landscape orientation
*
* @param height sets the height of the animation wrapper
* @return this, for chaining.
*/
@NonNull
public Builder setAnimationHeight(@NonNull Integer height) {
this.height = height;
return this;
}

/**
* Build the {@link MaterialDialog}.
*/
@NonNull
public MaterialDialog build() {
return new MaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape);
return new MaterialDialog(activity, title, message, isCancelable, positiveButton, negativeButton, animationResId, animationFile, showInLandscape, height);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="175dp"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:scaleType="fitCenter"
android:visibility="visible"
app:lottie_autoPlay="true"
app:lottie_loop="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
app:lottie_loop="true"
android:visibility="visible"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:scaleType="fitCenter"
app:lottie_autoPlay="true"/>

<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void onClick(DialogInterface dialogInterface, int which) {
dialogInterface.dismiss();
}
})*/
.setAnimation("delete_anim.json")
.setAnimation(R.raw.connection_error)
.setShowInLandscape(true)
.build();

Expand All @@ -115,7 +115,7 @@ public void onClick(DialogInterface dialogInterface, int which) {
dialogInterface.dismiss();
}
})*/
.setAnimation("delete_anim.json")
.setAnimation(R.raw.connection_error)
.setShowInLandscape(true)
.build();

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/raw/connection_error.json
Original file line number Diff line number Diff line change
@@ -0,0 +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 comments on commit 732f0a6

Please sign in to comment.