Giter Site home page Giter Site logo

lvtravler / android-dialog Goto Github PK

View Code? Open in Web Editor NEW
42.0 4.0 9.0 2.2 MB

Android Dialog(BaseDialog、AlertDialog、ProgressDialog、SuccessDdialog、ErrorDialog、BottomDialog)

Home Page: https://www.jianshu.com/p/92da769d3b0f

License: Apache License 2.0

Java 100.00%
dialogfragment alertdialog dialog alert progressbar progressdialog statusdialog successdialog errordialog androiddialog bottomdialog

android-dialog's Introduction

Android-Dialog

基于DialogFragment实现的Dialog,有以下几点优势:

  1. 异常情况状态自动保存
  2. show、dismiss等严格被Fragment生命周期托管,不会出现内存泄露
  3. 支持自定义,扩展性高

Show

AlertDialog:

AlertDialog

ProgressDialog:

ProgressDialog

SuccessDialog:

SuccessDialog

ErrorDialog:

ErrorDialog

BottomDialog:

BottomDialog Usage

   public void showAlertDialog() {
        AlertDialog.with(MainActivity.this)
                .setCancelable(true)
                .setContent("Android Alert DialogFragment Content")
                .setTitle("AlertDialog Title")
                .setPositiveButton("success", new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        showSuccessDialog();
                    }
                }).setNegativeButton("error", new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showErrorDialog();
            }
        }).show();
    }

    public void showErrorDialog() {
        StatusDialog.with(MainActivity.this)
                .setCancelable(false)
                .setPrompt("load error")
                .setType(StatusDialog.Type.ERROR)
                .show();
    }

    public void showSuccessDialog() {
        StatusDialog.with(MainActivity.this)
                .setCancelable(false)
                .setPrompt("load success")
                .setType(StatusDialog.Type.SUCCESS)
                .show();
    }

    public void showProgressDialog() {
        StatusDialog.with(MainActivity.this)
                .setCancelable(false)
                .setPrompt("loading…")
                .setType(StatusDialog.Type.PROGRESS)
                .show();
    }
    
   public void showItemDialog() {
        List<ItemBean> itemBeanList = Utils.getItemBeanList();
        ItemDialog.with(MainActivity.this)
                .setCancelable(true)
                .setData(itemBeanList)
                .setOnItemClickListener(new ItemDialog.OnItemClickListener() {
                    @Override
                    public void onItemClick(int position, ItemBean itemData) {
                        showSuccessDialog();
                    }
                })
                .setSpanCount(itemBeanList.size())
                .setAnimations(R.style.Dialog_Anim_Bottom_In_Bottom_Out)
                .setGravity(Gravity.BOTTOM)
                .setShowType(ItemDialog.ShowType.GRID)
                .show();
    }

It feels good,Please Star,Thank you!

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.