# DialogUtil
**Repository Path**: andych008/dialog-util
## Basic Information
- **Project Name**: DialogUtil
- **Description**: 各种功能样式的对话弹窗工具
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2021-12-22
- **Last Updated**: 2021-12-22
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# DialogUtil
common used dialog with material style,ios style,get top ability automatically,can invoke show() everywhere (any thread , any window)
- Original project website: https://github.com/hss01248/DialogUtil
- Original project baseline version: v2.0.2, sha1: 34257a382a1bbd95932f1d0f31405b51d01af5af
[中文ReadMe](README-ch.md)
# important points
* do not abuse loadingdialog:
> the right usage is :
```
first into the page/ability,use the loadingview inside your layout/xml,there is many statelayout lib,
refresh a part of the contentView,or click a button to request http,which has no effect on the whole contentview,then you can use the loadingDialog, just like the ajax in web.
```
# features
* include commo dialogs with material style,ios style
* **support custom dialog** ,just deliver a view. you can retain the buttons and title with ios or material style,or hide them.
* safety :can be invoked in any thread
* when the content is fullScreen ,it can adjust the margin automatically,also support set the **height percent and width percent**
* has a shadow **backgroud** incase of the dimlayer not work,you can also disable it to show your own background in customview
* chained api, easy to use
* adapt to phone and tablet,high and low resolution ratio screen
* support localization
* **support three window types**: as a common dialog ,as a widow with TYPE_TOAST.
* support show **softKeyboard** automatically ,just setNeedSoftKeyboard(true)
* support **ad style** dialog
# effect pics











# useage
## gradle
**Step 1.** Add the maven repository to your build file
Add it in your root build.gradle at the end of repositories:
```
allprojects {
repositories {
...
mavenCentral()
}
}
```
**Step 2.** Add the dependency
```
dependencies {
implementation 'io.github.dzsf:DialogUtil:1.0.0'
}
```
## init
```
//in onStart() of Ability:
StyledDialog.init(this);
```
## demo code( in MainAbilitySlice)
```
//use default style:
StyledDialog.buildLoading().show();
//set some style:
StyledDialog.buildMdAlert("title", msg, new MyDialogListener() {
@Override
public void onFirst() {
showToast("onFirst");
}
@Override
public void onSecond() {
showToast("onSecond");
}
@Override
public void onThird() {
showToast("onThird");
}
})
.setBtnSize(20)
.setBtnText("i","b","3")
.show();
```
# callback
## MyDialogListener
```
public abstract void onFirst();//md-sure button
public abstract void onSecond();//md-cancel button
public void onThird(){}//md-netural button
public void onCancle(){}
/**
* callback for Input
* @param input1
* @param input2
*/
public void onGetInput(CharSequence input1,CharSequence input2){
}
/**
* callback for MdSingleChoose
* @param chosen
* @param chosenTxt
*/
public void onGetChoose(int chosen,CharSequence chosenTxt){
}
/**
* callback for MdMultiChoose
* @param states
*/
public void onChoosen( List selectedIndex, List selectedStrs,boolean[] states){
}
```
## MyItemDialogListener
```
/**
* for IosSingleChoose,BottomItemDialog
* @param text
* @param position
*/
public abstract void onItemClick(CharSequence text, int position);
/**
* for BottomItemDialog
*/
public void onBottomBtnClick(){}
```
# apis
### build different dialogs :StyledDialog.buildxxx:

## set custom style:setXxx

## finally ,you must invoke show(),it returns a dialog pbject
# dismiss
```
StyledDialog.dismiss(DialogInterface... dialogs);
```
## the loading dialog can be dismissed by call :
```
StyledDialog.dismissLoading();
```
### progress dialog
```
/**
* call anywhere
*/
public static void updateProgress( Dialog dialog, int progress, int max, CharSequence msg, boolean isHorizontal)
```
## Versions
- v1.0.0
## Licence
- Apache Licence