package com.cooleshow.teacher.ui.live;

import android.view.View;
import android.widget.RadioGroup;

import com.cooleshow.base.ui.fragment.BaseFragment;
import com.cooleshow.teacher.R;
import com.cooleshow.teacher.databinding.FragmentBeautyFilterLayoutBinding;
import com.cooleshow.teacher.databinding.FragmentLiveBeautyLayoutBinding;
import com.cooleshow.teacher.widgets.helper.LiveRoomBeautyHelper;

/**
 * Author by pq, Date on 2022/6/13.
 */
public class LiveBeautyFilterFragment extends BaseFragment<FragmentBeautyFilterLayoutBinding> implements View.OnClickListener {
    private OnEventListener mEventListener;

    @Override
    protected void initView(View rootView) {
        mViewBinding.rgOptions.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                int type = LiveRoomBeautyHelper.FILTER_TYPE_NONE;
                mViewBinding.tvNoFilter.setSelected(false);
                if (checkedId == R.id.rb_options1) {
                    type = LiveRoomBeautyHelper.FILTER_TYPE1;
                } else if (checkedId == R.id.rb_options2) {
                    type = LiveRoomBeautyHelper.FILTER_TYPE2;
                } else if (checkedId == R.id.rb_options3) {
                    type = LiveRoomBeautyHelper.FILTER_TYPE3;
                }
                LiveRoomBeautyHelper.getInstance().updateFilterMode(type);
            }
        });
        mViewBinding.ivNoFilter.setOnClickListener(this);
        mViewBinding.tvNoFilter.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }


    @Override
    protected FragmentBeautyFilterLayoutBinding getLayoutView() {
        return FragmentBeautyFilterLayoutBinding.inflate(getLayoutInflater());
    }

    public void setOnEventListener(OnEventListener listener) {
        this.mEventListener = listener;
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        switch (id) {
            case R.id.iv_no_filter:
            case R.id.tv_no_filter:
                //无滤镜
                mViewBinding.rgOptions.clearCheck();
                mViewBinding.tvNoFilter.setSelected(true);
                LiveRoomBeautyHelper.getInstance().updateFilterMode(LiveRoomBeautyHelper.FILTER_TYPE_NONE);
                break;
        }
    }

    public interface OnEventListener {
        void onChangeOptions(int type);
    }
}
