Skip to content

Commit

Permalink
hmm
Browse files Browse the repository at this point in the history
  • Loading branch information
x3rocode committed Aug 19, 2022
1 parent 9c3c953 commit d19b78c
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 73 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import android.graphics.Color
import android.os.Bundle
import android.os.CountDownTimer
import android.view.View
import android.view.Window
import android.view.WindowManager
import android.widget.Button
import android.widget.CheckBox
import android.widget.EditText
Expand Down Expand Up @@ -48,93 +50,85 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
findViewById<Button>(id).setOnTouchListener(Constants.FOCUS_TOUCH_LISTENER)
}

lottie_test.repeatCount = 0
lottie_test.setAnimation(R.raw.ok_btn_lottie)

lottie_test.addAnimatorListener(object : Animator.AnimatorListener {

override fun onAnimationStart(animation: Animator) {
}

}
override fun onAnimationEnd(animation: Animator) {
sd.dismissWithAnimation()
}

override fun onAnimationCancel(animation: Animator) {
}
override fun onClick(v: View) {
when (v.id) {

basic_lottie_test.id -> {
val lsd = SweetLottieAlertDialog(this, SweetLottieAlertDialog.CUSTOM_IMAGE_TYPE)
lottie_test.addAnimatorListener(object : Animator.AnimatorListener {

override fun onAnimationRepeat(animation: Animator) {
}
})
override fun onAnimationStart(animation: Animator) {

}
override fun onAnimationEnd(animation: Animator) {
lsd.dismissWithAnimation()
}

override fun onAnimationCancel(animation: Animator) {
}

}
override fun onAnimationRepeat(animation: Animator) {
}
})

lsd.contentText = "Success!"
lsd.setLottieDrawble(lottie_test.drawable)
lsd.setCancelable(true)
lsd.setButtonTextFont(R.font.rix_font)
lsd.setCanceledOnTouchOutside(true)
lsd.show()
lottie_test.playAnimation()

override fun onClick(v: View) {
when (v.id) {
basic_test.id -> {
val sd = SweetLottieAlertDialog(this)
sd.setCancelable(true)
sd.setCanceledOnTouchOutside(true)
sd.setContentText("Here's a message")
sd.show()
}
basic_test_without_buttons.id -> {
val sd2 = SweetLottieAlertDialog(this)
sd2.setCancelable(true)
sd2.setCanceledOnTouchOutside(true)
sd2.setContentText("Here's a message")
sd2.hideConfirmButton()
sd2.show()
}
basic_lottie_popup_test.id -> {
basic_lottie_by_id_test.id -> {
val lsd2 = SweetLottieAlertDialog(this, SweetLottieAlertDialog.LOTTIE_ID_TYPE)
lsd2.setTitleText("this is lottie!")
lsd2.setContentText("WOW")
lsd2.setLottieImagebyId(R.raw.lottie_cryingface, true)
lsd2.contentText = "Try Again!"
lsd2.setLottieImagebyId(R.raw.lottie_cryingface, true, null)
lsd2.setCancelable(true)
lsd2.setPopupLottieAnimation(R.raw.lottie_congratulation, false, 999f)
lsd2.confirmText = "OK"
lsd2.setCanceledOnTouchOutside(true)
lsd2.setButtonTextFont(R.font.lexend_deca)
lsd2.show()
}
basic_lottie_test.id -> {
val lsd = SweetLottieAlertDialog(this, SweetLottieAlertDialog.CUSTOM_IMAGE_TYPE)
lsd.setTitleText("this is lottie!")
lsd.setLottieDrawble(lottie_test.drawable)
lsd.setCancelable(true)
lsd.setConfirmText("OK")
lsd.setButtonTextFont(R.font.lexend_deca)
lsd.setCanceledOnTouchOutside(true)
lsd.show()
lottie_test.playAnimation()
}
basic_lottie_by_id_test.id -> {
basic_lottie_popup_test.id -> {
val lsd2 = SweetLottieAlertDialog(this, SweetLottieAlertDialog.LOTTIE_ID_TYPE)
lsd2.setTitleText("this is lottie!")
lsd2.setContentText("WOW")
lsd2.setLottieImagebyId(R.raw.lottie_cryingface, true)
lsd2.contentText = "Congratulation!"
lsd2.setLottieImagebyId(R.raw.lottie_cryingface, true, null)
lsd2.setCancelable(true)
lsd2.setConfirmText("OK")
lsd2.setPopupLottieAnimation(R.raw.lottie_congratulation, false, 999f)
lsd2.setCanceledOnTouchOutside(true)
lsd2.setButtonTextFont(R.font.lexend_deca)
lsd2.show()
}

popup_lottie_behind_test.id -> {
val lsd2 = SweetLottieAlertDialog(this, SweetLottieAlertDialog.LOTTIE_ID_TYPE)
lsd2.setTitleText("this is lottie!")
lsd2.setContentText("WOW")
lsd2.setLottieImagebyId(R.raw.lottie_cryingface, true)
lsd2.contentText = "Lottie is behind the dialog"
lsd2.setLottieImagebyId(R.raw.lottie_cryingface, true, null)
lsd2.setCancelable(true)
lsd2.setPopupLottieAnimation(R.raw.lottie_congratulation, false, 0f)
lsd2.setPopupLottieAnimation(R.raw.lottie_money, true, 0f)
lsd2.setCanceledOnTouchOutside(true)
lsd2.setButtonTextFont(R.font.lexend_deca)
lsd2.show()
}

basic_test.id -> {
val sd = SweetLottieAlertDialog(this)
sd.setCancelable(true)
sd.setCanceledOnTouchOutside(true)
sd.setContentText("Here's a message")
sd.show()
}
basic_test_without_buttons.id -> {
val sd2 = SweetLottieAlertDialog(this)
sd2.setCancelable(true)
sd2.setCanceledOnTouchOutside(true)
sd2.setContentText("Here's a message")
sd2.hideConfirmButton()
sd2.show()
}
under_text_test.id -> SweetLottieAlertDialog(this, SweetLottieAlertDialog.NORMAL_TYPE)
.setTitleText("Title")
.setContentText("It's pretty, isn't it?")
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
android:id="@+id/lottie_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_rawRes="@raw/lottie_cryingface"
app:lottie_rawRes="@raw/ok_btn_lottie"
app:lottie_autoPlay="true"
app:lottie_repeatCount="0"
android:visibility="gone" />

<ImageView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/raw/lottie_money.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>

<color name="eblue40">#00A5E5</color>
<color name="eblue60">#0285BE</color>
<color name="eblue80">#00578A</color>
Expand All @@ -17,4 +9,13 @@
<color name="egray30">#D3D3D3</color>
<color name="egray40">#B2B2B2</color>
<color name="egray50">#929292</color>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@



import android.animation.Animator;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
Expand Down Expand Up @@ -94,6 +95,7 @@ public class SweetLottieAlertDialog extends Dialog implements View.OnClickListen
private int mLottieRes;
private int mPopupLottieRes;
private boolean mLottieIsLoop;
private Animator.AnimatorListener mLottieAnimatorListner;
private boolean mPopupLottieIsLoop;
private boolean mCloseFromCancel;
private float mPopupLottieElevation;
Expand Down Expand Up @@ -332,7 +334,7 @@ private void changeAlertType(int alertType, boolean fromCreate) {
case LOTTIE_ID_TYPE:
mLottieAnimationView.setVisibility(View.VISIBLE);
mCustomImage.setVisibility(View.GONE);
setLottieImagebyId(mLottieRes, mLottieIsLoop);
setLottieImagebyId(mLottieRes, mLottieIsLoop, mLottieAnimatorListner);
}
if (!fromCreate) {
playAnimation();
Expand Down Expand Up @@ -599,17 +601,21 @@ public SweetLottieAlertDialog setCustomImage (int resourceId) {
return setCustomImage(getContext().getResources().getDrawable(resourceId));
}

public SweetLottieAlertDialog setLottieImagebyId (int lottieRes, boolean isLoop) {
public SweetLottieAlertDialog setLottieImagebyId (int lottieRes, boolean isLoop, Animator.AnimatorListener listner) {
mLottieRes = lottieRes;
mLottieIsLoop = isLoop;

mLottieAnimatorListner = listner;
if (mLottieAnimationView != null ) {

mLottieAnimationView.setVisibility(View.VISIBLE);

mLottieAnimationView.setAnimation(mLottieRes);
mLottieAnimationView.playAnimation();
mLottieAnimationView.loop(mLottieIsLoop);
if(mLottieAnimatorListner != null){
mLottieAnimationView.addAnimatorListener(mLottieAnimatorListner);
}

}
return this;
}
Expand Down
10 changes: 9 additions & 1 deletion library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@color/float_transparent</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:backgroundDimEnabled">true</item>
Expand All @@ -18,6 +18,14 @@


<style name="alert_dialog_dark" parent="alert_dialog_light">
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@color/float_transparent</item>
<item name="android:windowAnimationStyle">@null</item>
<item name="android:backgroundDimEnabled">true</item>

<item name="android:backgroundDimAmount">0.8</item>
<item name="sweet_alert_bg_drawable">@drawable/dialog_background_dark</item>
<item name="sweet_alert_title_text_color">@color/title_color_dark</item>
Expand Down

0 comments on commit d19b78c

Please sign in to comment.