package com.sinata.bc_chat.fragment;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import com.bc_chat.bc_base.entity.wallet.NoticeEntity;
import com.makeramen.roundedimageview.RoundedImageView;
import com.sinata.bc_chat.R;
import com.zhaohaoting.framework.utils.glid.GlideUtils;


public class NoticeDialogFragment extends DialogFragment {

    private NoticeEntity noticeEntity;

    public void setNoticeEntity(NoticeEntity noticeEntity) {
        this.noticeEntity = noticeEntity;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (getDialog() != null && getDialog().getWindow() != null) {
            // 设置背景透明
            getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        }
        View view = inflater.inflate(R.layout.notice_dialog, container, false);
        view.findViewById(R.id.tvAdOk).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dissDialog();
            }
        });
        if (noticeEntity != null) {
            RoundedImageView roundImageView = view.findViewById(R.id.ivAdImg);
            GlideUtils.loadCenterCropImage(getContext(), noticeEntity.getPic(), roundImageView);
            TextView tvContent = view.findViewById(R.id.tvContent);
            tvContent.setText(noticeEntity.getContent());
        }

        return view;
    }

    public void dissDialog() {
        this.dismiss();
    }

}
