|
@@ -1,5 +1,6 @@
|
|
|
package com.cooleshow.teacher.ui.live;
|
|
|
|
|
|
+import android.graphics.drawable.Drawable;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.widget.RadioGroup;
|
|
@@ -9,6 +10,8 @@ import com.cooleshow.teacher.R;
|
|
|
import com.cooleshow.teacher.databinding.FragmentLiveBeautyLayoutBinding;
|
|
|
import com.cooleshow.teacher.widgets.helper.LiveRoomBeautyHelper;
|
|
|
|
|
|
+import androidx.annotation.DrawableRes;
|
|
|
+
|
|
|
/**
|
|
|
* Author by pq, Date on 2022/6/13.
|
|
|
*/
|
|
@@ -30,12 +33,22 @@ public class LiveBeautyOptionsFragment extends BaseFragment<FragmentLiveBeautyLa
|
|
|
} else if (checkedId == R.id.rb_options4) {
|
|
|
type = LiveRoomBeautyHelper.OPTIONS_TYPE4;
|
|
|
}
|
|
|
+ updateCheckStyle(checkedId);
|
|
|
if (mEventListener != null) {
|
|
|
mEventListener.onChangeOptions(type);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ mViewBinding.ivSwitchLiveBeauty.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ LiveRoomBeautyHelper.getInstance().switchBeauty();
|
|
|
+ updateUI();
|
|
|
+ if (mEventListener != null) {
|
|
|
+ mEventListener.onSwitchBeautyMode(LiveRoomBeautyHelper.getInstance().isOpenBeauty());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -44,6 +57,41 @@ public class LiveBeautyOptionsFragment extends BaseFragment<FragmentLiveBeautyLa
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void updateUI() {
|
|
|
+ if (LiveRoomBeautyHelper.getInstance().isOpenBeauty()) {
|
|
|
+ mViewBinding.rbOptions1.setClickable(true);
|
|
|
+ mViewBinding.rbOptions2.setClickable(true);
|
|
|
+ mViewBinding.rbOptions3.setClickable(true);
|
|
|
+ mViewBinding.rbOptions4.setClickable(true);
|
|
|
+ mViewBinding.rgOptions.clearCheck();
|
|
|
+ mViewBinding.ivSwitchLiveBeauty.setImageResource(R.drawable.icon_live_beauty_on);
|
|
|
+ mViewBinding.tvSwitchLiveBeauty.setText("已开启");
|
|
|
+ mViewBinding.rbOptions1.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options1_on), null, null);
|
|
|
+ mViewBinding.rbOptions2.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options2_on), null, null);
|
|
|
+ mViewBinding.rbOptions3.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options3_on), null, null);
|
|
|
+ mViewBinding.rbOptions4.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options4_on), null, null);
|
|
|
+ } else {
|
|
|
+ mViewBinding.ivSwitchLiveBeauty.setImageResource(R.drawable.icon_live_beauty_off);
|
|
|
+ mViewBinding.tvSwitchLiveBeauty.setText("已关闭");
|
|
|
+ mViewBinding.rbOptions1.setClickable(false);
|
|
|
+ mViewBinding.rbOptions2.setClickable(false);
|
|
|
+ mViewBinding.rbOptions3.setClickable(false);
|
|
|
+ mViewBinding.rbOptions4.setClickable(false);
|
|
|
+ mViewBinding.rgOptions.clearCheck();
|
|
|
+ mViewBinding.rbOptions1.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options1_off), null, null);
|
|
|
+ mViewBinding.rbOptions2.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options2_off), null, null);
|
|
|
+ mViewBinding.rbOptions3.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options3_off), null, null);
|
|
|
+ mViewBinding.rbOptions4.setCompoundDrawables(null, getTopDrawable(R.drawable.icon_live_beauty_options4_off), null, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateCheckStyle(int viewId) {
|
|
|
+ mViewBinding.rbOptions1.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions1.getId() ? R.drawable.icon_live_beauty_options1 : R.drawable.icon_live_beauty_options1_on), null, null);
|
|
|
+ mViewBinding.rbOptions2.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions2.getId() ? R.drawable.icon_live_beauty_options2 : R.drawable.icon_live_beauty_options2_on), null, null);
|
|
|
+ mViewBinding.rbOptions3.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions3.getId() ? R.drawable.icon_live_beauty_options3 : R.drawable.icon_live_beauty_options3_on), null, null);
|
|
|
+ mViewBinding.rbOptions4.setCompoundDrawables(null, getTopDrawable(viewId == mViewBinding.rbOptions4.getId() ? R.drawable.icon_live_beauty_options4 : R.drawable.icon_live_beauty_options4_on), null, null);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected FragmentLiveBeautyLayoutBinding getLayoutView() {
|
|
|
return FragmentLiveBeautyLayoutBinding.inflate(getLayoutInflater());
|
|
@@ -55,5 +103,13 @@ public class LiveBeautyOptionsFragment extends BaseFragment<FragmentLiveBeautyLa
|
|
|
|
|
|
public interface OnEventListener {
|
|
|
void onChangeOptions(int type);
|
|
|
+
|
|
|
+ void onSwitchBeautyMode(boolean isOpen);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Drawable getTopDrawable(@DrawableRes int id) {
|
|
|
+ Drawable drawableTop = getResources().getDrawable(id);
|
|
|
+ drawableTop.setBounds(0, 0, drawableTop.getMinimumWidth(), drawableTop.getMinimumHeight());
|
|
|
+ return drawableTop;
|
|
|
}
|
|
|
}
|