Skip to content

Commit

Permalink
修改拼写bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gittjy committed Jun 19, 2017
1 parent eec1413 commit f48fe23
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.view.View;
import android.widget.Button;

import com.android.tu.loadingdialog.LoadingDailog;
import com.android.tu.loadingdialog.LoadingDialog;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

Expand All @@ -27,10 +27,10 @@ protected void onCreate(Bundle savedInstanceState) {
public void onClick(View view) {
switch (view.getId()){
case R.id.style1_btn:
LoadingDailog.Builder builder1=new LoadingDailog.Builder(MainActivity.this)
LoadingDialog.Builder builder1=new LoadingDialog.Builder(MainActivity.this)
.setMessage("加载中...")
.setCancelable(false);
final LoadingDailog dialog1=builder1.create();
final LoadingDialog dialog1=builder1.create();
dialog1.show();
handler.postDelayed(new Runnable() {
@Override
Expand All @@ -40,10 +40,10 @@ public void run() {
},2000);
break;
case R.id.style2_btn:
LoadingDailog.Builder builder2=new LoadingDailog.Builder(MainActivity.this)
LoadingDialog.Builder builder2=new LoadingDialog.Builder(MainActivity.this)
.setShowMessage(false)
.setCancelable(false);
final LoadingDailog dialog2=builder2.create();
final LoadingDialog dialog2=builder2.create();
dialog2.show();
handler.postDelayed(new Runnable() {
@Override
Expand Down
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;

}


}
}

0 comments on commit f48fe23

Please sign in to comment.