Skip to content

Commit

Permalink
0.0.43.beta11
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzue committed Sep 10, 2021
1 parent 0d7a1e4 commit c520dcb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
48 changes: 29 additions & 19 deletions DialogX/src/main/java/com/kongzue/dialogx/dialogs/WaitDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Handler;
Expand Down Expand Up @@ -198,18 +199,20 @@ protected void setWaitDialogView(View v) {

public WaitDialog show() {
super.beforeShow();
int layoutResId = R.layout.layout_dialogx_wait;
if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
}
dialogImpl = new WeakReference<>(new DialogImpl(layoutResId));
runOnMain(new Runnable() {
@Override
public void run() {
int layoutResId = R.layout.layout_dialogx_wait;
if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
}
dialogImpl = new WeakReference<>(new DialogImpl(layoutResId));
if (getDialogImpl() != null) {
getDialogImpl().lazyCreate();
if (getWaitDialogView() != null) getWaitDialogView().setTag(me.get());
show(getWaitDialogView());
if (getWaitDialogView() != null) {
getWaitDialogView().setTag(me.get());
show(getWaitDialogView());
}
}
}
});
Expand All @@ -218,18 +221,20 @@ public void run() {

public WaitDialog show(final Activity activity) {
super.beforeShow();
int layoutResId = R.layout.layout_dialogx_wait;
if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
}
dialogImpl = new WeakReference<>(new DialogImpl(layoutResId));
runOnMain(new Runnable() {
@Override
public void run() {
int layoutResId = R.layout.layout_dialogx_wait;
if (style.overrideWaitTipRes() != null && style.overrideWaitTipRes().overrideWaitLayout(isLightTheme()) != 0) {
layoutResId = style.overrideWaitTipRes().overrideWaitLayout(isLightTheme());
}
dialogImpl = new WeakReference<>(new DialogImpl(layoutResId));
if (getDialogImpl() != null) {
getDialogImpl().lazyCreate();
if (getWaitDialogView() != null) getWaitDialogView().setTag(me.get());
show(activity, getWaitDialogView());
if (getWaitDialogView() != null) {
getWaitDialogView().setTag(me.get());
show(activity, getWaitDialogView());
}
}
}
});
Expand All @@ -254,8 +259,9 @@ public DialogImpl(int layoutResId) {
}

public void lazyCreate() {
View dialogView;
setWaitDialogView(dialogView = createView(layoutResId));
View dialogView = createView(layoutResId);
if (dialogView == null) return;
setWaitDialogView(dialogView);
boxRoot = dialogView.findViewById(R.id.box_root);
bkg = dialogView.findViewById(R.id.bkg);
blurView = dialogView.findViewById(R.id.blurView);
Expand Down Expand Up @@ -330,7 +336,7 @@ public void run() {
}
enterAnim.setDuration(enterAnimDurationTemp);
bkg.startAnimation(enterAnim);

ValueAnimator bkgAlpha = ValueAnimator.ofFloat(0f, 1f);
bkgAlpha.setDuration(enterAnimDurationTemp);
bkgAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
Expand Down Expand Up @@ -454,6 +460,10 @@ public void doDismiss(final View v) {
boxRoot.post(new Runnable() {
@Override
public void run() {
Context context = getContext();
if (context == null) context = boxRoot.getContext();
if (context == null) return;

if (v != null) v.setEnabled(false);

int exitAnimResId = R.anim.anim_dialogx_default_exit;
Expand All @@ -463,7 +473,7 @@ public void run() {
if (customExitAnimResId != 0) {
exitAnimResId = customExitAnimResId;
}
Animation exitAnim = AnimationUtils.loadAnimation(getContext(), exitAnimResId);
Animation exitAnim = AnimationUtils.loadAnimation(context, exitAnimResId);
long exitAnimDurationTemp = exitAnim.getDuration();
if (overrideExitDuration >= 0) {
exitAnimDurationTemp = overrideExitDuration;
Expand All @@ -479,7 +489,7 @@ public void run() {
.alpha(0f)
.setInterpolator(new AccelerateInterpolator())
.setDuration(exitAnimDurationTemp);

ValueAnimator bkgAlpha = ValueAnimator.ofFloat(1f, 0f);
bkgAlpha.setDuration(exitAnimDurationTemp);
bkgAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.animation.ObjectAnimator;
import android.content.res.Resources;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

Expand Down Expand Up @@ -130,6 +131,9 @@ public boolean onTouch(View v, MotionEvent event) {
}
});
} else {
if (impl.scrollView instanceof ScrollController) {
((ScrollController) impl.scrollView).lockScroll(false);
}
impl.bkg.setOnTouchListener(null);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

BUILD_VERSION=0.0.43.beta10
BUILD_VERSION=0.0.43.beta11
BUILD_VERSION_INT=42

0 comments on commit c520dcb

Please sign in to comment.