diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java index 46cb20f4d..004b52187 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java @@ -2,35 +2,24 @@ package com.yunbao.faceunity; import static android.content.Context.SENSOR_SERVICE; -import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; - import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.hardware.Camera; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; -import android.opengl.GLSurfaceView; import android.os.Environment; import android.util.Log; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import com.faceunity.core.callback.OperateCallback; -import com.faceunity.core.entity.FURenderFrameData; -import com.faceunity.core.entity.FURenderInputData; import com.faceunity.core.entity.FURenderOutputData; import com.faceunity.core.enumeration.CameraFacingEnum; import com.faceunity.core.enumeration.FUAIProcessorEnum; import com.faceunity.core.enumeration.FUInputTextureEnum; import com.faceunity.core.enumeration.FUTransformMatrixEnum; -import com.faceunity.core.faceunity.FURenderKit; import com.faceunity.core.faceunity.FURenderManager; -import com.faceunity.core.listener.OnGlRendererListener; -import com.faceunity.core.renderer.CameraRenderer; import com.faceunity.core.utils.CameraUtils; import com.faceunity.core.utils.FULogger; import com.yunbao.faceunity.data.FaceUnityDataFactory; @@ -39,23 +28,17 @@ import com.yunbao.faceunity.ui.FaceUnityView; import com.yunbao.faceunity.utils.Authpack; import com.yunbao.faceunity.utils.CSVUtils; import com.yunbao.faceunity.utils.FURenderer; -import com.yunbao.faceunity.utils.FaceCameraConfig; import com.yunbao.faceunity.utils.FaceUnityData; import com.yunbao.faceunity.utils.net.OkHttpUtils; import java.io.File; -import java.io.FileOutputStream; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.Date; import java.util.Locale; import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.callback.IRCRTCVideoOutputFrameListener; -import cn.rongcloud.rtc.api.stream.RCRTCVideoView; import cn.rongcloud.rtc.base.RCRTCVideoFrame; -import cn.rongcloud.rtc.core.EglRenderer; -import io.rong.callkit.SingleCallActivity; /** * 美颜模块管理类,接入测试中 @@ -64,6 +47,7 @@ public class FaceManager implements SensorEventListener { private static boolean isInit = false; private static final String TAG = FaceManager.class.getSimpleName(); private FaceUnityDataFactory mFaceUnityDataFactory; + private FaceManager.FaceStatusChanged faceStatusChanged; /** * 初始化美颜模块,在AppContext中调用 @@ -72,7 +56,7 @@ public class FaceManager implements SensorEventListener { if (isInit) { return; } - FaceUnityData.mApplication=context; + FaceUnityData.mApplication = context; OkHttpUtils.getInstance().init(context, false); FURenderManager.setCoreDebug(FULogger.LogLevel.OFF); FURenderManager.setKitDebug(FULogger.LogLevel.OFF); @@ -91,6 +75,7 @@ public class FaceManager implements SensorEventListener { } private FURenderer mFURenderer; + private FaceUnityView faceUnityView; /** * 配置美颜SDK @@ -115,8 +100,13 @@ public class FaceManager implements SensorEventListener { /** * 绑定控制view */ - public void bindControlView(FaceUnityView view){ - view.bindDataFactory(mFaceUnityDataFactory); + public void bindControlView(FaceUnityView view) { + this.faceUnityView = view; + faceUnityView.bindDataFactory(mFaceUnityDataFactory); + } + + public void setFaceStatusChanged(FaceStatusChanged faceStatusChanged) { + this.faceStatusChanged = faceStatusChanged; } private boolean mIsFirstFrame = true; @@ -193,12 +183,16 @@ public class FaceManager implements SensorEventListener { @Override public void onTrackStatusChanged(FUAIProcessorEnum type, int status) { Log.e(TAG, "onTrackStatusChanged: 人脸数: " + status); + if (faceStatusChanged != null) { + faceStatusChanged.onFaceChanged(status); + } + } @Override public void onFpsChanged(double fps, double callTime) { final String FPS = String.format(Locale.getDefault(), "%.2f", fps); - // Log.d(TAG, "onFpsChanged FPS: " + FPS + ", callTime: " + String.format("%.2f", callTime)); + // Log.d(TAG, "onFpsChanged FPS: " + FPS + ", callTime: " + String.format("%.2f", callTime)); } @Override @@ -218,10 +212,15 @@ public class FaceManager implements SensorEventListener { } + /** * 离开渲染界面时注销融云监听器,不然会绿屏 */ public void onClose() { RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(null); } + + public interface FaceStatusChanged { + void onFaceChanged(int num); + } } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/ContainerRecyclerAdapter.java b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/ContainerRecyclerAdapter.java index b00235a82..e57c4b8ca 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/ContainerRecyclerAdapter.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/ContainerRecyclerAdapter.java @@ -4,6 +4,7 @@ import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; @@ -71,16 +72,17 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter list) { @@ -221,17 +224,21 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter { adapter.getAnimojiDataFactory().onAnimojiSelected((AnimojiBean) itemView.getTag()); - setSelectPosition(getAdapterPosition()); + setSelectPosition(getLayoutPosition()); saveData(); }); } @@ -44,21 +44,26 @@ public class AnimojiViewHolder extends BaseViewHolder { @Override public boolean loadData() { String data = adapter.getString(getName(this)); - if (data != null) { - icon.setSelected(getAdapterPosition() == Integer.parseInt(data)); - return true; + if (data == null) { + return false; } + if (!data.equals(String.valueOf(getLayoutPosition()))) { + return false; + } + icon.setSelected(true); + adapter.getAnimojiDataFactory().onAnimojiSelected((AnimojiBean) itemView.getTag()); return false; } @Override public void saveData() { - adapter.save(getName(this), String.valueOf(getAdapterPosition())); + adapter.save(getName(this), String.valueOf(getLayoutPosition())); } @Override public void reset(List list) { adapter.del(getName(this)); + adapter.getAnimojiDataFactory().onAnimojiSelected((AnimojiBean) list.get(0)); adapter.setSelectPosition(0); } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/BigHeadViewHolder.java b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/BigHeadViewHolder.java index 567293887..a79337fbc 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/BigHeadViewHolder.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/BigHeadViewHolder.java @@ -69,7 +69,8 @@ public class BigHeadViewHolder extends BaseViewHolder { @Override public void reset(List list) { adapter.del(getName(this)); - itemView.callOnClick(); + adapter.getPropDataFactory().setPropType(FunctionEnum.BIG_HEAD); + adapter.getPropDataFactory().onItemSelected((PropBean) list.get(0)); adapter.setSelectPosition(0); } } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupCustomItemViewHolder.java b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupCustomItemViewHolder.java index 58cee9fdc..172efd280 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupCustomItemViewHolder.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupCustomItemViewHolder.java @@ -15,6 +15,9 @@ import com.yunbao.faceunity.seekbar.DiscreteSeekBar; import java.util.List; +/** + * 美妆 - 自定义 + */ public class MakeupCustomItemViewHolder extends BaseViewHolder { private ImageView icon; private TextView title; diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupViewHolder.java b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupViewHolder.java index acc0bde3b..604b9239e 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupViewHolder.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/MakeupViewHolder.java @@ -9,6 +9,7 @@ import androidx.annotation.NonNull; import com.yunbao.faceunity.R; import com.yunbao.faceunity.entity.BaseBean; import com.yunbao.faceunity.entity.MakeupCombinationBean; +import com.yunbao.faceunity.utils.FaceSPUtils; import java.util.List; @@ -72,6 +73,10 @@ public class MakeupViewHolder extends BaseViewHolder { @Override public void reset(Listlist) { - + adapter.del(getName(this)); + FaceSPUtils.getInstance().delStart("MakeupCustomItemViewHolder"); + adapter.getMakeupDataFactory().onMakeupCombinationSelected((MakeupCombinationBean) list.get(0)); + adapter.getMakeupDataFactory().clearAll(); + adapter.setSelectPosition(0); } } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/StickerViewHolder.java b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/StickerViewHolder.java index efdaced34..edc5ba70f 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/StickerViewHolder.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/adapters/vh/StickerViewHolder.java @@ -68,7 +68,8 @@ public class StickerViewHolder extends BaseViewHolder{ @Override public void reset(List list) { adapter.del(getName(this)); - itemView.callOnClick(); + adapter.getPropDataFactory().setPropType(FunctionEnum.STICKER); + adapter.getPropDataFactory().onItemSelected((PropBean) list.get(0)); adapter.setSelectPosition(0); } } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/data/BodyBeautyDataFactory.java b/FaceUnity/src/main/java/com/yunbao/faceunity/data/BodyBeautyDataFactory.java index 29431f5bc..6a7cb088c 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/data/BodyBeautyDataFactory.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/data/BodyBeautyDataFactory.java @@ -2,6 +2,8 @@ package com.yunbao.faceunity.data; import com.faceunity.core.controller.bodyBeauty.BodyBeautyParam; import com.faceunity.core.entity.FUBundleData; +import com.faceunity.core.enumeration.FUAITypeEnum; +import com.faceunity.core.faceunity.FUAIKit; import com.faceunity.core.faceunity.FURenderKit; import com.faceunity.core.model.bodyBeauty.BodyBeauty; @@ -9,6 +11,7 @@ import com.yunbao.faceunity.entity.BodyBeautyBean; import com.yunbao.faceunity.entity.ModelAttributeData; import com.yunbao.faceunity.infe.AbstractBodyBeautyDataFactory; import com.yunbao.faceunity.repo.BodyBeautySource; +import com.yunbao.faceunity.utils.FaceUnityConfig; import java.util.ArrayList; import java.util.HashMap; @@ -31,13 +34,14 @@ public class BodyBeautyDataFactory extends AbstractBodyBeautyDataFactory { /*渲染控制器*/ - private final FURenderKit mFURenderKit = FURenderKit.getInstance(); + private FURenderKit mFURenderKit = FURenderKit.getInstance(); + private FUAIKit mFUAIKit = FUAIKit.getInstance(); /*美体数据模型*/ public final BodyBeauty bodyBeauty; public BodyBeautyDataFactory() { - bodyBeauty = new BodyBeauty(new FUBundleData(BodyBeautySource.BUNDLE_BODY_BEAUTY)); + bodyBeauty = new BodyBeauty(new FUBundleData(FaceUnityConfig.BUNDLE_BODY_BEAUTY)); } @@ -90,6 +94,13 @@ public class BodyBeautyDataFactory extends AbstractBodyBeautyDataFactory { } } + @Override + public void enableBodyBeauty(boolean enable) { + if (mFURenderKit.getBodyBeauty() != null) { + mFURenderKit.getBodyBeauty().setEnable(enable); + } + } + /** * 获取当前模型 * @@ -99,22 +110,11 @@ public class BodyBeautyDataFactory extends AbstractBodyBeautyDataFactory { return bodyBeauty; } - /** - * 美体开关设置 - * - * @param enable - */ - @Override - public void enableBodyBeauty(boolean enable) { - if (mFURenderKit.getBodyBeauty() != null) { - mFURenderKit.getBodyBeauty().setEnable(enable); - } - } /*模型映射设置模型值*/ private final HashMap bodyBeautySetMapping = new HashMap() { { - put(BodyBeautyParam.BODY_SLIM_INTENSITY, value -> getCurrentBodyBeautyModel().setBodySlimIntensity(value)); + put(BodyBeautyParam.BODY_SLIM_INTENSITY, value -> getCurrentBodyBeautyModel().setBodySlimIntensity(value)); put(BodyBeautyParam.LEG_STRETCH_INTENSITY, value -> getCurrentBodyBeautyModel().setLegStretchIntensity(value)); put(BodyBeautyParam.WAIST_SLIM_INTENSITY, value -> getCurrentBodyBeautyModel().setWaistSlimIntensity(value)); put(BodyBeautyParam.SHOULDER_SLIM_INTENSITY, value -> getCurrentBodyBeautyModel().setShoulderSlimIntensity(value)); @@ -127,13 +127,13 @@ public class BodyBeautyDataFactory extends AbstractBodyBeautyDataFactory { /*模型映射获取模型值*/ HashMap bodyBeautyGetMapping = new HashMap() { { - put(BodyBeautyParam.BODY_SLIM_INTENSITY, () -> getCurrentBodyBeautyModel().getBodySlimIntensity()); - put(BodyBeautyParam.LEG_STRETCH_INTENSITY, () -> getCurrentBodyBeautyModel().getLegStretchIntensity()); - put(BodyBeautyParam.WAIST_SLIM_INTENSITY, () -> getCurrentBodyBeautyModel().getWaistSlimIntensity()); - put(BodyBeautyParam.SHOULDER_SLIM_INTENSITY, () -> getCurrentBodyBeautyModel().getShoulderSlimIntensity()); - put(BodyBeautyParam.HIP_SLIM_INTENSITY, () -> getCurrentBodyBeautyModel().getHipSlimIntensity()); - put(BodyBeautyParam.HEAD_SLIM_INTENSITY, () -> getCurrentBodyBeautyModel().getHeadSlimIntensity()); - put(BodyBeautyParam.LEG_SLIM_INTENSITY, () -> getCurrentBodyBeautyModel().getLegSlimIntensity()); + put(BodyBeautyParam.BODY_SLIM_INTENSITY, ()->getCurrentBodyBeautyModel().getBodySlimIntensity()); + put(BodyBeautyParam.LEG_STRETCH_INTENSITY, ()->getCurrentBodyBeautyModel().getLegStretchIntensity()); + put(BodyBeautyParam.WAIST_SLIM_INTENSITY, ()->getCurrentBodyBeautyModel().getWaistSlimIntensity()); + put(BodyBeautyParam.SHOULDER_SLIM_INTENSITY, ()->getCurrentBodyBeautyModel().getShoulderSlimIntensity()); + put(BodyBeautyParam.HIP_SLIM_INTENSITY, ()->getCurrentBodyBeautyModel().getHipSlimIntensity()); + put(BodyBeautyParam.HEAD_SLIM_INTENSITY, ()->getCurrentBodyBeautyModel().getHeadSlimIntensity()); + put(BodyBeautyParam.LEG_SLIM_INTENSITY, ()->getCurrentBodyBeautyModel().getLegSlimIntensity()); } }; @@ -143,8 +143,18 @@ public class BodyBeautyDataFactory extends AbstractBodyBeautyDataFactory { * FURenderKit加载当前特效 */ public void bindCurrentRenderer() { + mFUAIKit.loadAIProcessor(FaceUnityConfig.getAIHumanBundle(), FUAITypeEnum.FUAITYPE_HUMAN_PROCESSOR); + mFUAIKit.setMaxFaces(1); + mFURenderKit.setFaceBeauty(FaceBeautyDataFactory.faceBeauty); mFURenderKit.setBodyBeauty(bodyBeauty); } + /** + * 结束需要释放AI驱动 + */ + public void releaseAIProcessor() { + mFUAIKit.releaseAIProcessor(FUAITypeEnum.FUAITYPE_HUMAN_PROCESSOR); + } + } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/data/MakeupDataFactory.java b/FaceUnity/src/main/java/com/yunbao/faceunity/data/MakeupDataFactory.java index 99c6809a3..1e808a010 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/data/MakeupDataFactory.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/data/MakeupDataFactory.java @@ -846,4 +846,8 @@ public class MakeupDataFactory extends AbstractMakeupDataFactory { mFURenderKit.getPropContainer().addProp(expressionRecognition); } } + public void clearAll(){ + currentMakeup = new Makeup(new FUBundleData(FaceUnityConfig.BUNDLE_FACE_MAKEUP)); + mFURenderKit.setMakeup(currentMakeup); + } } \ No newline at end of file diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java b/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java index ef2f8e0bf..3cbcc9d00 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/ui/FaceUnityView.java @@ -3,6 +3,7 @@ package com.yunbao.faceunity.ui; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; +import android.view.View; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -111,9 +112,24 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper } private void initViewClick() { - menu2Back.setOnClickListener(v -> goBackMainMenu()); + menu2Back.setOnClickListener(v -> { + Object tag = menu2Back.getTag(); + if(tag==null) { + goBackMainMenu(); + }else if(tag.equals("makeup")){ + title.setText(R.string.home_function_name_makeup); + title.setVisibility(VISIBLE); + menuDiy.setVisibility(VISIBLE); + tabLayout.removeAllTabs(); + changeRecyclerItemCount(5); + setContainerRecycler(MakeupSource.buildCombinations()); + menu2Back.setTag(null); + } + }); menuDiy.setOnClickListener(v -> { + menu2Back.setTag("makeup"); changeRecyclerItemCount(5); + menuDiy.setVisibility(GONE); ArrayList list = MakeupSource.buildCustomClasses(); setTab(createTabs(list)); }); @@ -128,6 +144,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper title.setVisibility(VISIBLE); menu2.setVisibility(GONE); menuGroup.setVisibility(VISIBLE); + menuDiy.setVisibility(GONE); } diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java index 0781c7b7c..f4ba6d5b0 100644 --- a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java +++ b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceSPUtils.java @@ -30,4 +30,12 @@ public class FaceSPUtils { public void del(String key) { mSharedPreferences.edit().remove(key).apply(); } + + public void delStart(String key){ + for (String _key : mSharedPreferences.getAll().keySet()) { + if(_key.startsWith(key)){ + mSharedPreferences.edit().remove(key).apply(); + } + } + } } diff --git a/FaceUnity/src/main/res/layout/layout_faceunity.xml b/FaceUnity/src/main/res/layout/layout_faceunity.xml index 161b09f3d..f24b8d17c 100644 --- a/FaceUnity/src/main/res/layout/layout_faceunity.xml +++ b/FaceUnity/src/main/res/layout/layout_faceunity.xml @@ -13,8 +13,8 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="@dimen/x24" android:layout_marginBottom="@dimen/x15" + android:paddingTop="20dp" android:visibility="gone" - android:paddingTop="10dp" app:dsb_indicatorColor="#CDCDCD" app:dsb_indicatorElevation="0dp" app:dsb_indicatorPopupEnabled="true" @@ -171,6 +171,8 @@ android:layout_height="wrap_content" android:layout_marginStart="10dp" android:layout_weight="0" + android:paddingStart="10dp" + android:paddingEnd="10dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -186,8 +188,10 @@ diff --git a/FaceUnity/src/main/res/mipmap-xxhdpi/icon_beauty_box_style_7_normal.png b/FaceUnity/src/main/res/mipmap-xxhdpi/icon_beauty_box_style_7_normal.png index d76dc2580..c33de736c 100644 Binary files a/FaceUnity/src/main/res/mipmap-xxhdpi/icon_beauty_box_style_7_normal.png and b/FaceUnity/src/main/res/mipmap-xxhdpi/icon_beauty_box_style_7_normal.png differ diff --git a/FaceUnity/src/main/res/mipmap-xxhdpi/icon_beauty_style_7_selector.png b/FaceUnity/src/main/res/mipmap-xxhdpi/icon_beauty_style_7_selector.png new file mode 100644 index 000000000..c33de736c Binary files /dev/null and b/FaceUnity/src/main/res/mipmap-xxhdpi/icon_beauty_style_7_selector.png differ diff --git a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java index ff3aaf53e..3fbd2d26e 100644 --- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java +++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java @@ -148,13 +148,6 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL } }; mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000); - mCover.setOnClickListener(v -> { - FaceManager manager = new FaceManager(); - manager.initFURender(mContext); - LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext); - fragment.setManager(manager); - fragment.show(((LauncherActivity) mContext).getSupportFragmentManager(), "FaceUnity"); - }); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 3d43f2428..6d86ed44d 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -47,6 +47,7 @@ import com.yunbao.live.bean.LiveKsyConfigBean; import com.yunbao.live.bean.LiveReceiveGiftBean; import com.yunbao.live.bean.WishlistModel; import com.yunbao.live.dialog.LiveBeautyDialogFragment; +import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveFunctionDialogFragment; import com.yunbao.live.dialog.LiveLinkMicListDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java index 2f21d53b5..3a244c2f1 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -6,6 +6,8 @@ import android.content.Context; import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -71,6 +73,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl private int mLiveSdk; private LiveClassBean classBean; private FaceManager manager; + private TextView faceTextView;//提示人脸未检测到的TextView public LiveNewReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) { super(context, parentView, liveSdk); @@ -120,6 +123,8 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl mLiveClass = (TextView) findViewById(R.id.live_class); mLiveTypeTextView = (TextView) findViewById(R.id.text_room_type); mLiveWishListTextView = (TextView) findViewById(R.id.text_wishlist); + faceTextView=(TextView)findViewById(R.id.faceTextView); + mImageUtil = ((LiveActivity) mContext).getProcessImageUtil(); mImageUtil.setImageResultCallback(new ImageResultCallback() { @@ -188,6 +193,20 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl } }; manager = new FaceManager(); + manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() { + final Handler handler = new Handler(Looper.getMainLooper()); + + @Override + public void onFaceChanged(int num) { + handler.post(() -> { + if (num == 0) { + faceTextView.setVisibility(View.VISIBLE); + } else { + faceTextView.setVisibility(View.GONE); + } + }); + } + }); manager.initFURender(mContext); manager.drawRongFrame(mContext); } @@ -229,6 +248,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl public void setFaceUnity() { LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext); fragment.setManager(manager); + if (mContext instanceof LiveRyAnchorActivity) { fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity"); } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 552043969..bb36809a5 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -108,6 +108,7 @@ import com.yunbao.live.bean.WishlistItemModel; import com.yunbao.live.custom.LiveLightView; import com.yunbao.live.custom.RightGradual; import com.yunbao.live.custom.TopGradual; +import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserDialogFragment; @@ -963,7 +964,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis reloadIM(); } public void hideFloatMsg(){ - msg.setVisibility(View.GONE); + msgLayout.setVisibility(View.GONE); } private void showBanner2() { @@ -2541,6 +2542,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis */ public void startFace() { manager=new FaceManager(); + manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() { + @Override + public void onFaceChanged(int num) { + + } + }); manager.initFURender(mContext); manager.drawRongFrame(mContext); } @@ -2549,7 +2556,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis * 切换美颜UI */ public void changeFaceUnityView(){ - faceUnityView.setVisibility(faceUnityView.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); + // faceUnityView.setVisibility(faceUnityView.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); + LiveFaceUnityDialogFragment fragment=new LiveFaceUnityDialogFragment(mContext); + fragment.setManager(manager); + fragment.show(((LiveActivity)mContext).getSupportFragmentManager(),"faceUi"); } private static class LiveRoomHandler extends Handler { diff --git a/live/src/main/res/layout/view_new_live_ready.xml b/live/src/main/res/layout/view_new_live_ready.xml index ac6c6ab8b..0ec5b7b4d 100644 --- a/live/src/main/res/layout/view_new_live_ready.xml +++ b/live/src/main/res/layout/view_new_live_ready.xml @@ -249,5 +249,18 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> - + + + \ No newline at end of file