新增启动直播准备间时就加载上次美颜参数
This commit is contained in:
parent
461a23a790
commit
3dd9f3f551
@ -19,11 +19,15 @@ import com.faceunity.core.enumeration.FUInputTextureEnum;
|
|||||||
import com.faceunity.core.enumeration.FUTransformMatrixEnum;
|
import com.faceunity.core.enumeration.FUTransformMatrixEnum;
|
||||||
import com.faceunity.core.faceunity.FUAIKit;
|
import com.faceunity.core.faceunity.FUAIKit;
|
||||||
import com.faceunity.core.utils.CameraUtils;
|
import com.faceunity.core.utils.CameraUtils;
|
||||||
|
import com.yunbao.faceunity.data.FaceBeautyDataFactory;
|
||||||
import com.yunbao.faceunity.data.FaceUnityDataFactory;
|
import com.yunbao.faceunity.data.FaceUnityDataFactory;
|
||||||
|
import com.yunbao.faceunity.entity.FaceBeautyBean;
|
||||||
|
import com.yunbao.faceunity.entity.FaceBeautyFilterBean;
|
||||||
import com.yunbao.faceunity.listener.FURendererListener;
|
import com.yunbao.faceunity.listener.FURendererListener;
|
||||||
import com.yunbao.faceunity.ui.FaceUnityView;
|
import com.yunbao.faceunity.ui.FaceUnityView;
|
||||||
import com.yunbao.faceunity.utils.CSVUtils;
|
import com.yunbao.faceunity.utils.CSVUtils;
|
||||||
import com.yunbao.faceunity.utils.FURenderer;
|
import com.yunbao.faceunity.utils.FURenderer;
|
||||||
|
import com.yunbao.faceunity.utils.FaceSPUtils;
|
||||||
import com.yunbao.faceunity.utils.FaceUnityData;
|
import com.yunbao.faceunity.utils.FaceUnityData;
|
||||||
import com.yunbao.faceunity.utils.net.OkHttpUtils;
|
import com.yunbao.faceunity.utils.net.OkHttpUtils;
|
||||||
|
|
||||||
@ -31,6 +35,8 @@ import java.io.File;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCVideoOutputFrameListener;
|
import cn.rongcloud.rtc.api.callback.IRCRTCVideoOutputFrameListener;
|
||||||
@ -83,6 +89,7 @@ public class FaceManager implements SensorEventListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册长按对比键事件
|
* 注册长按对比键事件
|
||||||
|
*
|
||||||
* @param faceUnityView
|
* @param faceUnityView
|
||||||
*/
|
*/
|
||||||
public void setFaceUnityView(FaceUnityView faceUnityView) {
|
public void setFaceUnityView(FaceUnityView faceUnityView) {
|
||||||
@ -98,6 +105,44 @@ public class FaceManager implements SensorEventListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public void loadConfig(){
|
||||||
|
initFaceBeauty();
|
||||||
|
}
|
||||||
|
public void initFaceBeauty() {
|
||||||
|
FaceBeautyDataFactory faceBeautyDataFactory;
|
||||||
|
faceBeautyDataFactory = new FaceBeautyDataFactory();
|
||||||
|
Map<String, ?> configMap = FaceSPUtils.getInstance().getAll();
|
||||||
|
for (String key : configMap.keySet()) {
|
||||||
|
if ("FilterViewHolder_".equals(key)) {
|
||||||
|
for (FaceBeautyFilterBean filter : faceBeautyDataFactory.getBeautyFilters()) {
|
||||||
|
if (filter.getKey().equals(configMap.get(key))&&!"origin".equals(configMap.get(key))) {
|
||||||
|
faceBeautyDataFactory.onFilterSelected(filter.getKey(), Double.parseDouble((String) Objects.requireNonNull(configMap.get("FilterViewHolder_" + configMap.get(key) + "_val")))/100, filter.getDesRes());
|
||||||
|
Log.i(TAG, "test: 设置滤镜 ="+filter.getKey()+" val = "+configMap.get("FilterViewHolder_" + configMap.get(key) + "_val"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (key.startsWith("BeautySkinViewHolder_")) {
|
||||||
|
String name = key.replace("BeautySkinViewHolder_", "");
|
||||||
|
for (FaceBeautyBean bean : faceBeautyDataFactory.getShapeBeauty()) {
|
||||||
|
if (bean.getKey().equals(name)) {
|
||||||
|
faceBeautyDataFactory.updateParamIntensity(bean.getKey(),Double.parseDouble((String) Objects.requireNonNull(configMap.get(key))));
|
||||||
|
Log.i(TAG, "test: 设置美颜 = "+bean.getKey()+" val = "+configMap.get(key));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if(key.startsWith("BeautyShapeViewHolder")){
|
||||||
|
String name = key.replace("BeautyShapeViewHolder_", "");
|
||||||
|
for (FaceBeautyBean bean : faceBeautyDataFactory.getShapeBeauty()) {
|
||||||
|
if (bean.getKey().equals(name)) {
|
||||||
|
faceBeautyDataFactory.updateParamIntensity(bean.getKey(),Double.parseDouble((String) Objects.requireNonNull(configMap.get(key))));
|
||||||
|
Log.i(TAG, "test: 设置美肤 = "+bean.getKey()+" val = "+configMap.get(key));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听人脸识别个数
|
* 监听人脸识别个数
|
||||||
|
@ -85,6 +85,19 @@ public class FaceBeautyDataFactory extends AbstractFaceBeautyDataFactory {
|
|||||||
public FaceBeautyDataFactory(FaceBeautyListener listener) {
|
public FaceBeautyDataFactory(FaceBeautyListener listener) {
|
||||||
mFaceBeautyListener = listener;
|
mFaceBeautyListener = listener;
|
||||||
}
|
}
|
||||||
|
public FaceBeautyDataFactory(){
|
||||||
|
mFaceBeautyListener=new FaceBeautyListener() {
|
||||||
|
@Override
|
||||||
|
public void onFilterSelected(int res) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFaceBeautyEnable(boolean enable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,6 @@ package com.yunbao.faceunity.ui;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -311,7 +310,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper
|
|||||||
tabLayout.removeAllTabs();
|
tabLayout.removeAllTabs();
|
||||||
for (TabLayout.Tab tab : tabs) {
|
for (TabLayout.Tab tab : tabs) {
|
||||||
tabLayout.addTab(tab);
|
tabLayout.addTab(tab);
|
||||||
if(tab.getTag() instanceof Integer) {
|
if (tab.getTag() instanceof Integer) {
|
||||||
if (FaceSPUtils.getInstance().getString(StyleViewHolder.class.getSimpleName() + "_") != null && (int) tab.getTag() == FaceParam.FACE_BEAUTY_STYLE) {
|
if (FaceSPUtils.getInstance().getString(StyleViewHolder.class.getSimpleName() + "_") != null && (int) tab.getTag() == FaceParam.FACE_BEAUTY_STYLE) {
|
||||||
ToastUtil.show("请先重置风格推荐");
|
ToastUtil.show("请先重置风格推荐");
|
||||||
tab.select();
|
tab.select();
|
||||||
@ -446,7 +445,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper
|
|||||||
containerRecycler.setAdapter(containerAdapter);
|
containerRecycler.setAdapter(containerAdapter);
|
||||||
}
|
}
|
||||||
// titleLayout.setVisibility(title.getVisibility()==GONE?INVISIBLE:VISIBLE);
|
// titleLayout.setVisibility(title.getVisibility()==GONE?INVISIBLE:VISIBLE);
|
||||||
// Log.i(TAG, "setContainerRecycler: " + list.size());
|
// Log.i(TAG, "setContainerRecycler: " + list.size());
|
||||||
containerAdapter.setList(list);
|
containerAdapter.setList(list);
|
||||||
containerAdapter.notifyDataSetChanged();
|
containerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class FURenderer extends IFURenderer {
|
|||||||
private FURenderKit mFURenderKit;
|
private FURenderKit mFURenderKit;
|
||||||
|
|
||||||
/* AI道具*/
|
/* AI道具*/
|
||||||
private String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
|
private String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle";
|
||||||
private String BUNDLE_AI_HUMAN = "model" + File.separator + "ai_human_processor.bundle";
|
private String BUNDLE_AI_HUMAN = "model" + File.separator + "ai_human_processor.bundle";
|
||||||
|
|
||||||
/* GL 线程 ID */
|
/* GL 线程 ID */
|
||||||
|
@ -5,6 +5,8 @@ import android.content.SharedPreferences;
|
|||||||
|
|
||||||
import com.yunbao.common.CommonAppContext;
|
import com.yunbao.common.CommonAppContext;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class FaceSPUtils {
|
public class FaceSPUtils {
|
||||||
private static FaceSPUtils utils;
|
private static FaceSPUtils utils;
|
||||||
private SharedPreferences mSharedPreferences;
|
private SharedPreferences mSharedPreferences;
|
||||||
@ -38,4 +40,7 @@ public class FaceSPUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Map<String, ?> getAll(){
|
||||||
|
return mSharedPreferences.getAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ public class LiveFaceUnityDialogFragment extends AbsDialogFragment {
|
|||||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
manager.setFaceUnityView(faceView);
|
manager.setFaceUnityView(faceView);
|
||||||
|
manager.loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -209,6 +209,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
|||||||
//新美颜
|
//新美颜
|
||||||
manager.initFURender(mContext);
|
manager.initFURender(mContext);
|
||||||
manager.drawRongFrame(mContext);
|
manager.drawRongFrame(mContext);
|
||||||
|
setFaceUnity(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -229,7 +230,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
|||||||
chooseLiveClass();
|
chooseLiveClass();
|
||||||
} else if (i == R.id.btn_beauty) {
|
} else if (i == R.id.btn_beauty) {
|
||||||
//beauty();//momo美颜
|
//beauty();//momo美颜
|
||||||
setFaceUnity(); //新娱美颜
|
setFaceUnity(false); //新娱美颜
|
||||||
} else if (i == R.id.btn_wishlist) {
|
} else if (i == R.id.btn_wishlist) {
|
||||||
//点击心愿单
|
//点击心愿单
|
||||||
openWishListWindow();
|
openWishListWindow();
|
||||||
@ -249,13 +250,16 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
|||||||
/**
|
/**
|
||||||
* 新娱美颜
|
* 新娱美颜
|
||||||
*/
|
*/
|
||||||
public void setFaceUnity() {
|
public void setFaceUnity(boolean init) {
|
||||||
LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext);
|
LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext);
|
||||||
fragment.setManager(manager);
|
fragment.setManager(manager);
|
||||||
fragment.setDismissShowUi(mRootView);
|
fragment.setDismissShowUi(mRootView);
|
||||||
if (mContext instanceof LiveRyAnchorActivity) {
|
if (mContext instanceof LiveRyAnchorActivity) {
|
||||||
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
|
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
|
||||||
mRootView.setVisibility(View.INVISIBLE);
|
mRootView.setVisibility(View.INVISIBLE);
|
||||||
|
if(init){
|
||||||
|
fragment.dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user