HeadDialog.java 3.11 KB
package com.hjx.personalcenter.customdialog;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.hjx.personalcenter.R;
import com.hjx.personalcenter.interfaces.DialogCallBack;
import com.mylhyl.circledialog.BaseCircleDialog;
import com.mylhyl.circledialog.res.values.CircleDimen;

/**
 * Created by h on 2017/8/20.
 */

public class HeadDialog extends BaseCircleDialog implements View.OnClickListener {
    private View mView;
    private TextView oktakephone, cancetakephone;
    private LinearLayout take_pic,xiangce;
    private DialogCallBack.CallBackView mCallBack;
    //默认头像选择
    RadioButton radio_head1,radio_head2,radio_head3,radio_head4;

    public HeadDialog(DialogCallBack.CallBackView callBack) {
        this.mCallBack = callBack;
    }

    public static HeadDialog getInstance(DialogCallBack.CallBackView callBackview) {
        HeadDialog dialogFragment = new HeadDialog(callBackview);
        dialogFragment.setCanceledBack(true);
        dialogFragment.setCanceledOnTouchOutside(false);
        dialogFragment.setRadius(CircleDimen.RADIUS);
        dialogFragment.setWidth(0.4f);
        dialogFragment.setGravity(Gravity.CENTER);
        dialogFragment.setBackgroundColor(Color.WHITE);
        return dialogFragment;
    }

    @Override
    public View createView(Context context, LayoutInflater inflater, ViewGroup container) {

        if (mView == null) {
            mView = inflater.inflate(R.layout.custom_adilog_lhead, container, false);
        }
        return mView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        oktakephone = (TextView) mView.findViewById(R.id.oktakephone);
        cancetakephone = (TextView) mView.findViewById(R.id.canceltakephone);
        take_pic = (LinearLayout) mView.findViewById(R.id.take_pic);
        xiangce = (LinearLayout) mView.findViewById(R.id.xiangce);
        radio_head1 = (RadioButton)mView .findViewById(R.id.radio_head1);
        radio_head2 = (RadioButton)mView .findViewById(R.id.radio_head2);
        radio_head3 = (RadioButton)mView .findViewById(R.id.radio_head3);
        radio_head4 = (RadioButton)mView .findViewById(R.id.radio_head4);
        oktakephone.setOnClickListener(this);
        cancetakephone.setOnClickListener(this);
        take_pic.setOnClickListener(this);
        xiangce.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        int headweizhi;
        if (radio_head1.isChecked()){
            headweizhi =1;
        } else if (radio_head2.isChecked()) {
            headweizhi =2;
        }else if (radio_head3.isChecked()) {
            headweizhi =3;
        }else if (radio_head4.isChecked()) {
            headweizhi =4;
        }else  {
            headweizhi =0;
        }
        mCallBack.heard(getActivity(), v,headweizhi);
        dismiss();
    }
}