Git Product home page Git Product logo

okdialog's Introduction

一、概述

通用Dialog,适用于ProgressDialog,BuilderDialog,可以设置字体、进入退出动画。

二、版本

OkDialog已上传jcenter,直接在gradle中添加依赖即可。 compile 'com.hengda.zwf:OkDialog:0.0.1'

三、效果

1、ProgressDialog补间动画

2、ProgressDialog帧动画

3、BuilderDialog默认布局

4、BuilderDialog自定义布局

四、使用

此处以BuilderDialog自定义布局为例,简单介绍说使用,具体用法参见demo。 地址:https://github.com/Tailyou/OkDialog

    /**
     * 该方法通过提取文字参数和点击事件可以继续封装
     *
     * @author 祝文飞(Tailyou)
     * @time 2017/2/6 9:37
     */
    private void showCustomDlg() {
        HDialogBuilder hDialogBuilder = new HDialogBuilder(mContext);

        View customView = View.inflate(mContext, R.layout.dialog_custom_view_all, null);
        TextView tvTitle = HdTool.getView(customView, R.id.tvTitle);
        TextView tvMsg = HdTool.getView(customView, R.id.tvMsg);
        TextView btnYes = HdTool.getView(customView, R.id.btnYes);
        TextView btnNo = HdTool.getView(customView, R.id.btnNo);
        tvTitle.setText("注销");
        tvMsg.setText("退出账号可能会使连续登录记录归零,确定退出?");
        btnYes.setText("确定退出");
        btnNo.setText("取消");
        btnYes.setOnClickListener(v -> hDialogBuilder.dismiss());
        btnNo.setOnClickListener(v -> hDialogBuilder.dismiss());

        hDialogBuilder.setCustomView(customView)
                .dlgColor(Color.TRANSPARENT)
                .cancelable(false)
                .show();
    }

封装后:

    private void showCustomDlg(String title, String msg, String txtYes, String txtNo,
                               DialogClickListener dialogClickListener) {
        hDialogBuilder = new HDialogBuilder(mContext);

        View customView = View.inflate(mContext, R.layout.dialog_custom_view_all, null);
        TextView tvTitle = HdTool.getView(customView, R.id.tvTitle);
        TextView tvMsg = HdTool.getView(customView, R.id.tvMsg);
        TextView btnYes = HdTool.getView(customView, R.id.btnYes);
        TextView btnNo = HdTool.getView(customView, R.id.btnNo);
        tvTitle.setText(title);
        tvMsg.setText(msg);
        btnYes.setText(txtYes);
        btnNo.setText(txtNo);
        btnYes.setOnClickListener(v -> dialogClickListener.p());
        btnNo.setOnClickListener(v -> dialogClickListener.n());

        hDialogBuilder.setCustomView(customView)
                        .dlgColor(Color.TRANSPARENT)
                        .cancelable(false)
                        .show();
    }

封装好之后,可以写到工具类中供直接调用.

/**
 * 作者:Tailyou (祝文飞)
 * 时间:2016/5/26 19:03
 * 邮箱:[email protected]
 * 描述:Dialog工具类
 */
public class DialogCenter {

    private static HDialogBuilder hDialogBuilder;

    /**
     * 封装好的方法可以写到DialogCenter工具类中,供直接调用
     *
     * @author 祝文飞(Tailyou)
     * @time 2017/2/6 9:39
     */
    public static void showCustomDlg(Context mContext, String title, String msg, String txtYes, String txtNo,
                               DialogClickListener dialogClickListener) {
        hideDialog();
        hDialogBuilder = new HDialogBuilder(mContext);

        View customView = View.inflate(mContext, R.layout.dialog_custom_view_all, null);
        TextView tvTitle = HdTool.getView(customView, R.id.tvTitle);
        TextView tvMsg = HdTool.getView(customView, R.id.tvMsg);
        TextView btnYes = HdTool.getView(customView, R.id.btnYes);
        TextView btnNo = HdTool.getView(customView, R.id.btnNo);
        tvTitle.setText(title);
        tvMsg.setText(msg);
        btnYes.setText(txtYes);
        btnNo.setText(txtNo);
        btnYes.setOnClickListener(v -> dialogClickListener.p());
        btnNo.setOnClickListener(v -> dialogClickListener.n());

        hDialogBuilder.setCustomView(customView)
                        .dlgColor(Color.TRANSPARENT)
                        .cancelable(false)
                        .show();
    }

    /**
     * 隐藏Dialog
     */
    public static void hideDialog() {
        if (hDialogBuilder != null) {
            hDialogBuilder.dismiss();
            hDialogBuilder = null;
        }
    }

}

okdialog's People

Contributors

tailyou avatar

Stargazers

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

Watchers

 avatar

Forkers

cbdgit saymiss

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.