package com.ysvideo.zhibo.app.ui.dialog;
|
|
import android.app.Activity;
|
import android.app.Dialog;
|
import android.content.Context;
|
import android.graphics.Color;
|
import android.graphics.drawable.GradientDrawable;
|
import android.view.Gravity;
|
import android.view.View;
|
import android.widget.LinearLayout;
|
import android.widget.TextView;
|
|
import com.ysvideo.zhibo.app.R;
|
import com.ysvideo.zhibo.lib.common.util.SystemCommon;
|
import com.ysvideo.zhibo.lib.common.util.common.DimenUtils;
|
|
/**
|
* 用户协议弹框
|
*/
|
public class BrowserMoreDialog extends Dialog {
|
|
private static String TAG = "InputTextDialog";
|
|
public BrowserMoreDialog(Context context) {
|
super(context);
|
this.setCancelable(false);
|
}
|
|
public BrowserMoreDialog(Context context, int theme) {
|
super(context, theme);
|
this.setCancelable(false);
|
}
|
|
|
public static class Builder {
|
|
private Activity context;
|
private IActionListener actionListener;
|
|
|
public Builder(Activity context) {
|
this.context = context;
|
}
|
|
public Builder setActionListener(IActionListener actionListener) {
|
this.actionListener = actionListener;
|
return this;
|
}
|
|
|
public BrowserMoreDialog create() {
|
final BrowserMoreDialog dialog = new BrowserMoreDialog(context, R.style.Dialog);
|
dialog.setCanceledOnTouchOutside(true);
|
LinearLayout linearLayout = new LinearLayout(context);
|
linearLayout.setGravity(Gravity.CENTER);
|
GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, new int[]{Color.parseColor("#333333"), Color.parseColor("#333333")});
|
int radius = DimenUtils.dip2px(context, 16);
|
gradientDrawable.setCornerRadii(new float[]{radius, radius, radius, radius, 0, 0, 0, 0});
|
linearLayout.setBackground(gradientDrawable);
|
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
TextView textView = new TextView(context);
|
textView.setCompoundDrawablePadding(DimenUtils.dip2px(context, 6));
|
textView.setText("刷新");
|
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_more_refresh, 0, 0, 0);
|
textView.setTextSize(15.0f);
|
textView.setTextColor(Color.WHITE);
|
textView.setGravity(Gravity.CENTER);
|
textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, DimenUtils.dip2px(context, 40)));
|
textView.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
if (actionListener != null)
|
actionListener.onRefresh();
|
}
|
});
|
linearLayout.addView(textView);
|
|
textView = new TextView(context);
|
textView.setCompoundDrawablePadding(DimenUtils.dip2px(context, 6));
|
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_more_copy, 0, 0, 0);
|
textView.setText("复制链接");
|
textView.setTextSize(15.0f);
|
textView.setTextColor(Color.WHITE);
|
textView.setGravity(Gravity.CENTER);
|
textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, DimenUtils.dip2px(context, 40)));
|
textView.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
if (actionListener != null)
|
actionListener.copyLink();
|
}
|
});
|
linearLayout.addView(textView);
|
|
textView = new TextView(context);
|
|
textView.setCompoundDrawablePadding(DimenUtils.dip2px(context, 6));
|
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.icon_more_browser, 0, 0, 0);
|
textView.setText("其他浏览器打开");
|
textView.setTextSize(15.0f);
|
textView.setTextColor(Color.WHITE);
|
textView.setGravity(Gravity.CENTER);
|
textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, DimenUtils.dip2px(context, 40)));
|
textView.setOnClickListener(new View.OnClickListener() {
|
@Override
|
public void onClick(View v) {
|
if (actionListener != null)
|
actionListener.openInBrowser();
|
}
|
});
|
linearLayout.addView(textView);
|
|
|
dialog.setContentView(linearLayout);
|
|
android.view.WindowManager.LayoutParams params = dialog.getWindow()
|
.getAttributes();
|
params.width = (int) (SystemCommon.getScreenWidth(context));
|
params.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
|
params.gravity = Gravity.BOTTOM;
|
dialog.getWindow().setAttributes(params);
|
return dialog;
|
}
|
|
|
}
|
|
public static interface IActionListener {
|
public void onRefresh();
|
|
public void copyLink();
|
|
public void openInBrowser();
|
}
|
|
}
|