package com.tejia.lijin.app.ui.goldtask;
|
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.content.DialogInterface;
|
import android.graphics.Color;
|
import android.graphics.drawable.GradientDrawable;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.widget.FrameLayout;
|
import android.widget.TextView;
|
|
import com.app.hubert.guide.util.ScreenUtils;
|
import com.wpc.library.util.SystemCommon;
|
import com.tejia.lijin.app.R;
|
import com.tejia.lijin.app.entity.DailySign;
|
import com.tejia.lijin.app.ui.dialog.CopyLinkDialog;
|
import com.tejia.lijin.app.ui.goldtask.view.ProgressBarTime;
|
|
public class SigninTodayDialog extends Dialog {
|
public SigninTodayDialog(Context context) {
|
super(context);
|
this.setCancelable(false);
|
}
|
|
public SigninTodayDialog(Context context, int theme) {
|
super(context, theme);
|
this.setCancelable(false);
|
}
|
|
public static class Builder {
|
private Context context;
|
private DailySign mDailySign;
|
private String positiveButtonText;
|
private String negativeButtonText;
|
private DialogInterface.OnClickListener positiveButtonClickListener;
|
private DialogInterface.OnClickListener negativeButtonClickListener;
|
|
public Builder(Context context) {
|
this.context = context;
|
}
|
|
public SigninTodayDialog.Builder setMessage(DailySign mDailySign) {
|
this.mDailySign = mDailySign;
|
return this;
|
}
|
|
/**
|
* Set the positive button resource and it's listener
|
*
|
* @param positiveButtonText
|
* @return
|
*/
|
public SigninTodayDialog.Builder setPositiveButton(int positiveButtonText,
|
DialogInterface.OnClickListener listener) {
|
this.positiveButtonText = (String) context
|
.getText(positiveButtonText);
|
this.positiveButtonClickListener = listener;
|
return this;
|
}
|
|
public SigninTodayDialog.Builder setPositiveButton(String positiveButtonText,
|
DialogInterface.OnClickListener listener) {
|
this.positiveButtonText = positiveButtonText;
|
this.positiveButtonClickListener = listener;
|
return this;
|
}
|
|
public SigninTodayDialog.Builder setNegativeButton(int negativeButtonText,
|
DialogInterface.OnClickListener listener) {
|
this.negativeButtonText = (String) context
|
.getText(negativeButtonText);
|
this.negativeButtonClickListener = listener;
|
return this;
|
}
|
|
public SigninTodayDialog.Builder setNegativeButton(String negativeButtonText,
|
DialogInterface.OnClickListener listener) {
|
this.negativeButtonText = negativeButtonText;
|
this.negativeButtonClickListener = listener;
|
return this;
|
}
|
|
public CopyLinkDialog create() {
|
LayoutInflater inflater = (LayoutInflater) context
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
// instantiate the dialog with the custom Theme
|
final CopyLinkDialog dialog = new CopyLinkDialog(context, R.style.Dialog1);
|
View layout = inflater.inflate(R.layout.item_signintoday, null);
|
dialog.addContentView(layout, new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
|
|
TextView signintoday_gold = layout.findViewById(R.id.signintoday_gold);// 签到金币
|
ProgressBarTime signintoday_bar = layout.findViewById(R.id.signintoday_bar);//签到进度
|
TextView signintoday_close = layout.findViewById(R.id.signintoday_close);//关闭
|
// 动态改变shape
|
GradientDrawable shape = new GradientDrawable();
|
shape.setCornerRadius(ScreenUtils.dp2px(context, 100));
|
shape.setColor(Color.parseColor("#FF9E00"));
|
//设置大小
|
signintoday_close.setBackground(shape);
|
|
signintoday_bar.setProgressBarTime(mDailySign);
|
signintoday_gold.setText(" + " + mDailySign.goldCoin);
|
|
if (positiveButtonClickListener != null) {
|
signintoday_close.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
positiveButtonClickListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
}
|
});
|
}
|
if (negativeButtonClickListener != null) {
|
// popups_close.setVisibility(View.VISIBLE);//显示第二个按钮
|
signintoday_close.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
negativeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
|
}
|
});
|
}
|
dialog.setContentView(layout);
|
|
android.view.WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
|
params.width = (int) ((SystemCommon.getScreenWidth(context) * 19) / 25);
|
params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
|
dialog.getWindow().setAttributes(params);
|
dialog.setCanceledOnTouchOutside(false);
|
return dialog;
|
}
|
}
|
}
|