Code Monkey home page Code Monkey logo

fingerthandroidutils's Introduction

使用方法

  • Step 1. Add the JitPack repository to your build file
  • Add it in your root build.gradle at the end of repositories:
allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
  • Step 2. Add the dependency
dependencies {
	        compile 'com.github.fingerth:FingerthAndroidUtils:1.0.3'
	}

使用

  • 代码1
SYSDiaLogUtils.showSuccessDialog(this, false);
  • 效果图1

效果图


  • 代码2
SYSDiaLogUtils.showSuccessDialog(this, "操作成功", "恭喜你,操作成功了!", "OK", false);
  • 效果图2

这里写图片描述


  • 代码3
 SYSDiaLogUtils.showInfoDialog(this, "操作提示", "很抱歉,你還不夠硬氣!", "取消", false);
  • 效果图3

这里写图片描述


  • 代码4
 SYSDiaLogUtils.showErrorDialog(this, "錯誤警告", "很抱歉,你這次真的是錯了,請重新試試!", "取消", false);
  • 效果图4

这里写图片描述


  • 代码5
 SYSDiaLogUtils.showSystemProgressDialog(this, "標題", "", false, new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                Toast.makeText(MainActivity.this, "點擊消失", Toast.LENGTH_SHORT).show();
            }
        });
  • 效果图5

这里写图片描述


  • 代码6
SYSDiaLogUtils.showProgressDialog(this, SYSDiaLogUtils.SYSDiaLogType.IosType, "加載中...", false, new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                Toast.makeText(MainActivity.this, "點擊消失", Toast.LENGTH_SHORT).show();
            }
        });
  • 效果图6

这里写图片描述


  • 代码7
SYSDiaLogUtils.showProgressBar(this, "", "", false, new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (SYSDiaLogUtils.getProgressBar() < 100) {
                    if (asyncTaskProgress != null) {
                        asyncTaskProgress.cancel(true);
                    }
                    SYSDiaLogUtils.showErrorDialog(MainActivity.this, "下載失敗", "由於你取消了下載,導致下載失敗!", "確定", false);
                }
            }
        });
        asyncTaskProgress = new AsyncTaskProgress();
        asyncTaskProgress.execute("");
  • 效果图7

这里写图片描述


  • 代码8
SYSDiaLogUtils.showProgressBar(this, SYSDiaLogUtils.SYSDiaLogType.HorizontalWithNumberProgressBar, "正在加載...");
        asyncTaskProgress = new AsyncTaskProgress();
        asyncTaskProgress.execute("");
  • 效果图8

这里写图片描述


  • 代码9
 SYSDiaLogUtils.showProgressBar(this, SYSDiaLogUtils.SYSDiaLogType.RoundWidthNumberProgressBar, "正在加載...");
        asyncTaskProgress = new AsyncTaskProgress();
        asyncTaskProgress.execute("");
  • 效果图9

这里写图片描述


  • 代码10
  SYSDiaLogUtils.showConfirmDialog(this, true, SYSDiaLogUtils.SYSConfirmType.Tip, "標題", "我是提示!", new SYSDiaLogUtils.ConfirmDialogListener() {
            @Override
            public void onClickButton(boolean clickLeft, boolean clickRight) {
                if (clickLeft) {
                    Toast.makeText(MainActivity.this, "left", Toast.LENGTH_SHORT).show();
                } else if (clickRight) {
                    Toast.makeText(MainActivity.this, "right", Toast.LENGTH_SHORT).show();
                }
            }
        });
  • 效果图10

这里写图片描述


  • AsyncTaskProgress 的代码
private AsyncTaskProgress asyncTaskProgress;

 private class AsyncTaskProgress extends AsyncTask<String, Integer, Object> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected Object doInBackground(String... params) {
            for (int i = 0; i < 100; i++) {
                SystemClock.sleep(50);
                publishProgress(i + 1);
            }
            return params;
        }

        @Override
        protected void onProgressUpdate(Integer... values) {
            //horizontal_bar.setProgress(values[0] % 100);
            SYSDiaLogUtils.setProgressBar(values[0] % 100);
            if (values[0] == 100) {
                SYSDiaLogUtils.dismissProgress();
                SYSDiaLogUtils.showSuccessDialog(MainActivity.this, false);
            }
            super.onProgressUpdate(values);
        }

        @Override
        protected void onPostExecute(Object o) {
            super.onPostExecute(o);
        }
    }
}

小结一下

  • 对话框,我一般都用系统提供的了,自定义bug太多,没有Google提供的稳定。
  • 其实我还写了很多方法,代码很简单,入门级。

fingerthandroidutils's People

Contributors

fingerth avatar

Watchers

James Cloos avatar  avatar

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.