package com.yeshi.makemoney.video.app.ui.dialog;
|
|
import android.app.Activity;
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.content.DialogInterface;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.widget.FrameLayout;
|
import android.widget.TextView;
|
|
import com.androidquery.AQuery;
|
import com.demo.lib.common.util.SystemCommon;
|
import com.yeshi.makemoney.video.R;
|
import com.yeshi.makemoney.video.app.utils.videos.VideoGoldCornUtil;
|
|
|
/**
|
* 用户协议弹框
|
*/
|
public class GoldCornDoubleDialog extends Dialog {
|
|
private static String TAG = "GoldCornDoubleDialog";
|
|
public GoldCornDoubleDialog(Context context) {
|
super(context);
|
this.setCancelable(false);
|
}
|
|
public GoldCornDoubleDialog(Context context, int theme) {
|
super(context, theme);
|
this.setCancelable(false);
|
}
|
|
|
public static class Builder {
|
private Activity context;
|
private GoldCornDoubleCallBack callBack;
|
|
private int goldCorn;
|
|
public Builder(Activity context) {
|
this.context = context;
|
}
|
|
|
public Builder setGoldCorn(int goldCorn) {
|
this.goldCorn = goldCorn;
|
return this;
|
}
|
|
public Builder setCallBack(GoldCornDoubleCallBack callBack) {
|
this.callBack = callBack;
|
return this;
|
}
|
|
public GoldCornDoubleDialog create() {
|
LayoutInflater inflater = (LayoutInflater) context
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
final GoldCornDoubleDialog dialog = new GoldCornDoubleDialog(context, R.style.Dialog);
|
dialog.setCanceledOnTouchOutside(false);
|
final View layout = inflater.inflate(R.layout.dialog_goldcorn_double, null);
|
dialog.addContentView(layout, new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
|
|
AQuery mAquery = new AQuery(layout);
|
mAquery.id(R.id.cb_notify).checked(VideoGoldCornUtil.isDoubleNotify(context));
|
mAquery.id(R.id.tv_goldcorn_old).text(goldCorn + "");
|
mAquery.id(R.id.tv_goldcorn_new).text(goldCorn * 2 + "");
|
mAquery.id(R.id.tv_positive).clicked(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
VideoGoldCornUtil.setDoubleNotify(mAquery.id(R.id.cb_notify).isChecked(), context);
|
if (callBack != null) {
|
callBack.onPositive(!mAquery.id(R.id.cb_notify).isChecked());
|
} else {
|
dialog.dismiss();
|
}
|
}
|
});
|
|
mAquery.id(R.id.iv_close).clicked(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
if (callBack != null) {
|
callBack.onCancel();
|
} else {
|
dialog.dismiss();
|
}
|
}
|
});
|
|
dialog.setContentView(layout);
|
|
android.view.WindowManager.LayoutParams params = dialog.getWindow()
|
.getAttributes();
|
params.width = (int) ((SystemCommon.getScreenWidth(context) * 3) / 4);
|
params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
|
dialog.getWindow().setAttributes(params);
|
return dialog;
|
}
|
}
|
|
public interface GoldCornDoubleCallBack {
|
void onPositive(boolean notify);
|
|
void onCancel();
|
}
|
}
|