All Projects → 24Kshign → FRDialog

24Kshign / FRDialog

Licence: other
用Builder模式重新打造一个dialog

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to FRDialog

android-dialog
此框架提供七种对话框的显示,并支持对话框的扩展,目的是为了提供对话框的统一管理,并提供对话框显示的公共接口。
Stars: ✭ 44 (-48.84%)
Mutual labels:  dialog
opensnips
Open source projects related to Snips https://snips.ai/.
Stars: ✭ 50 (-41.86%)
Mutual labels:  dialog
android-versioninfo
A version info widget for Android. Material style.
Stars: ✭ 21 (-75.58%)
Mutual labels:  dialog
bootstrap-cookie-consent-settings
A modal dialog (cookie banner) and framework to handle the German and EU law about cookies in a website. Needs Bootstrap.
Stars: ✭ 25 (-70.93%)
Mutual labels:  dialog
react-native-wxui
A UI package for React Native
Stars: ✭ 21 (-75.58%)
Mutual labels:  dialog
AudioVisualSceneAwareDialog
No description or website provided.
Stars: ✭ 22 (-74.42%)
Mutual labels:  dialog
denbun
Adjust showing frequency of Android app messages, and to be more user friendly 🐦
Stars: ✭ 17 (-80.23%)
Mutual labels:  dialog
ContrastiveLearning4Dialogue
The codebase for "Group-wise Contrastive Learning for Neural Dialogue Generation" (Cai et al., Findings of EMNLP 2020)
Stars: ✭ 54 (-37.21%)
Mutual labels:  dialog
ngx-modal
Dynamic modal dialog for Angular
Stars: ✭ 54 (-37.21%)
Mutual labels:  dialog
AVSD-DSTC10 Official
Audio Visual Scene-Aware Dialog (AVSD) Challenge at the 10th Dialog System Technology Challenge (DSTC)
Stars: ✭ 22 (-74.42%)
Mutual labels:  dialog
Android-Shortify
An Android library used for making an Android application more faster with less amount of code. Shortify for Android provides basic functionalities of view and resource binding, view customization, JSON parsing, AJAX, various readymade dialogs and much more.
Stars: ✭ 21 (-75.58%)
Mutual labels:  dialog
DSTC6-End-to-End-Conversation-Modeling
DSTC6: End-to-End Conversation Modeling Track
Stars: ✭ 56 (-34.88%)
Mutual labels:  dialog
permuted-bAbI-dialog-tasks
Dataset for 'Learning End-to-End Goal-Oriented Dialog with Multiple Answers' EMNLP 2018
Stars: ✭ 17 (-80.23%)
Mutual labels:  dialog
AndroidLoadingView
🚗🚗🚗Android LoadingView
Stars: ✭ 25 (-70.93%)
Mutual labels:  dialog
TaskDialog
.NET implementation of the Windows Task Dialog.
Stars: ✭ 48 (-44.19%)
Mutual labels:  dialog
smart-show
Toast # Snackbar # Dialog
Stars: ✭ 500 (+481.4%)
Mutual labels:  dialog
Licenser
An android library to display the licenses of your application libraries in a easy way.
Stars: ✭ 75 (-12.79%)
Mutual labels:  dialog
soloalert
A customizable lightweight Alert Library with Material UI and awesome features.
Stars: ✭ 18 (-79.07%)
Mutual labels:  dialog
ak-vue3
组件库包含了 AutoForm 自动表单、BackTop 返回顶部、Breadcrumb 面包屑、 Button 按钮、Cascader 级联选择器、Checkbox 多选框、Collapse 折叠面板、ColorPicker 颜色选择器、DataPicker 时间选择器、Dialog 弹层对话框、Alert 弹框、Echarts 图形图表、Form 表单、Input 输入框、Lazy 图片延时加载、Loading 加载等待、Menu 菜单、Pagination 分页、Progress 进度条、Radio 单选框、Select 选择器、Steps 步骤条、Swiper 图片轮播、Switch 开关、Table 表格、Tabs 标签页、Textarea 文本框、Tooltip 提示、Tr…
Stars: ✭ 24 (-72.09%)
Mutual labels:  dialog
TheBashMenu
A useful bash script allowing you to easily create your own menu, which uses the directional keys! Quickly add your title, options and commands and you're good to go!
Stars: ✭ 52 (-39.53%)
Mutual labels:  dialog

FRDialog

用Builder模式重新打造一个dialog,案例中有两种Builder,分别是CommonBuilder和MDBuilder,如果还想实现其他的通用,继承自FRBaseDialogBuilder即可。

jcenter Author Api

注意

从2019.05.23日开始,该库升级为支持androidx,如果你的项目还没有升级支持的话,那么只能使用1.0.6之前的版本。

1、添加依赖

Gradle:

repositories {
    jcenter()
}

dependencies {
    //lastVersion请参照上述版本号
    compile 'com.jack.frdialog:FRDialog:latestVersion'
}

2、使用案例

2.1、普通Dialog

private void showCommonDialog() {
    final FRDialog dialog = new FRDialog.CommonBuilder(this)
            .setContentView(R.layout.dialog_common)
            .setText(R.id.dcu_tv_cancel, "否")
            .setText(R.id.dcu_tv_confirm, "是")
            .setText(R.id.dcu_tv_title, "温馨提示")
            .setText(R.id.dcu_tv_content, "1.文字文字我是文字文字文字我是文字文字文字我是文字!\n2.文字文字文字文字文字\n3.文字文字文字文字文字")
            .setDefaultAnim()
            .show();

    dialog.setText(R.id.dcu_tv_confirm, "确定");

    dialog.setOnClickListener(R.id.dcu_tv_cancel, new FRDialogClickListener() {
        @Override
        public boolean onDialogClick(View view) {
            Toast.makeText(MainActivity.this, "点击了否", Toast.LENGTH_SHORT).show();
            return true;
        }
    });

    dialog.setOnClickListener(R.id.dcu_tv_confirm, new FRDialogClickListener() {
        @Override
        public boolean onDialogClick(View v) {
            Toast.makeText(MainActivity.this, "点击了是", Toast.LENGTH_SHORT).show();
            return false;
        }
    });
}

普通dialog

2.2、MaterialDesign Dialog

private void showMDDialog() {
    FRDialog dialog = new FRDialog.MDBuilder(this)
                    .setMessage("1.文字文字我是文字文字!\n2.文字文字文字文字文字\n3.文字文字文字文字文字")
                    .setTitle("温馨提示")
                    .setNegativeContentAndListener("否", null)
                    .setNegativeTextColor(ContextCompat.getColor(this,R.color.c999999))
                    .setPositiveTextColor(ContextCompat.getColor(this,R.color.colorPrimary))
                    .setPositiveContentAndListener("是", new FRDialogClickListener() {
                        @Override
                        public boolean onDialogClick(View view) {
                            return true;
                        }
                    }).show();
}

MD效果的dialog

2.3、从底部弹出来的Dialog

FRDialog dialog = new FRDialog.CommonBuilder(this)
  .setContentView(R.layout.dialog_from_bottom)
  .setFullWidth()
  .setFromBottom()
  .show();

从底部弹出的dialog

3、特殊设置:

继承所有dialog的设置,同时还可以自定义以下设置

//设置宽度全屏
dialog.setFullWidth()

//设置从底部弹出
dialog.setFromBottom()

//设置弹出动画
dialog.setAnimation(int anim)

2018.5.24日更新

将mWidth改成mWidthRatio,不让用户设置一个具体的宽度,而是让用户去设置一个宽度比例,然后通过改变window的LayoutParams来设置dialog的宽高:

WindowManager.LayoutParams lp = window.getAttributes();
lp.width = (int) (baseBuilder.mContext.getResources().getDisplayMetrics().widthPixels * baseBuilder.mWidthRatio);
lp.height = baseBuilder.mHeight;
window.setAttributes(lp);

用法还是和之前一样:

dialog.setWidthRatio(0——1)  默认是0.9

2018.7.19日更新

新增点击dialog中非EditText区域隐藏软键盘

重写dispatchTouchEvent方法进行拦截:

/**
 * 点击dialog中除EditText以外的区域隐藏软键盘
 *
 * @param ev
 * @return
 */
@Override
public boolean dispatchTouchEvent(@NonNull MotionEvent ev) {
    FRInputMethodManager.autoHideSoftInput(this, ev);
    return super.dispatchTouchEvent(ev);
}

//核心方法
public static boolean isAutoHideSoftInput(View view, MotionEvent event) {
    if (event.getAction() != MotionEvent.ACTION_DOWN) {
        return false;
    }

    if (!(view instanceof EditText)) {
        return false;
    }

    float x = event.getX();
    float y = event.getY();

    int[] location = {0, 0};
    view.getLocationInWindow(location);
    int left = location[0];
    int top = location[1];
    int bottom = top + view.getHeight();
    int right = left + view.getWidth();
    if (left <= x && x < right && top <= y && y < bottom) {
        // 点击事件在EditText的区域里
        return false;
    }

    return true;
}

用法不变。

2018.9.11日更新

新增recyclerview样式的dialogBuilder

具体功能有:

  • 设置一个列表布局,只需要传一个adapter就好了

  • 可以给列表添加头部和底部

  • 可以给dialog添加头部和底部

用法:

    private void showRecyclerViewDialog() {
        List<Object> mDataList = new ArrayList<>();
        mDataList.add(new TestDataBean("张三", "2018-09-11 14:00"));
        mDataList.add(new TestDataBean("李四", "2018-09-11 11:00"));
        mDataList.add(new TestDataBean("王五", "2018-09-11 12:00"));
        mDataList.add(new TestDataBean("李四", "2018-09-11 13:00"));
        mDataList.add(new TestDataBean("张三", "2018-09-11 16:00"));
        mDataList.add(new TestDataBean("王五", "2018-09-11 15:00"));


        final FRDialog dialog = new FRDialog.RecyclerViewBuilder(this)
                .setLayoutManager(new LinearLayoutManager(MainActivity.this))
                .setAdapter(new FRBaseDialogAdapter<TestDataBean>(MainActivity.this) {

                    @Override
                    protected int getLayoutRes() {
                        return R.layout.item_test;
                    }

                    @Override
                    protected void convert(FRBaseDialogViewHolder holder, TestDataBean dataBean, int position, List<Object> payloads) {
                        holder.setImageResource(R.id.it_iv_image, R.mipmap.ic_launcher_round);
                        holder.setText(R.id.it_tv_title, dataBean.getName());
                        holder.setText(R.id.it_tv_time, dataBean.getTime());
                    }
                }).setDataList(mDataList)
                .setHeightRatio(0.5)
                .addRecyclerViewHeader(R.layout.layout_header)
                .addDialogFooter(R.layout.layout_footer)
                .setOnClickListener(R.id.lf_tv_cancel, view -> true)
                .setOnClickListener(R.id.lf_tv_confirm, view -> {
                    Toast.makeText(MainActivity.this, "点击了确定", Toast.LENGTH_SHORT).show();
                    return false;
                })
                .show();
    }

详细可以参照demo中的。

2018.11.14日更新

新增适配在Service中国弹出dialog

首先Android5.x以上的版本都需要适配,8.x版本的需要单独设置 window 的 type 类型,8.x以下版本,还需要申请悬浮窗的权限,因为我们是将dialog作为一个悬浮窗来弹出来

dialog中:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    Objects.requireNonNull(window).setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY - 1);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    Objects.requireNonNull(window).setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
    openOverlaySettings();
} else {
    startService(new Intent(this, DialogService.class));
}

private void openOverlaySettings() {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
        try {
            //打开权限申请页面
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
            startActivityForResult(intent, RC_OVERLAY);
        } catch (ActivityNotFoundException e) {
            Log.e("TAG", "ActivityNotFoundException--->" + e.getMessage());
        }
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case RC_OVERLAY:
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
                // 判断当前有没有授权成功
                if (Settings.canDrawOverlays(this)) {
                    startService(new Intent(this, DialogService.class));
                }
            }
		break;
    }
}

@Override
protected void onDestroy() {
    super.onDestroy();
    stopService(new Intent(this, DialogService.class));
}

2018.12.29日更新

新增dialog的偏移量,可以自定义dialog的显示位置

FRDialog dialog = new FRDialog.CommonBuilder(this, R.style.transparent_dialog)
                .setContentView(R.layout.dialog_offsetx)
                .setGravity(Gravity.LEFT | Gravity.TOP)
                .setOnClickListener(R.id.do_tv_praised, view -> {
                    Toast.makeText(DialogOffsetActivity.this, "赞", Toast.LENGTH_SHORT).show();
                    return true;
                })
                .setOnClickListener(R.id.do_tv_comment, view -> {
                    Toast.makeText(DialogOffsetActivity.this, "评论", Toast.LENGTH_SHORT).show();
                    return true;
                })
                .setOffsetX(dp2px(100))
                .setOffsetY(dp2px(51))
                .show();

2019.05.23日更新

此次更新主要是升级到androidx,然后将内部使用的三方库(support包和recyclerview包)设置成implemention,外部不可访问,用法不变

公众号

欢迎关注我的个人公众号【IT先森养成记】,专注大前端技术分享,包含Android,Java基础,Kotlin,HTML,CSS,JS等技术;在这里你能得到的不止是技术上的提升,还有一些学习经验以及志同道合的朋友,赶快加入我们,一起学习,一起进化吧!!!

公众号:IT先森养成记

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].