package ai.pai.client.views;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.widget.ImageView;

import com.android.views.PhotoView.UrlTouchImageView;
import com.android.views.popup.BasePopupWindow;

import ai.pai.client.R;
import ai.pai.client.utils.GroupCreateUtils;

/**
 * Created by chengzhenyu on 2016/3/4.
 */
public class FullScreenImgPopup extends BasePopupWindow {

    private View popupView;
    private String imgUrl;
    private UrlTouchImageView fullScreenImg;
    private ImageView backImg;
    private Context context;


    public FullScreenImgPopup(Activity context, String imgUrl) {
        super(context);
        this.imgUrl = imgUrl;
        this.context = context;
        init();
    }

    @Override
    protected Animation getShowAnimation() {
        return getDefaultScaleAnimation();
    }

    @Override
    protected View getClickToDismissView() {
        return popupView.findViewById(R.id.click_to_dismiss);
    }

    @Override
    public View getPopupView() {
        popupView = LayoutInflater.from(mContext).inflate(R.layout.pop_full_screen_img, null);
        fullScreenImg = (UrlTouchImageView) popupView.findViewById(R.id.iv_full_screen_img);
        backImg = (ImageView)popupView.findViewById(R.id.iv_pop_back);
        return popupView;
    }

    private void init() {
        fullScreenImg.setUrl(imgUrl);
        backImg.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    @Override
    public View getAnimaView() {
        return popupView.findViewById(R.id.popup_anima);
    }

}
