-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
loadingdialog/src/main/java/com/android/tu/loadingdialog/LoadingDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.android.tu.loadingdialog; | ||
|
||
import android.app.Dialog; | ||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
/** | ||
* Created by tjy on 2017/6/19. | ||
*/ | ||
public class LoadingDialog extends Dialog{ | ||
|
||
|
||
public LoadingDialog(Context context) { | ||
super(context); | ||
} | ||
|
||
public LoadingDialog(Context context, int themeResId) { | ||
super(context, themeResId); | ||
} | ||
|
||
public static class Builder{ | ||
|
||
private Context context; | ||
private String message; | ||
private boolean isShowMessage=true; | ||
private boolean isCancelable=false; | ||
private boolean isCancelOutside=false; | ||
|
||
|
||
public Builder(Context context) { | ||
this.context = context; | ||
} | ||
|
||
/** | ||
* 设置提示信息 | ||
* @param message | ||
* @return | ||
*/ | ||
|
||
public Builder setMessage(String message){ | ||
this.message=message; | ||
return this; | ||
} | ||
|
||
/** | ||
* 设置是否显示提示信息 | ||
* @param isShowMessage | ||
* @return | ||
*/ | ||
public Builder setShowMessage(boolean isShowMessage){ | ||
this.isShowMessage=isShowMessage; | ||
return this; | ||
} | ||
|
||
/** | ||
* 设置是否可以按返回键取消 | ||
* @param isCancelable | ||
* @return | ||
*/ | ||
|
||
public Builder setCancelable(boolean isCancelable){ | ||
this.isCancelable=isCancelable; | ||
return this; | ||
} | ||
|
||
/** | ||
* 设置是否可以取消 | ||
* @param isCancelOutside | ||
* @return | ||
*/ | ||
public Builder setCancelOutside(boolean isCancelOutside){ | ||
this.isCancelOutside=isCancelOutside; | ||
return this; | ||
} | ||
|
||
public LoadingDialog create(){ | ||
|
||
LayoutInflater inflater = LayoutInflater.from(context); | ||
View view=inflater.inflate(R.layout.dialog_loading,null); | ||
LoadingDialog loadingDailog=new LoadingDialog(context,R.style.MyDialogStyle); | ||
TextView msgText= (TextView) view.findViewById(R.id.tipTextView); | ||
if(isShowMessage){ | ||
msgText.setText(message); | ||
}else{ | ||
msgText.setVisibility(View.GONE); | ||
} | ||
loadingDailog.setContentView(view); | ||
loadingDailog.setCancelable(isCancelable); | ||
loadingDailog.setCanceledOnTouchOutside(isCancelOutside); | ||
return loadingDailog; | ||
|
||
} | ||
|
||
|
||
} | ||
} |