package com.taoke.autopay.android.ui.dialog;
|
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.widget.FrameLayout;
|
|
import com.taoke.autopay.android.R;
|
import com.taoke.autopay.android.utils.SystemUtil;
|
|
|
/**
|
* Created by weikou2015 on 2017/2/28.
|
*/
|
|
public class OrderProcessNotifyDialog extends Dialog {
|
|
public OrderProcessNotifyDialog(Context context) {
|
super(context);
|
this.setCancelable(false);
|
}
|
|
public OrderProcessNotifyDialog(Context context, int theme) {
|
super(context, theme);
|
this.setCancelable(false);
|
}
|
|
|
public static class Builder {
|
private Context context;
|
|
String title;
|
private OnClickListener positiveButtonClickListener;
|
private OnClickListener negativeButtonClickListener;
|
|
public Builder(Context context) {
|
this.context = context;
|
}
|
|
|
public Builder setTitle(String title) {
|
this.title = title;
|
return this;
|
}
|
|
|
public Builder setPositiveButton(OnClickListener listener) {
|
|
this.positiveButtonClickListener = listener;
|
return this;
|
}
|
|
public Builder setNegativeButton(OnClickListener listener) {
|
this.negativeButtonClickListener = listener;
|
return this;
|
}
|
|
|
public OrderProcessNotifyDialog create() {
|
|
LayoutInflater inflater = (LayoutInflater) context
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
// instantiate the dialog with the custom Theme
|
final OrderProcessNotifyDialog dialog = new OrderProcessNotifyDialog(context, R.style.Dialog);
|
View layout = inflater.inflate(R.layout.dialog_order_process, null);
|
dialog.addContentView(layout, new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
|
layout.findViewById(R.id.button_reject)
|
.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
dialog.dismiss();
|
if(negativeButtonClickListener!=null){
|
negativeButtonClickListener.onClick(dialog,0);
|
}
|
}
|
});
|
layout.findViewById(R.id.button_agree)
|
.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
dialog.dismiss();
|
if(positiveButtonClickListener!=null){
|
positiveButtonClickListener.onClick(dialog,0);
|
}
|
}
|
});
|
layout.findViewById(R.id.iv_clode)
|
.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
dialog.dismiss();
|
}
|
});
|
|
dialog.setContentView(layout);
|
|
android.view.WindowManager.LayoutParams params = dialog.getWindow()
|
.getAttributes();
|
params.width = (int) ((SystemUtil.getScreenWidth(context) * 3) / 4);
|
params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
|
dialog.getWindow().setAttributes(params);
|
return dialog;
|
}
|
}
|
}
|