Git Product home page Git Product logo

kongzue / dialogx Goto Github PK

View Code? Open in Web Editor NEW
1.9K 19.0 199.0 138.51 MB

💬 DialogX dialog box component library, easy to use, more customizable, more scalable, easy to achieve a variety of dialog boxes. DialogX对话框组件库,更加方便易用,可自定义程度更高,扩展性更强,轻松实现各种对话框、菜单和提示效果,更有Material You、iOS、MIUI等主题扩展可选

License: Apache License 2.0

Java 100.00%
dialogx-material kongzue-dialogx waitdialog-tipdialog bottomdialog-bottommenu android-dialog ios-style android dialog materialdialog messagedialog

dialogx's Introduction

Kongzue 的 Github

  

欢迎使用我分享的框架和代码。我的所有开源代码库都旨在减少重复性开发工作和不必要的麻烦,其性能不一定是最优的,但一定朝着对开发者最友好的方向进行设计,希望能多吸取建议和意见,与各位共同进步。

🚀统计

Kongzue's GitHub stats GitHub Streak

🛠️工具&语言

🌐我的个人网站和博客

个人网站

➡️kongzue.com

你可以访问这个网站来了解我做过哪些项目,以及当前在 Github 上开源的这些作品应用于了哪些已经上线的项目。

专栏博客

➡️Android开发中遇到的那些坑

小专栏,技术干货分享,包含应用层、硬件相关开发和网络相关开发中常见/非常见错误,排查办法及原因分析,以及一些基础介绍文章

➡️大话安卓

大话安卓群友文章分享,包含一些技术讨论、新框架介绍

📧如何与我取得联系

如果你对这些开源的框架有任何疑问或建议,可以直接在库的页面提交 issues,不过因为工作的原因我可能不能及时答复,你可以通过 Q 群:590498789,或者邮件至:[email protected],我会尽快答复。

dialogx's People

Contributors

alirezaivaz avatar hchenx avatar kongzue avatar matcha-xiaobin avatar weixiaomin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dialogx's Issues

一个页面多个接口时的混乱

在同一个Fragment里,同时加载多个接口,每个接口都调用了WaitDialog,结果WaitDialog一直存在,不会消失
mModel.getTaskList( pageNo, pageSize)
.subscribeOn(Schedulers.io())
//遇到错误时重试,第一个参数为重试几次,第二个参数为重试的间隔
.retryWhen(new RetryWithDelay(3, 2))
.doOnSubscribe(disposable -> {
WaitDialog.show( "请稍候222...");
})
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doFinally(() -> {
WaitDialog.dismiss();
})
//使用 Rxlifecycle,使 Disposable 和 Activity 一起销毁
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber(mErrorHandler) {
@OverRide
public void onNext(GetTaskEntity response) {
}
});

使用IOSstyle后报错,默认样式没问题

java.lang.AbstractMethodError: abstract method "int com.kongzue.dialogx.interfaces.DialogXStyle$WaitTipRes.overrideWaitLayout(boolean)"

private fun initDialogX() {
    DialogX.init(this)
    DialogX.globalStyle = IOSStyle()
}

在Application.onCreate()中调用初始化方法

两个dialog互相调用显示,会导致链接无法点击

第一个dialog里包含了SpannnableString的描述,里面的文字里有链接可以有点击效果。

//设置下划线文字
        spannableString.setSpan(UnderlineSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
        //设置文字的单击事件
        spannableString.setSpan(object : ClickableSpan() {
            override fun onClick(widget: View) {
                Timber.d("ClickableSpan.onClick")
                onClickHandler()
            }
        }, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
        //设置文字的前景色
        spannableString.setSpan(
            ForegroundColorSpan(application.color(R.color.accent)),
            start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
        )

使用showDialog()来显示第一个dialog,此时的文字链接点击有onClick回调效果。

当第一个dialog,点击取消的时候,显示一个二次确认弹窗,

在这个第二次确认弹窗dialog的取消,setCancelButton,会直接重新调用showDialog()显示第一个dialog,此时显示的dialog正确显示下划线等外观,然而,链接却没有onClick点击效果。

状况描述:
如果在第二次弹窗的取消上直接执行showDialog(),则第一个dialog【无】点击效果。
如果在第二次弹窗的取消上添加异步0.1秒执行showDialog(),则第一个dialog【有】点击效果。
如果在第二次弹窗的onDismiss回调上直接执行showDialog(),则第一个dialog【无】点击效果。

不知道具体2个dialog显示是否有公用情况或者什么原因,希望我这个描述可以让你明白我的问题。

好像不支持序列化/顺序展示提示框,而同时展示了全部

MessageDialog
                .show("标题", "这里是正文内容。", "确定")
                .setOkButton { baseDialog, v ->
                    PopTip.show("点击确定按钮")
                    PopTip.show("点击确定按钮")
                    false
                }

val messageDialog =
    MessageDialog("多选对话框", "移除App会将它从主屏幕移除并保留其所有数据。", "删除App", "取消", "移至App资源库")
        .setButtonOrientation(LinearLayout.VERTICAL)
messageDialog.show()

TipDialog builder模式

TipDialog 没有builder模式,只能TipDialog.show(,);
产生的影响,不能show(activity);

崩溃:Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4496)

稳定复现代码如下:
CustomDialog.show(object : OnBindView(R.layout.alert_coustom) {
override fun onBind(dialog: CustomDialog, v: View) {
v.findViewById(R.id.tv_cancel).click { dialog.dismiss() }
v.findViewById(R.id.tv_ok).click {
dialog.dismiss()
TipDialog.show("崩溃点",WaitDialog.TYPE.SUCCESS)
}
}
})
CustomDialog中执行相关逻辑后,只要有TipDialog弹窗提示和就会崩溃报空指针,报错内容:
java.lang.NullPointerException
Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
com.kongzue.dialogx.interfaces.BaseDialog.createView(BaseDialog.java:131)

自定义弹窗的奇怪现象

在最新的AS 4.2.1和com.gyf.immersionbar:immersionbar:3.0.0,但是demo项目没问题

CustomDialog.build()
            .setCustomView(object : OnBindView<CustomDialog>(R.layout.dialog_popup_custom) {

                override fun onBind(dialog: CustomDialog?, v: View?) {

                }

            })
            .setMaskColor(CoreApplication.instance.color(R.color.backgroundAlertMaskTransparent))
            .setFullScreen(true)
            .setAlign(CustomDialog.ALIGN.CENTER)
            .setAutoUnsafePlacePadding(false)
            .show()

image

center无效果,然后bottom直接看不见

配合AndroidUtilCode PermissionUtils显示方法bug

PermissionUtils请求权限,在回调中显示MessageDialog。
PermissionUtils会启动一个UtilActivity,瞬间消失,MessageDialog.show会显示在UtilActivity上面。
由于show方法无法指定activity ,就会出现无法show的情况

WaitDialog theme

无单独设置WaitDialog theme的接口。
我想亮色模式也是用白色框

BottomMenu在我的魅族魅蓝U20上,高度为全屏

BottomMenu.show(contractNameList as List?)
.setCancelButton("取消")
.setSelection(contractSelectIndex)
.setOnMenuItemClickListener { _, text, index ->
btnContract.text = text
contractSelectIndex = index
return@setOnMenuItemClickListener false
}
}

不知道是不是我的使用方式不对
但是在小米一款手机上正常得

通过TextInfo设置标题 、确定、 取消按钮不加粗 不生效

1、通过TextInfo设置标题 、确定、 取消按钮不加粗 不生效,
2、MessageDialog.show(null,"内容,"确定","取消")
内容顶到dialog的顶部去了,
3、无法设置MessageDialog标题和内容的边距
4、其他style能否上传到jcenter,通过gradle来引用

MessageDialog自定义布局的宽度

MessageDialog中设置自定义布局后,对话框的宽度如何设置呢?
我的应用是强制横屏的,对话框宽度过宽,且不会随自定义布局的宽度而变化,尝试设置 DialogX.dialogMaxWidth 没有效果

Dialog Dissmiss后页面所有事件全部失效

请求结束后会弹框,然后弹框点击确定后diss,但是页面上任何事件均无效果(无法滑动或者点击触摸),但是进程并没有被阻塞。

a1600063c83a096b6f1000d5a530b373.mp4

自定义view中

在BottomMenu中使用自定义view带listview 最终只会显示一行的数据。感觉是BottomMenu中给cutsomview的展示面积很小
`

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="60dp">

    <TextView
        android:id="@+id/btn_dialog_cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:paddingLeft="20dp"
        android:text="@string/view_cancel"
        android:textColor="@color/textColor_iOS"
        android:textSize="@dimen/NormalTextSize" />

    <TextView
        android:id="@+id/btn_dialog_confirm"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:paddingRight="20dp"
        android:text="@string/make_sure"
        android:textColor="@color/textColor_iOS"
        android:textSize="@dimen/NormalTextSize" />
</RelativeLayout>


<ListView
    android:id="@+id/lv_tree_menu"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:cacheColorHint="@android:color/transparent"
    android:divider="#aaa"
    android:dividerHeight="1px" />

`

等待+提示对话框 返回键处理异常

将demo等待时间延长,按一次返回键,PopTip弹出,立即再按返回键,会执行返回键操作。(这个操作待讨论)。
按一次返回键,PopTip弹出,等PopTip消失再按返回键,也会执行返回键操作,这个操作估计不科学。

37版本是发了还是没发?

Failed to resolve: com.kongzue.dialogx:DialogX:0.0.37
Show in Project Structure dialog
Affected Modules: app

gradle sync的时候总是提示这个

InputDialog无法输入数据

按照使用说明创建了一个输入对话框,不点击输入框就显示正常,然后点击输入框后显示出现问题,输入框及下半部分会不见,只剩下标题和按钮。
在AS 3.5的模拟器(安卓11)上和实体机(安卓11,类原生系统)上都有这个问题,App的API版本也是30
1
2

设置背景色有问题

在com.kongzue.dialogx.dialogs.MessageDialog:491行

splitHorizontal.setBackgroundColor(getColor(style.splitColorRes(isLightTheme())));

应该采用类似533行的:

splitView.setBackgroundColor(getResources().getColor(style.splitColorRes(isLightTheme())));

结果应为:
在com.kongzue.dialogx.dialogs.MessageDialog:491行

splitHorizontal.setBackgroundColor(getResources().getColor(style.splitColorRes(isLightTheme())));

不然现在获取不到resource

BottomDialog 自定义布局 中包含 recycleview recycleview 移除item BottomDialog高度变化异常

目前解决办法 在OnGlobalLayoutListener 中加入一下代码
private ViewTreeObserver.OnGlobalLayoutListener onContentViewLayoutChangeListener = new ViewTreeObserver.OnGlobalLayoutListener() {
@OverRide
public void onGlobalLayout() {
if (boxContent != null) {
if (bkg.isChildScrollViewCanScroll() && bottomDialogMaxHeight != 0) {
if (bottomDialogMaxHeight <= 1) {
bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight() * bottomDialogMaxHeight;
} else {
bkgEnterAimY = boxBkg.getHeight() - bottomDialogMaxHeight;
}
} else {
bkgEnterAimY = boxBkg.getHeight() - bkg.getHeight();
}
long exitAnimDurationTemp = 300;

                ObjectAnimator exitAnim = ObjectAnimator.ofFloat(bkg, "y", bkg.getY(), bkgEnterAimY);
                exitAnim.setDuration(exitAnimDurationTemp);
                exitAnim.start();
             /*   long downTime = SystemClock.uptimeMillis();
                long eventTime = SystemClock.uptimeMillis() + 100;
                float x = 0.0f;
                float y = 0.0f;
                int metaState = 0;
                MotionEvent motionEvent = MotionEvent.obtain(
                        downTime,
                        eventTime,
                        MotionEvent.ACTION_MOVE,
                        x,
                        y,
                        metaState
                );

                bkg.dispatchTouchEvent(motionEvent);*/

            }
        }
    };

为什么不持有独立的 Window 呢

不持有独立的 Window,将会对宿主 Window 造成过度绘制,
弹窗时的背景遮罩算一层(绿色),对话框的背景算一层(浅红),这时候再布置些内容,就已经触及性能的红线了。

如果坚持通过这种方式来显示对话框,倒是有一种办法可以尽可能减少过度绘制,是通过 canvas.clipRect 的方式,使对话框遮住的部分不再绘制。

不过这种方式的实现只适合底栏和顶栏。

还是不一样

Screenshot_2021-02-25-22-00-37-80
Screenshot_2021-02-25-20-55-16-14
和你软件还是不一样,宽度对了,长度不对啊?

具体修改了这个方法 加了句 rootFrameLayout.get().removeView(dialogView);

public static void dismiss(View dialogView) {
if (rootFrameLayout == null || dialogView == null) return;
if (dialogView.getTag() == null || !(dialogView.getTag() instanceof ViewGroup)) {
rootFrameLayout.get().removeView(dialogView);
} else {
((ViewGroup) dialogView.getTag()).removeView(dialogView);
rootFrameLayout.get().removeView(dialogView);
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.