Compare commits
No commits in common. "master" and "6.4.2" have entirely different histories.
@ -1,12 +1,12 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'img-optimizer'
|
apply plugin: 'img-optimizer'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-parcelize'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
apply from: "../package_config.gradle"
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace "com.yunbao.faceunity"
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
compileSdk rootProject.ext.android.compileSdkVersion
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
pickFirst "lib/armeabi/libyuvutils.so"
|
pickFirst "lib/armeabi/libyuvutils.so"
|
||||||
pickFirst "lib/arm64-v8a/libyuvutils.so"
|
pickFirst "lib/arm64-v8a/libyuvutils.so"
|
||||||
@ -34,7 +34,6 @@ android {
|
|||||||
manifestPlaceholders = rootProject.ext.manifestPlaceholders
|
manifestPlaceholders = rootProject.ext.manifestPlaceholders
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||||
// abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aaptOptions {
|
aaptOptions {
|
||||||
@ -49,8 +48,8 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_18
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_18
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
@ -59,15 +58,15 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
api rootProject.ext.dependencies["appcompat-androidx"]
|
implementation rootProject.ext.dependencies["appcompat-androidx"]
|
||||||
api rootProject.ext.dependencies["recyclerview-androidx"]
|
implementation rootProject.ext.dependencies["recyclerview-androidx"]
|
||||||
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
//common
|
//common
|
||||||
api project(path: ':common')
|
implementation project(path: ':common')
|
||||||
|
|
||||||
api 'com.faceunity:core:8.7.0'
|
implementation 'com.faceunity:core:8.3.1'
|
||||||
api 'com.faceunity:model:8.7.0'
|
implementation 'com.faceunity:model:8.3.1'
|
||||||
//implementation 'com.faceunity:nama:8.3.1' //底层库-标准版
|
//implementation 'com.faceunity:nama:8.3.1' //底层库-标准版
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package com.yunbao.faceunity;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.test.platform.app.Instrimport com.yunbao.common.utils.MobclickAgent;ntationRegistry;
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="com.yunbao.faceunity"
|
||||||
|
>
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
@ -19,15 +19,11 @@ 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;
|
||||||
|
|
||||||
@ -35,9 +31,10 @@ 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.callback.IRCRTCVideoOutputFrameListener;
|
||||||
|
import cn.rongcloud.rtc.base.RCRTCVideoFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 美颜模块管理类
|
* 美颜模块管理类
|
||||||
@ -68,7 +65,7 @@ public class FaceManager implements SensorEventListener {
|
|||||||
* 配置美颜SDK
|
* 配置美颜SDK
|
||||||
*/
|
*/
|
||||||
public void initFURender(Context context) {
|
public void initFURender(Context context) {
|
||||||
initFaceUnity(context);
|
|
||||||
mFURenderer = FURenderer.getInstance();
|
mFURenderer = FURenderer.getInstance();
|
||||||
mFURenderer.setInputTextureType(FUInputTextureEnum.FU_ADM_FLAG_COMMON_TEXTURE);
|
mFURenderer.setInputTextureType(FUInputTextureEnum.FU_ADM_FLAG_COMMON_TEXTURE);
|
||||||
mFURenderer.setCameraFacing(CameraFacingEnum.CAMERA_FRONT);
|
mFURenderer.setCameraFacing(CameraFacingEnum.CAMERA_FRONT);
|
||||||
@ -86,81 +83,22 @@ public class FaceManager implements SensorEventListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册长按对比键事件
|
* 注册长按对比键事件
|
||||||
*
|
|
||||||
* @param faceUnityView
|
* @param faceUnityView
|
||||||
*/
|
*/
|
||||||
public void setFaceUnityView(FaceUnityView faceUnityView) {
|
public void setFaceUnityView(FaceUnityView faceUnityView) {
|
||||||
faceUnityView.setIFaceUnityInter(new FaceUnityView.IFaceUnityInter() {
|
faceUnityView.setIFaceUnityInter(new FaceUnityView.IFaceUnityInter() {
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
if(onMirrorChanged!=null){
|
|
||||||
onMirrorChanged.onChange(false);
|
|
||||||
}
|
|
||||||
pauseFace = true;
|
pauseFace = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
if(onMirrorChanged!=null){
|
|
||||||
onMirrorChanged.onChange(true);
|
|
||||||
}
|
|
||||||
pauseFace = false;
|
pauseFace = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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))) {
|
|
||||||
try {
|
|
||||||
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"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (key.startsWith("BeautySkinViewHolder_")) {
|
|
||||||
String name = key.replace("BeautySkinViewHolder_", "");
|
|
||||||
for (FaceBeautyBean bean : faceBeautyDataFactory.getShapeBeauty()) {
|
|
||||||
if (bean.getKey().equals(name)) {
|
|
||||||
try {
|
|
||||||
faceBeautyDataFactory.updateParamIntensity(bean.getKey(), Double.parseDouble((String) Objects.requireNonNull(configMap.get(key))));
|
|
||||||
Log.i(TAG, "test: 设置美颜 = " + bean.getKey() + " val = " + configMap.get(key));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (key.startsWith("BeautyShapeViewHolder")) {
|
|
||||||
String name = key.replace("BeautyShapeViewHolder_", "");
|
|
||||||
for (FaceBeautyBean bean : faceBeautyDataFactory.getShapeBeauty()) {
|
|
||||||
if (bean.getKey().equals(name)) {
|
|
||||||
try {
|
|
||||||
faceBeautyDataFactory.updateParamIntensity(bean.getKey(), Double.parseDouble((String) Objects.requireNonNull(configMap.get(key))));
|
|
||||||
Log.i(TAG, "test: 设置美肤 = " + bean.getKey() + " val = " + configMap.get(key));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听人脸识别个数
|
* 监听人脸识别个数
|
||||||
*/
|
*/
|
||||||
@ -175,6 +113,44 @@ public class FaceManager implements SensorEventListener {
|
|||||||
private static final int CAMERA_SWITCH_SKIP_FRAME = 0;
|
private static final int CAMERA_SWITCH_SKIP_FRAME = 0;
|
||||||
private volatile boolean mSkip;
|
private volatile boolean mSkip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染融云视频帧
|
||||||
|
*/
|
||||||
|
public void drawRongFrame(Context context) {
|
||||||
|
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(new IRCRTCVideoOutputFrameListener() {
|
||||||
|
@Override
|
||||||
|
public RCRTCVideoFrame processVideoFrame(RCRTCVideoFrame callVideoFrame) {
|
||||||
|
//Log.i(TAG, "processVideoFrame: egl context " + EGL14.eglGetCurrentContext());
|
||||||
|
if (pauseFace) {
|
||||||
|
return callVideoFrame;
|
||||||
|
}
|
||||||
|
int width = callVideoFrame.getWidth();
|
||||||
|
int height = callVideoFrame.getHeight();
|
||||||
|
|
||||||
|
if (mIsFirstFrame) {
|
||||||
|
mIsFirstFrame = false;
|
||||||
|
//initCsvUtil(context);
|
||||||
|
mFURenderer.prepareRenderer(mFURendererListener);
|
||||||
|
}
|
||||||
|
//long start = System.nanoTime();
|
||||||
|
mFURenderer.setInputOrientation(callVideoFrame.getRotation());
|
||||||
|
FURenderOutputData data = mFURenderer.onDrawFrameInputWithReturn(callVideoFrame.getData(), width, height);
|
||||||
|
/* long time = System.nanoTime() - start;
|
||||||
|
if (mCSVUtils != null) {
|
||||||
|
mCSVUtils.writeCsv(null, time);
|
||||||
|
}*/
|
||||||
|
if (mSkippedFrames > 0 || mSkip) {
|
||||||
|
--mSkippedFrames;
|
||||||
|
return callVideoFrame;
|
||||||
|
}
|
||||||
|
if (data != null && data.getImage() != null && data.getImage().getBuffer() != null) {
|
||||||
|
callVideoFrame.setData(data.getImage().getBuffer());
|
||||||
|
}
|
||||||
|
return callVideoFrame;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录渲染工具,调试用,在processVideoFrame里使用
|
* 记录渲染工具,调试用,在processVideoFrame里使用
|
||||||
@ -237,6 +213,12 @@ public class FaceManager implements SensorEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 离开渲染界面时注销融云监听器,不然会绿屏
|
||||||
|
*/
|
||||||
|
public void onClose() {
|
||||||
|
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 释放资源
|
* 释放资源
|
||||||
@ -250,22 +232,10 @@ public class FaceManager implements SensorEventListener {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
isInit = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OnMirrorChanged onMirrorChanged;
|
|
||||||
|
|
||||||
public void setOnMirrorChanged(OnMirrorChanged onMirrorChanged) {
|
|
||||||
this.onMirrorChanged = onMirrorChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface FaceStatusChanged {
|
public interface FaceStatusChanged {
|
||||||
void onFaceChanged(int num);
|
void onFaceChanged(int num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface OnMirrorChanged{
|
|
||||||
void onChange(boolean falg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
@ -80,11 +81,11 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolde
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void hideSeekBar() {
|
public void hideSeekBar() {
|
||||||
if (seekBar.getVisibility() == View.INVISIBLE) {
|
if (seekBar.getVisibility() == View.GONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
seekBar.setOnProgressChangeListener(null);
|
seekBar.setOnProgressChangeListener(null);
|
||||||
seekBar.setVisibility(View.INVISIBLE);
|
seekBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class AnimojiViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean> list) {
|
public void reset(List<? extends BaseBean> list) {
|
||||||
adapter.save(getName(this),"0");
|
adapter.del(getName(this));
|
||||||
adapter.getAnimojiDataFactory().onAnimojiSelected((AnimojiBean) list.get(0));
|
adapter.getAnimojiDataFactory().onAnimojiSelected((AnimojiBean) list.get(0));
|
||||||
adapter.setSelectPosition(0);
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,7 @@ public class BeautyShapeViewHolder extends BaseViewHolder {
|
|||||||
super.onProgressChanged(seekBar, value, fromUser);
|
super.onProgressChanged(seekBar, value, fromUser);
|
||||||
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
||||||
double toValue = SeekBarUtils.Companion.seekToValue(bean.getModelAttributeData().getMaxRange(), value, seekBar.getMin());
|
double toValue = SeekBarUtils.Companion.seekToValue(bean.getModelAttributeData().getMaxRange(), value, seekBar.getMin());
|
||||||
BeautyShapeViewHolder.this.value.setTag(String.format("%.1f", toValue));
|
BeautyShapeViewHolder.this.value.setText(String.format("%.1f", toValue));
|
||||||
BeautyShapeViewHolder.this.value.setText(value+"");
|
|
||||||
adapter.getFaceBeautyDataFactory().updateParamIntensity(bean.getKey(), toValue);
|
adapter.getFaceBeautyDataFactory().updateParamIntensity(bean.getKey(), toValue);
|
||||||
saveData();
|
saveData();
|
||||||
}
|
}
|
||||||
@ -81,7 +80,7 @@ public class BeautyShapeViewHolder extends BaseViewHolder {
|
|||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
||||||
adapter.save(getName(this)+bean.getKey(), (String) value.getTag());
|
adapter.save(getName(this)+bean.getKey(), (String) value.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,8 +36,7 @@ public class BeautySkinViewHolder extends BaseViewHolder{
|
|||||||
super.onProgressChanged(seekBar, value, fromUser);
|
super.onProgressChanged(seekBar, value, fromUser);
|
||||||
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
||||||
double toValue = SeekBarUtils.Companion.seekToValue(bean.getModelAttributeData().getMaxRange(), value, seekBar.getMin());
|
double toValue = SeekBarUtils.Companion.seekToValue(bean.getModelAttributeData().getMaxRange(), value, seekBar.getMin());
|
||||||
BeautySkinViewHolder.this.value.setTag(String.format("%.1f",toValue));
|
BeautySkinViewHolder.this.value.setText(String.format("%.1f",toValue));
|
||||||
BeautySkinViewHolder.this.value.setText(value+"");
|
|
||||||
adapter.getFaceBeautyDataFactory().updateParamIntensity(bean.getKey(),toValue);
|
adapter.getFaceBeautyDataFactory().updateParamIntensity(bean.getKey(),toValue);
|
||||||
saveData();
|
saveData();
|
||||||
}
|
}
|
||||||
@ -81,7 +80,7 @@ public class BeautySkinViewHolder extends BaseViewHolder{
|
|||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
String key = ((FaceBeautyBean)itemView.getTag()).getKey();
|
String key = ((FaceBeautyBean)itemView.getTag()).getKey();
|
||||||
String val= (String) value.getTag();
|
String val= (String) value.getText();
|
||||||
adapter.save(getName(this)+key,val);
|
adapter.save(getName(this)+key,val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class BigHeadViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean> list) {
|
public void reset(List<? extends BaseBean> list) {
|
||||||
adapter.save(getName(this),list.get(0).getKey());
|
adapter.del(getName(this));
|
||||||
adapter.getPropDataFactory().setPropType(FunctionEnum.BIG_HEAD);
|
adapter.getPropDataFactory().setPropType(FunctionEnum.BIG_HEAD);
|
||||||
adapter.getPropDataFactory().onItemSelected((PropBean) list.get(0));
|
adapter.getPropDataFactory().onItemSelected((PropBean) list.get(0));
|
||||||
adapter.setSelectPosition(0);
|
adapter.setSelectPosition(0);
|
||||||
|
@ -9,8 +9,6 @@ import androidx.annotation.NonNull;
|
|||||||
import com.yunbao.faceunity.R;
|
import com.yunbao.faceunity.R;
|
||||||
import com.yunbao.faceunity.entity.BaseBean;
|
import com.yunbao.faceunity.entity.BaseBean;
|
||||||
import com.yunbao.faceunity.entity.FaceBeautyFilterBean;
|
import com.yunbao.faceunity.entity.FaceBeautyFilterBean;
|
||||||
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
|
||||||
import com.yunbao.faceunity.utils.SeekBarUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -20,7 +18,6 @@ import java.util.List;
|
|||||||
public class FilterViewHolder extends BaseViewHolder {
|
public class FilterViewHolder extends BaseViewHolder {
|
||||||
private ImageView icon;
|
private ImageView icon;
|
||||||
private TextView title;
|
private TextView title;
|
||||||
private String KEY_VAL;
|
|
||||||
|
|
||||||
public FilterViewHolder(@NonNull View itemView) {
|
public FilterViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -31,28 +28,6 @@ public class FilterViewHolder extends BaseViewHolder {
|
|||||||
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(), bean.getIntensity(), bean.getDesRes());
|
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(), bean.getIntensity(), bean.getDesRes());
|
||||||
setSelectPosition(getAdapterPosition());
|
setSelectPosition(getAdapterPosition());
|
||||||
saveData();
|
saveData();
|
||||||
if("origin".equals(bean.getKey())){
|
|
||||||
adapter.hideSeekBar();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
adapter.showSeekBar();
|
|
||||||
adapter.getSeekBar().setMax(100);
|
|
||||||
adapter.getSeekBar().setTag(bean);
|
|
||||||
adapter.getSeekBar().setOnProgressChangeListener(new DiscreteSeekBar.OnSimpleProgressChangeListener(){
|
|
||||||
@Override
|
|
||||||
public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
|
|
||||||
super.onProgressChanged(seekBar, value, fromUser);
|
|
||||||
KEY_VAL=getName(FilterViewHolder.this)+((BaseBean)seekBar.getTag()).getKey()+"_val";
|
|
||||||
double toValue = SeekBarUtils.Companion.seekToValue(1, value, seekBar.getMin());
|
|
||||||
adapter.getFaceBeautyDataFactory().updateFilterIntensity(toValue);
|
|
||||||
adapter.save(KEY_VAL,value+"");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(adapter.getString(KEY_VAL)==null) {
|
|
||||||
adapter.getSeekBar().setProgress((int) (bean.getIntensity() * 100));
|
|
||||||
}else{
|
|
||||||
adapter.getSeekBar().setProgress(Integer.parseInt(adapter.getString(KEY_VAL)));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +47,6 @@ public class FilterViewHolder extends BaseViewHolder {
|
|||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
FaceBeautyFilterBean bean = (FaceBeautyFilterBean) itemView.getTag();
|
FaceBeautyFilterBean bean = (FaceBeautyFilterBean) itemView.getTag();
|
||||||
KEY_VAL=getName(FilterViewHolder.this)+bean.getKey()+"_val";
|
|
||||||
String val = adapter.getString(getName(this));
|
String val = adapter.getString(getName(this));
|
||||||
if (val == null) {
|
if (val == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -80,14 +54,8 @@ public class FilterViewHolder extends BaseViewHolder {
|
|||||||
if (!val.equals(bean.getKey())) {
|
if (!val.equals(bean.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!"origin".equals(bean.getKey())){
|
|
||||||
adapter.showSeekBar();
|
|
||||||
}
|
|
||||||
icon.setSelected(true);
|
icon.setSelected(true);
|
||||||
title.setSelected(true);
|
title.setSelected(true);
|
||||||
if(adapter.getString(KEY_VAL)!=null) {
|
|
||||||
bean.setIntensity(Double.parseDouble(adapter.getString(KEY_VAL))/100);
|
|
||||||
}
|
|
||||||
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(), bean.getIntensity(), bean.getDesRes());
|
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(), bean.getIntensity(), bean.getDesRes());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -100,14 +68,8 @@ public class FilterViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean> list) {
|
public void reset(List<? extends BaseBean> list) {
|
||||||
FaceBeautyFilterBean bean = (FaceBeautyFilterBean) list.get(0);
|
adapter.del(getName(this));
|
||||||
for (BaseBean baseBean : list) {
|
itemView.callOnClick();
|
||||||
String key=getName(this)+baseBean.getKey()+"_val";
|
|
||||||
adapter.save(key,"40");
|
|
||||||
}
|
|
||||||
adapter.hideSeekBar();
|
|
||||||
adapter.save(getName(this),bean.getKey());
|
|
||||||
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(), bean.getIntensity(), bean.getDesRes());
|
|
||||||
adapter.setSelectPosition(0);
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class FineStickerViewHolder extends BaseViewHolder implements StickerDown
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean> list) {
|
public void reset(List<? extends BaseBean> list) {
|
||||||
adapter.save(getName(this),list.get(0).getKey());
|
adapter.del(getName(this));
|
||||||
itemView.callOnClick();
|
itemView.callOnClick();
|
||||||
adapter.setSelectPosition(0);
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
|
@ -115,10 +115,11 @@ public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean> list) {
|
public void reset(List<? extends BaseBean> list) {
|
||||||
adapter.save(getName(this),list.get(0).getKey());
|
adapter.del(getName(this));
|
||||||
for (BaseBean bean : list) {
|
for (BaseBean bean : list) {
|
||||||
adapter.del(getName(this) + bean.getKey() + "_val");
|
adapter.del(getName(this) + bean.getKey() + "_val");
|
||||||
}
|
}
|
||||||
|
itemView.callOnClick();
|
||||||
adapter.setSelectPosition(0);
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class MakeupViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean>list) {
|
public void reset(List<? extends BaseBean>list) {
|
||||||
adapter.save(getName(this),list.get(0).getKey());
|
adapter.del(getName(this));
|
||||||
FaceSPUtils.getInstance().delStart("MakeupCustomItemViewHolder");
|
FaceSPUtils.getInstance().delStart("MakeupCustomItemViewHolder");
|
||||||
adapter.getMakeupDataFactory().onMakeupCombinationSelected((MakeupCombinationBean) list.get(0));
|
adapter.getMakeupDataFactory().onMakeupCombinationSelected((MakeupCombinationBean) list.get(0));
|
||||||
adapter.getMakeupDataFactory().clearAll();
|
adapter.getMakeupDataFactory().clearAll();
|
||||||
|
@ -70,7 +70,7 @@ public class StickerViewHolder extends BaseViewHolder{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean> list) {
|
public void reset(List<? extends BaseBean> list) {
|
||||||
adapter.save(getName(this),list.get(0).getKey());
|
adapter.del(getName(this));
|
||||||
adapter.getPropDataFactory().setPropType(FunctionEnum.STICKER);
|
adapter.getPropDataFactory().setPropType(FunctionEnum.STICKER);
|
||||||
adapter.getPropDataFactory().onItemSelected((PropBean) list.get(0));
|
adapter.getPropDataFactory().onItemSelected((PropBean) list.get(0));
|
||||||
adapter.setSelectPosition(0);
|
adapter.setSelectPosition(0);
|
||||||
|
@ -46,9 +46,7 @@ public class StyleViewHolder extends BaseViewHolder{
|
|||||||
BaseBean bean= (BaseBean) itemView.getTag();
|
BaseBean bean= (BaseBean) itemView.getTag();
|
||||||
String val = adapter.getString(getName(this));
|
String val = adapter.getString(getName(this));
|
||||||
if(val==null){
|
if(val==null){
|
||||||
icon.setSelected(false);
|
return false;
|
||||||
title.setSelected(false);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if(!val.equals(bean.getKey())){
|
if(!val.equals(bean.getKey())){
|
||||||
return false;
|
return false;
|
||||||
@ -68,9 +66,8 @@ public class StyleViewHolder extends BaseViewHolder{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(List<? extends BaseBean> list) {
|
public void reset(List<? extends BaseBean> list) {
|
||||||
// adapter.save(getName(this),list.get(0).getKey());
|
|
||||||
adapter.setSelectPosition(0);
|
|
||||||
adapter.del(getName(this));
|
adapter.del(getName(this));
|
||||||
adapter.getFaceBeautyDataFactory().onStyleSelected(null);
|
itemView.callOnClick();
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,19 +85,6 @@ 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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -14,12 +15,10 @@ import androidx.recyclerview.widget.GridLayoutManager;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.yunbao.common.utils.ToastUtil;
|
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.faceunity.R;
|
import com.yunbao.faceunity.R;
|
||||||
import com.yunbao.faceunity.adapters.ContainerRecyclerAdapter;
|
import com.yunbao.faceunity.adapters.ContainerRecyclerAdapter;
|
||||||
import com.yunbao.faceunity.adapters.MenuGroupRecyclerAdapter;
|
import com.yunbao.faceunity.adapters.MenuGroupRecyclerAdapter;
|
||||||
import com.yunbao.faceunity.adapters.vh.StyleViewHolder;
|
|
||||||
import com.yunbao.faceunity.data.FaceParam;
|
import com.yunbao.faceunity.data.FaceParam;
|
||||||
import com.yunbao.faceunity.data.FineStickerDataFactory;
|
import com.yunbao.faceunity.data.FineStickerDataFactory;
|
||||||
import com.yunbao.faceunity.entity.BaseBean;
|
import com.yunbao.faceunity.entity.BaseBean;
|
||||||
@ -34,7 +33,6 @@ import com.yunbao.faceunity.repo.FaceBeautySource;
|
|||||||
import com.yunbao.faceunity.repo.MakeupSource;
|
import com.yunbao.faceunity.repo.MakeupSource;
|
||||||
import com.yunbao.faceunity.repo.PropSource;
|
import com.yunbao.faceunity.repo.PropSource;
|
||||||
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
||||||
import com.yunbao.faceunity.utils.FaceSPUtils;
|
|
||||||
import com.yunbao.faceunity.utils.net.StickerDownloadHelper;
|
import com.yunbao.faceunity.utils.net.StickerDownloadHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -59,7 +57,6 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper
|
|||||||
private DiscreteSeekBar seekBar;
|
private DiscreteSeekBar seekBar;
|
||||||
private IFaceUnityInter iFaceUnityInter;
|
private IFaceUnityInter iFaceUnityInter;
|
||||||
private ConstraintLayout titleLayout;
|
private ConstraintLayout titleLayout;
|
||||||
private static final String TAG = "美颜";
|
|
||||||
|
|
||||||
public FaceUnityView(Context context) {
|
public FaceUnityView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -107,7 +104,6 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper
|
|||||||
initMenuGroup();
|
initMenuGroup();
|
||||||
setContainerRecycler(new ArrayList<>());
|
setContainerRecycler(new ArrayList<>());
|
||||||
initViewClick();
|
initViewClick();
|
||||||
gotoFaceBeauty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,25 +168,6 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper
|
|||||||
menuDiy.setVisibility(GONE);
|
menuDiy.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 目前只需要美颜功能,进入后直奔美颜
|
|
||||||
*/
|
|
||||||
private void gotoFaceBeauty() {
|
|
||||||
LinkedHashMap<Integer, Integer> map = new LinkedHashMap<>();
|
|
||||||
map.put(R.string.beauty_radio_skin_beauty, FaceParam.FACE_BEAUTY_SKIN);
|
|
||||||
map.put(R.string.beauty_radio_face_shape, FaceParam.FACE_BEAUTY_SHAPE);
|
|
||||||
map.put(R.string.beauty_radio_filter, FaceParam.FACE_BEAUTY_FILTER);
|
|
||||||
map.put(R.string.beauty_radio_style, FaceParam.FACE_BEAUTY_STYLE);
|
|
||||||
setContainerRecycler(FaceBeautySource.buildSkinParams());
|
|
||||||
changeRecyclerItemCount(2);
|
|
||||||
setTab(createTabs(map));
|
|
||||||
menuGroup.setVisibility(GONE);
|
|
||||||
titleLayout.setVisibility(GONE);
|
|
||||||
back.setVisibility(GONE);
|
|
||||||
menu2Back.setVisibility(GONE);
|
|
||||||
menu2.setVisibility(VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置主菜单
|
* 配置主菜单
|
||||||
*/
|
*/
|
||||||
@ -310,26 +287,12 @@ 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 (FaceSPUtils.getInstance().getString(StyleViewHolder.class.getSimpleName() + "_") != null && (int) tab.getTag() == FaceParam.FACE_BEAUTY_STYLE) {
|
|
||||||
ToastUtil.show("请先重置风格推荐");
|
|
||||||
tab.select();
|
|
||||||
changeRecyclerItemCount(5);
|
|
||||||
setContainerRecycler(FaceBeautySource.buildStylesParams());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
Object tabTag = tab.getTag();
|
Object tabTag = tab.getTag();
|
||||||
if (tabTag instanceof Integer) {
|
if (tabTag instanceof Integer) {
|
||||||
if (FaceSPUtils.getInstance().getString(StyleViewHolder.class.getSimpleName() + "_") != null && (int) tab.getTag() < FaceParam.FACE_BEAUTY_STYLE) {
|
|
||||||
ToastUtil.show("请先重置风格推荐");
|
|
||||||
tabLayout.getTabAt(3).select();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch ((int) tab.getTag()) {
|
switch ((int) tab.getTag()) {
|
||||||
case FaceParam.FACE_BEAUTY_SKIN:
|
case FaceParam.FACE_BEAUTY_SKIN:
|
||||||
changeRecyclerItemCount(2);
|
changeRecyclerItemCount(2);
|
||||||
@ -444,8 +407,7 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper
|
|||||||
containerRecycler.setLayoutManager(new GridLayoutManager(mContext, 2));
|
containerRecycler.setLayoutManager(new GridLayoutManager(mContext, 2));
|
||||||
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());
|
|
||||||
containerAdapter.setList(list);
|
containerAdapter.setList(list);
|
||||||
containerAdapter.notifyDataSetChanged();
|
containerAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,11 @@ public class FURenderer extends IFURenderer {
|
|||||||
|
|
||||||
|
|
||||||
/* 特效FURenderKit*/
|
/* 特效FURenderKit*/
|
||||||
public FURenderKit mFURenderKit;
|
private FURenderKit mFURenderKit;
|
||||||
|
|
||||||
/* AI道具*/
|
/* AI道具*/
|
||||||
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
|
private String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
|
||||||
public static 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 */
|
||||||
private Long mGlThreadId = 0L;
|
private Long mGlThreadId = 0L;
|
||||||
@ -87,8 +87,8 @@ public class FURenderer extends IFURenderer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setup(Context context) {
|
public void setup(Context context) {
|
||||||
FURenderManager.setKitDebug(FULogger.LogLevel.INFO);
|
FURenderManager.setKitDebug(FULogger.LogLevel.OFF);
|
||||||
FURenderManager.setCoreDebug(FULogger.LogLevel.INFO);
|
FURenderManager.setCoreDebug(FULogger.LogLevel.OFF);
|
||||||
FURenderManager.registerFURender(context, Authpack.A(), new OperateCallback() {
|
FURenderManager.registerFURender(context, Authpack.A(), new OperateCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(int i, @NotNull String s) {
|
public void onSuccess(int i, @NotNull String s) {
|
||||||
|
@ -5,8 +5,6 @@ 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;
|
||||||
@ -40,7 +38,4 @@ public class FaceSPUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Map<String, ?> getAll(){
|
|
||||||
return mSharedPreferences.getAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -314,35 +314,6 @@ public class FileUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String copyAssetsFile(Context context, String assetsPath, String fileName, String saveFileDir) {
|
|
||||||
File fileDir = new File(saveFileDir);
|
|
||||||
if (!fileDir.exists()) {
|
|
||||||
fileDir.mkdirs();
|
|
||||||
}
|
|
||||||
File file = new File(fileDir, fileName);
|
|
||||||
if (file.exists()) {
|
|
||||||
return file.getAbsolutePath();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
InputStream inputStream = context.getAssets().open(assetsPath);
|
|
||||||
FileOutputStream fos = new FileOutputStream(file);
|
|
||||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
|
||||||
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
|
||||||
byte[] byteArray = new byte[1024];
|
|
||||||
int bytes = bis.read(byteArray);
|
|
||||||
while (bytes > 0) {
|
|
||||||
bos.write(byteArray, 0, bytes);
|
|
||||||
bos.flush();
|
|
||||||
bytes = bis.read(byteArray);
|
|
||||||
}
|
|
||||||
bos.close();
|
|
||||||
fos.close();
|
|
||||||
return file.getAbsolutePath();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取Uri文件绝对路径
|
* 获取Uri文件绝对路径
|
||||||
@ -551,7 +522,6 @@ public class FileUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 遍历一个文件夹获取改文件夹下所有文件名
|
* 遍历一个文件夹获取改文件夹下所有文件名
|
||||||
*
|
|
||||||
* @param path
|
* @param path
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -593,7 +563,7 @@ public class FileUtils {
|
|||||||
* @param path String
|
* @param path String
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public static Boolean checkIsVideo(Context context, String path) {
|
public static Boolean checkIsVideo(Context context,String path) {
|
||||||
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
||||||
try {
|
try {
|
||||||
retriever.setDataSource(context, Uri.fromFile(new File(path)));
|
retriever.setDataSource(context, Uri.fromFile(new File(path)));
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.yunbao.common.utils;
|
package com.yunbao.faceunity.utils;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -152,36 +151,16 @@ public class ZipUtils {
|
|||||||
* @param zipFileString 解压完成的Zip路径
|
* @param zipFileString 解压完成的Zip路径
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static void zipFolder(List<String> srcFileString, String zipFileString, List<String> filters, Runnable runnable) throws Exception {
|
public static void zipFolder(String srcFileString, String zipFileString) throws Exception {
|
||||||
if (filters == null) {
|
|
||||||
filters = new ArrayList<>();
|
|
||||||
}
|
|
||||||
filters.add(new File(zipFileString).getAbsolutePath());
|
|
||||||
final List<String> tmp = new ArrayList<>(filters);
|
|
||||||
//创建ZIP
|
//创建ZIP
|
||||||
ZipOutputStream outZip = new ZipOutputStream(new FileOutputStream(zipFileString));
|
ZipOutputStream outZip = new ZipOutputStream(new FileOutputStream(zipFileString));
|
||||||
|
//创建文件
|
||||||
new Thread(new Runnable() {
|
File file = new File(srcFileString);
|
||||||
@Override
|
//压缩
|
||||||
public void run() {
|
zipFiles(file.getParent() + File.separator, file.getName(), outZip);
|
||||||
try {
|
//完成和关闭
|
||||||
for (String src : srcFileString) {
|
outZip.finish();
|
||||||
File file = new File(src);
|
outZip.close();
|
||||||
//压缩
|
|
||||||
zipFiles(file.getParent() + File.separator, file.getName(), outZip, tmp);
|
|
||||||
}
|
|
||||||
//创建文件
|
|
||||||
//完成和关闭
|
|
||||||
outZip.finish();
|
|
||||||
outZip.close();
|
|
||||||
runnable.run();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,15 +171,9 @@ public class ZipUtils {
|
|||||||
* @param zipOutputSteam
|
* @param zipOutputSteam
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private static void zipFiles(String folderString, String fileString, ZipOutputStream zipOutputSteam, List<String> filters) throws Exception {
|
private static void zipFiles(String folderString, String fileString, ZipOutputStream zipOutputSteam) throws Exception {
|
||||||
if (zipOutputSteam == null)
|
if (zipOutputSteam == null)
|
||||||
return;
|
return;
|
||||||
for (String filter : filters) {
|
|
||||||
if (fileString.startsWith(filter)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("压缩文件:" + folderString + "|" + fileString);
|
|
||||||
File file = new File(folderString + fileString);
|
File file = new File(folderString + fileString);
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
ZipEntry zipEntry = new ZipEntry(fileString);
|
ZipEntry zipEntry = new ZipEntry(fileString);
|
||||||
@ -223,7 +196,7 @@ public class ZipUtils {
|
|||||||
}
|
}
|
||||||
//子文件和递归
|
//子文件和递归
|
||||||
for (int i = 0; i < fileList.length; i++) {
|
for (int i = 0; i < fileList.length; i++) {
|
||||||
zipFiles(folderString, fileString + File.separator + fileList[i], zipOutputSteam, filters);
|
zipFiles(folderString, fileString + File.separator + fileList[i], zipOutputSteam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.yunbao.faceunity.entity.net.FineStickerEntity;
|
import com.yunbao.faceunity.entity.net.FineStickerEntity;
|
||||||
import com.yunbao.faceunity.utils.FaceUnityData;
|
import com.yunbao.faceunity.utils.FaceUnityData;
|
||||||
import com.yunbao.faceunity.utils.FileUtils;
|
import com.yunbao.faceunity.utils.FileUtils;
|
||||||
import com.yunbao.common.utils.ZipUtils;
|
import com.yunbao.faceunity.utils.ZipUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -59,7 +59,6 @@
|
|||||||
android:id="@+id/titleLayout"
|
android:id="@+id/titleLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
>
|
>
|
||||||
|
|
||||||
@ -179,11 +178,11 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:visibility="visible">
|
android:visibility="gone">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="35dp"
|
android:layout_height="25dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
@ -203,7 +202,7 @@
|
|||||||
|
|
||||||
<HorizontalScrollView
|
<HorizontalScrollView
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:layout_marginEnd="10dp"
|
android:layout_marginEnd="10dp"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
@ -215,8 +214,6 @@
|
|||||||
app:tabMaxWidth="100dp"
|
app:tabMaxWidth="100dp"
|
||||||
app:tabMode="scrollable"
|
app:tabMode="scrollable"
|
||||||
app:tabSelectedTextColor="#F6F7FB"
|
app:tabSelectedTextColor="#F6F7FB"
|
||||||
app:tabIndicatorColor="#F6F7FB"
|
|
||||||
app:tabIndicatorFullWidth="false"
|
|
||||||
app:tabTextColor="#9A9A9A" />
|
app:tabTextColor="#9A9A9A" />
|
||||||
</HorizontalScrollView>
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 422 B |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_animoji.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 2.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_beauty.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 1.3 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_beauty_body.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 1.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_big_head.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 2.4 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_fine_sticker.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 2.2 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_makeup.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 1.9 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_sticker.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 1.9 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_baihu.png
Normal file
After Width: | Height: | Size: 276 KiB |
Before Width: | Height: | Size: 58 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_baimao.png
Normal file
After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 163 KiB |
Before Width: | Height: | Size: 131 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_douniuquan.png
Normal file
After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 8.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_frog_st.png
Normal file
After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 7.9 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_hashiqi.png
Normal file
After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_hetun.png
Normal file
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 9.1 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_huangya.png
Normal file
After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 8.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_kaola.png
Normal file
After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 14 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_kuloutou.png
Normal file
After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 9.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_qgirl.png
Normal file
After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 5.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_wuxia.png
Normal file
After Width: | Height: | Size: 128 KiB |
Before Width: | Height: | Size: 107 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_baozi.png
Normal file
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_bluebird.png
Normal file
After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 8.7 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_fenhudie.png
Normal file
After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 9.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_lanhudie.png
Normal file
After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 9.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_tiger.png
Normal file
After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 19 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_tiger_bai.png
Normal file
After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_tiger_huang.png
Normal file
After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_xiongmao.png
Normal file
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 16 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_avatar_female.png
Normal file
After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_avatar_male.png
Normal file
After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 6.1 KiB |