package com.weikou.beibeivideo.ui.dialog;
|
|
import android.app.Activity;
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.content.DialogInterface;
|
import android.graphics.Color;
|
import android.text.method.LinkMovementMethod;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.widget.FrameLayout;
|
import android.widget.TextView;
|
|
import com.lcjian.library.util.SystemCommon;
|
import com.lcjian.library.util.common.StringUtils;
|
import com.weikou.beibeivideo.R;
|
import com.weikou.beibeivideo.util.ui.TextViewUtil;
|
|
/**
|
* 权限请求之前的弹框
|
*/
|
public class PermissionAuthNotifyDialog extends Dialog {
|
|
private static String TAG = "UserProtocolDialog";
|
|
public PermissionAuthNotifyDialog(Context context) {
|
super(context);
|
this.setCancelable(false);
|
}
|
|
public PermissionAuthNotifyDialog(Context context, int theme) {
|
super(context, theme);
|
this.setCancelable(false);
|
}
|
|
|
public static class Builder {
|
public final static int TEXT_ALIGIN_LEFT = 1;
|
public final static int TEXT_ALIGIN_MIDDLE = 2;
|
public final static int TEXT_ALIGIN_RIGHT = 3;
|
|
private Activity context;
|
String webviewData;
|
String title;
|
private String positiveButtonText;
|
private String negativeButtonText;
|
private OnClickListener positiveButtonClickListener;
|
private OnClickListener negativeButtonClickListener;
|
|
public Builder(Activity context) {
|
this.context = context;
|
}
|
|
|
public Builder setPositiveButton(String positiveButtonText,
|
OnClickListener listener) {
|
this.positiveButtonText = positiveButtonText;
|
this.positiveButtonClickListener = listener;
|
return this;
|
}
|
|
public PermissionAuthNotifyDialog create() {
|
LayoutInflater inflater = (LayoutInflater) context
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
final PermissionAuthNotifyDialog dialog = new PermissionAuthNotifyDialog(context, R.style.Dialog);
|
dialog.setCanceledOnTouchOutside(false);
|
final View layout = inflater.inflate(R.layout.dialog_auth_notify, null);
|
dialog.addContentView(layout, new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
|
TextView tv_positive = layout.findViewById(R.id.tv_positive);
|
|
|
|
// set the confirm button
|
if (positiveButtonClickListener != null) {
|
if (!StringUtils.isEmpty(positiveButtonText))
|
tv_positive.setText(positiveButtonText);
|
tv_positive.setOnClickListener(new View.OnClickListener() {
|
public void onClick(View v) {
|
positiveButtonClickListener.onClick(dialog,
|
DialogInterface.BUTTON_POSITIVE);
|
}
|
});
|
}
|
|
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 MeasureCallBack {
|
public void onMeasure(int height);
|
}
|
}
|