package com.camnter.newlife.widget;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.camnter.newlife.R;

/**
 * Description：TopicFieldPopWindow
 * Created by：CaMnter
 * Time：2015-12-11 11:31
 */
public class CustomPopupWindow extends android.widget.PopupWindow {

    private Activity activity;

    private View popupWindowView;

    public CustomPopupWindow(Activity activity) {
        super(activity);
        this.activity = activity;
        this.initPopupWindow();
    }

    private void initPopupWindow() {
        LayoutInflater inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.popupWindowView = inflater.inflate(R.layout.popupwindow_topic_field, null);
        setContentView(popupWindowView);
        //设置弹出窗体的宽
        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        //设置弹出窗体的高
        this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        //设置弹出窗体可点击
        setTouchable(true);
        setFocusable(true);
        //
        setOutsideTouchable(true);

        //设置弹出窗体动画效果
        // this.setAnimationStyle(R.style.AnimBottom);
        //实例化一个ColorDrawable颜色为半透明
        ColorDrawable drawable = new ColorDrawable(0x4f000000);
        //设置弹出窗体的背景
        this.setBackgroundDrawable(drawable);
    }


    public static class PopupWindowBuilder {
        private CustomPopupWindow popupWindow;
        public static PopupWindowBuilder ourInstance;

        public static PopupWindowBuilder getInstance(Activity activity) {
            if (ourInstance == null) ourInstance = new PopupWindowBuilder(activity);
            return ourInstance;
        }

        private PopupWindowBuilder(Activity activity) {
            this.popupWindow = new CustomPopupWindow(activity);
        }

        public CustomPopupWindow getPopupWindow() {
            return this.popupWindow;
        }

    }


}
@@ -1291,16 +1291,58 @@
 ottom);%0A
+        this.setAnimationStyle(R.style.);%0A
         
@@ -1368,16 +1368,16 @@
 e%E9%A2%9C%E8%89%B2%E4%B8%BA%E5%8D%8A%E9%80%8F%E6%98%8E%0A
-
         
@@ -1567,16 +1567,23 @@
 private 
+static 
 CustomPo
@@ -1811,32 +1811,91 @@
 lder(activity);%0A
+            popupWindow = new CustomPopupWindow(activity);%0A
             retu
@@ -1981,72 +1981,9 @@
 ) %7B%0A
-            this.popupWindow = new CustomPopupWindow(activity);
 %0A
+
     
@@ -2033,32 +2033,32 @@
 PopupWindow() %7B%0A
+
             retu
@@ -2060,21 +2060,16 @@
  return 
-this.
 popupWin

update CustomPopupWindow