update
This commit is contained in:
parent
e29ecd2845
commit
80c5609bb7
@ -72,9 +72,16 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolde
|
|||||||
seekBar.setVisibility(View.VISIBLE);
|
seekBar.setVisibility(View.VISIBLE);
|
||||||
if (seekY == 0) {
|
if (seekY == 0) {
|
||||||
seekY = seekBar.getY();
|
seekY = seekBar.getY();
|
||||||
}
|
|
||||||
seekBar.setY(seekY - DpUtil.dp2px(20));
|
seekBar.setY(seekY - DpUtil.dp2px(20));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public void hideSeekBar(){
|
||||||
|
if(seekBar.getVisibility()==View.INVISIBLE){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
seekBar.setOnProgressChangeListener(null);
|
||||||
|
seekBar.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initDataFactory() {
|
private void initDataFactory() {
|
||||||
@ -103,6 +110,7 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolde
|
|||||||
public void setList(ArrayList<? extends BaseBean> list) {
|
public void setList(ArrayList<? extends BaseBean> list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
this.selectPosition = -1;
|
this.selectPosition = -1;
|
||||||
|
hideSeekBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSelectPosition() {
|
public int getSelectPosition() {
|
||||||
@ -218,4 +226,12 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolde
|
|||||||
public String getString(String key){
|
public String getString(String key){
|
||||||
return FaceSPUtils.getInstance().getString(key);
|
return FaceSPUtils.getInstance().getString(key);
|
||||||
}
|
}
|
||||||
|
public void del(String key){
|
||||||
|
FaceSPUtils.getInstance().del(key);
|
||||||
|
}
|
||||||
|
public void reset(){
|
||||||
|
if(vh!=null){
|
||||||
|
vh.reset(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,17 @@ import com.yunbao.faceunity.R;
|
|||||||
import com.yunbao.faceunity.entity.AnimationFilterBean;
|
import com.yunbao.faceunity.entity.AnimationFilterBean;
|
||||||
import com.yunbao.faceunity.entity.BaseBean;
|
import com.yunbao.faceunity.entity.BaseBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 动画滤镜 *暂无权限
|
* 动画滤镜 *暂无权限
|
||||||
*/
|
*/
|
||||||
public class AnimViewHolder extends BaseViewHolder{
|
public class AnimViewHolder extends BaseViewHolder {
|
||||||
ImageView icon;
|
ImageView icon;
|
||||||
|
|
||||||
public AnimViewHolder(@NonNull View itemView) {
|
public AnimViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
icon =itemView.findViewById(R.id.iv_control);
|
icon = itemView.findViewById(R.id.iv_control);
|
||||||
icon.setBackgroundResource(R.drawable.bg_control_square_selector);
|
icon.setBackgroundResource(R.drawable.bg_control_square_selector);
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
adapter.getAnimojiDataFactory().onFilterSelected((AnimationFilterBean) itemView.getTag());
|
adapter.getAnimojiDataFactory().onFilterSelected((AnimationFilterBean) itemView.getTag());
|
||||||
@ -29,7 +32,7 @@ public class AnimViewHolder extends BaseViewHolder{
|
|||||||
public void setData(BaseBean data) {
|
public void setData(BaseBean data) {
|
||||||
itemView.setTag(data);
|
itemView.setTag(data);
|
||||||
icon.setImageResource(data.getImageRes());
|
icon.setImageResource(data.getImageRes());
|
||||||
icon.setSelected(getAdapterPosition()==getSelectPosition());
|
icon.setSelected(getAdapterPosition() == getSelectPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,4 +44,9 @@ public class AnimViewHolder extends BaseViewHolder{
|
|||||||
public void saveData() {
|
public void saveData() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ import com.yunbao.faceunity.R;
|
|||||||
import com.yunbao.faceunity.entity.AnimojiBean;
|
import com.yunbao.faceunity.entity.AnimojiBean;
|
||||||
import com.yunbao.faceunity.entity.BaseBean;
|
import com.yunbao.faceunity.entity.BaseBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animoji
|
* Animoji
|
||||||
*/
|
*/
|
||||||
@ -32,7 +34,7 @@ public class AnimojiViewHolder extends BaseViewHolder {
|
|||||||
icon.setImageResource(data.getImageRes());
|
icon.setImageResource(data.getImageRes());
|
||||||
int adapterPosition = getAdapterPosition();
|
int adapterPosition = getAdapterPosition();
|
||||||
int selectPosition = getSelectPosition();
|
int selectPosition = getSelectPosition();
|
||||||
if(loadData()){
|
if (loadData()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
icon.setSelected(adapterPosition == selectPosition);
|
icon.setSelected(adapterPosition == selectPosition);
|
||||||
@ -41,7 +43,7 @@ public class AnimojiViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
String data = adapter.getString(getClass().getSimpleName());
|
String data = adapter.getString(getName(this));
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
icon.setSelected(getAdapterPosition() == Integer.parseInt(data));
|
icon.setSelected(getAdapterPosition() == Integer.parseInt(data));
|
||||||
return true;
|
return true;
|
||||||
@ -51,6 +53,14 @@ public class AnimojiViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
adapter.save(getClass().getSimpleName(), String.valueOf(getAdapterPosition()));
|
adapter.save(getName(this), String.valueOf(getAdapterPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.del(getName(this));
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ public abstract class BaseViewHolder extends RecyclerView.ViewHolder {
|
|||||||
|
|
||||||
public abstract boolean loadData();
|
public abstract boolean loadData();
|
||||||
public abstract void saveData();
|
public abstract void saveData();
|
||||||
|
public abstract void reset(List<? extends BaseBean> list);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,12 @@ import com.yunbao.faceunity.entity.ModelAttributeData;
|
|||||||
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
||||||
import com.yunbao.faceunity.utils.SeekBarUtils;
|
import com.yunbao.faceunity.utils.SeekBarUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 美体
|
* 美体
|
||||||
*/
|
*/
|
||||||
public class BeautyBodyViewHolder extends BaseViewHolder{
|
public class BeautyBodyViewHolder extends BaseViewHolder {
|
||||||
private ImageView icon;
|
private ImageView icon;
|
||||||
private TextView title;
|
private TextView title;
|
||||||
private TextView value;
|
private TextView value;
|
||||||
@ -28,14 +30,14 @@ public class BeautyBodyViewHolder extends BaseViewHolder{
|
|||||||
title = itemView.findViewById(R.id.item_title);
|
title = itemView.findViewById(R.id.item_title);
|
||||||
value = itemView.findViewById(R.id.item_value);
|
value = itemView.findViewById(R.id.item_value);
|
||||||
seekBar = itemView.findViewById(R.id.item_seekBar);
|
seekBar = itemView.findViewById(R.id.item_seekBar);
|
||||||
seekBar.setOnProgressChangeListener(new DiscreteSeekBar.OnSimpleProgressChangeListener(){
|
seekBar.setOnProgressChangeListener(new DiscreteSeekBar.OnSimpleProgressChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
|
public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
|
||||||
super.onProgressChanged(seekBar, value, fromUser);
|
super.onProgressChanged(seekBar, value, fromUser);
|
||||||
BodyBeautyBean bean = (BodyBeautyBean) itemView.getTag();
|
BodyBeautyBean bean = (BodyBeautyBean) itemView.getTag();
|
||||||
double toValue = SeekBarUtils.Companion.seekToValue(bean.getModelAttributeData().getMaxRange(), value, seekBar.getMin());
|
double toValue = SeekBarUtils.Companion.seekToValue(bean.getModelAttributeData().getMaxRange(), value, seekBar.getMin());
|
||||||
BeautyBodyViewHolder.this.value.setText(String.format("%.1f",toValue));
|
BeautyBodyViewHolder.this.value.setText(String.format("%.1f", toValue));
|
||||||
adapter.getBodyBeautyDataFactory().updateParamIntensity(bean.getKey(),toValue);
|
adapter.getBodyBeautyDataFactory().updateParamIntensity(bean.getKey(), toValue);
|
||||||
saveData();
|
saveData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -46,7 +48,7 @@ public class BeautyBodyViewHolder extends BaseViewHolder{
|
|||||||
itemView.setTag(data);
|
itemView.setTag(data);
|
||||||
icon.setImageResource(data.getImageRes());
|
icon.setImageResource(data.getImageRes());
|
||||||
title.setText(data.getDesRes());
|
title.setText(data.getDesRes());
|
||||||
if(loadData()){
|
if (loadData()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ModelAttributeData attributeData = data.getModelAttributeData();
|
ModelAttributeData attributeData = data.getModelAttributeData();
|
||||||
@ -60,8 +62,8 @@ public class BeautyBodyViewHolder extends BaseViewHolder{
|
|||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
BodyBeautyBean bean = (BodyBeautyBean) itemView.getTag();
|
BodyBeautyBean bean = (BodyBeautyBean) itemView.getTag();
|
||||||
String val = adapter.getString(getName(this) + bean);
|
String val = adapter.getString(getName(this) + bean.getKey());
|
||||||
if(val==null){
|
if (val == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ModelAttributeData attributeData = bean.getModelAttributeData();
|
ModelAttributeData attributeData = bean.getModelAttributeData();
|
||||||
@ -76,7 +78,16 @@ public class BeautyBodyViewHolder extends BaseViewHolder{
|
|||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
BodyBeautyBean bean = (BodyBeautyBean) itemView.getTag();
|
BodyBeautyBean bean = (BodyBeautyBean) itemView.getTag();
|
||||||
String key=getName(this)+bean.getKey();
|
String key = getName(this) + bean.getKey();
|
||||||
adapter.save(key, (String) value.getText());
|
adapter.save(key, (String) value.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
String name = getName(this);
|
||||||
|
for (BaseBean bean : list) {
|
||||||
|
adapter.del(name + bean.getKey());
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ import com.yunbao.faceunity.entity.ModelAttributeData;
|
|||||||
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
||||||
import com.yunbao.faceunity.utils.SeekBarUtils;
|
import com.yunbao.faceunity.utils.SeekBarUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 美型
|
* 美型
|
||||||
*/
|
*/
|
||||||
@ -80,4 +82,13 @@ public class BeautyShapeViewHolder extends BaseViewHolder {
|
|||||||
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
||||||
adapter.save(getName(this)+bean.getKey(), (String) value.getText());
|
adapter.save(getName(this)+bean.getKey(), (String) value.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
String name = getName(this);
|
||||||
|
for (BaseBean bean : list) {
|
||||||
|
adapter.del(name+bean.getKey());
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ import com.yunbao.faceunity.entity.ModelAttributeData;
|
|||||||
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
||||||
import com.yunbao.faceunity.utils.SeekBarUtils;
|
import com.yunbao.faceunity.utils.SeekBarUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 美肤
|
* 美肤
|
||||||
*/
|
*/
|
||||||
@ -81,4 +83,11 @@ public class BeautySkinViewHolder extends BaseViewHolder{
|
|||||||
String val= (String) value.getText();
|
String val= (String) value.getText();
|
||||||
adapter.save(getName(this)+key,val);
|
adapter.save(getName(this)+key,val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
for (BaseBean bean : list) {
|
||||||
|
adapter.del(getName(this)+bean.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ import com.yunbao.faceunity.entity.BaseBean;
|
|||||||
import com.yunbao.faceunity.entity.FunctionEnum;
|
import com.yunbao.faceunity.entity.FunctionEnum;
|
||||||
import com.yunbao.faceunity.entity.PropBean;
|
import com.yunbao.faceunity.entity.PropBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 大头
|
* 大头
|
||||||
*/
|
*/
|
||||||
@ -35,6 +37,7 @@ public class BigHeadViewHolder extends BaseViewHolder {
|
|||||||
if(loadData()){
|
if(loadData()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAdapterPosition() == 0) {
|
if (getAdapterPosition() == 0) {
|
||||||
icon.setBackgroundResource(R.drawable.bg_control_oval2_selector);
|
icon.setBackgroundResource(R.drawable.bg_control_oval2_selector);
|
||||||
}
|
}
|
||||||
@ -62,4 +65,11 @@ public class BigHeadViewHolder extends BaseViewHolder {
|
|||||||
PropBean bean = (PropBean) itemView.getTag();
|
PropBean bean = (PropBean) itemView.getTag();
|
||||||
adapter.save(getName(this),bean.getKey());
|
adapter.save(getName(this),bean.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.del(getName(this));
|
||||||
|
itemView.callOnClick();
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ 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 java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 滤镜
|
* 滤镜
|
||||||
*/
|
*/
|
||||||
@ -22,8 +24,8 @@ public class FilterViewHolder extends BaseViewHolder {
|
|||||||
icon = itemView.findViewById(R.id.iv_control);
|
icon = itemView.findViewById(R.id.iv_control);
|
||||||
title = itemView.findViewById(R.id.tv_control);
|
title = itemView.findViewById(R.id.tv_control);
|
||||||
itemView.setOnClickListener(view -> {
|
itemView.setOnClickListener(view -> {
|
||||||
FaceBeautyFilterBean bean= (FaceBeautyFilterBean) itemView.getTag();
|
FaceBeautyFilterBean bean = (FaceBeautyFilterBean) itemView.getTag();
|
||||||
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(),bean.getIntensity(),bean.getDesRes());
|
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(), bean.getIntensity(), bean.getDesRes());
|
||||||
setSelectPosition(getAdapterPosition());
|
setSelectPosition(getAdapterPosition());
|
||||||
saveData();
|
saveData();
|
||||||
});
|
});
|
||||||
@ -34,33 +36,40 @@ public class FilterViewHolder extends BaseViewHolder {
|
|||||||
itemView.setTag(data);
|
itemView.setTag(data);
|
||||||
icon.setImageResource(data.getImageRes());
|
icon.setImageResource(data.getImageRes());
|
||||||
title.setText(data.getDesRes());
|
title.setText(data.getDesRes());
|
||||||
if(loadData()){
|
if (loadData()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
icon.setSelected(getSelectPosition()==getAdapterPosition());
|
icon.setSelected(getSelectPosition() == getAdapterPosition());
|
||||||
title.setSelected(getSelectPosition()==getAdapterPosition());
|
title.setSelected(getSelectPosition() == getAdapterPosition());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
FaceBeautyFilterBean bean= (FaceBeautyFilterBean) itemView.getTag();
|
FaceBeautyFilterBean bean = (FaceBeautyFilterBean) itemView.getTag();
|
||||||
String val = adapter.getString(getName(this));
|
String val = adapter.getString(getName(this));
|
||||||
if(val==null){
|
if (val == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!val.equals(bean.getKey())){
|
if (!val.equals(bean.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
icon.setSelected(true);
|
icon.setSelected(true);
|
||||||
title.setSelected(true);
|
title.setSelected(true);
|
||||||
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(),bean.getIntensity(),bean.getDesRes());
|
adapter.getFaceBeautyDataFactory().onFilterSelected(bean.getKey(), bean.getIntensity(), bean.getDesRes());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
FaceBeautyFilterBean bean= (FaceBeautyFilterBean) itemView.getTag();
|
FaceBeautyFilterBean bean = (FaceBeautyFilterBean) itemView.getTag();
|
||||||
adapter.save(getName(this),bean.getKey());
|
adapter.save(getName(this), bean.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.del(getName(this));
|
||||||
|
itemView.callOnClick();
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ import com.yunbao.faceunity.entity.BaseBean;
|
|||||||
import com.yunbao.faceunity.entity.net.FineStickerEntity;
|
import com.yunbao.faceunity.entity.net.FineStickerEntity;
|
||||||
import com.yunbao.faceunity.utils.net.StickerDownloadHelper;
|
import com.yunbao.faceunity.utils.net.StickerDownloadHelper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精品贴纸
|
* 精品贴纸
|
||||||
*/
|
*/
|
||||||
@ -65,6 +67,13 @@ public class FineStickerViewHolder extends BaseViewHolder implements StickerDown
|
|||||||
adapter.save(getName(this), bean.getKey());
|
adapter.save(getName(this), bean.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.del(getName(this));
|
||||||
|
itemView.callOnClick();
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGetTags(String[] tags) {
|
public void onGetTags(String[] tags) {
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ import com.yunbao.faceunity.entity.MakeupCustomBean;
|
|||||||
import com.yunbao.faceunity.repo.MakeupSource;
|
import com.yunbao.faceunity.repo.MakeupSource;
|
||||||
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
||||||
private ImageView icon;
|
private ImageView icon;
|
||||||
private TextView title;
|
private TextView title;
|
||||||
@ -73,7 +75,7 @@ public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
|||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
MakeupCustomBean bean = (MakeupCustomBean) itemView.getTag();
|
MakeupCustomBean bean = (MakeupCustomBean) itemView.getTag();
|
||||||
String model = adapter.getString(getName(this) + "_model");
|
String model = adapter.getString(getName(this));
|
||||||
String val = adapter.getString(getName(this) + bean.getKey() + "_val");
|
String val = adapter.getString(getName(this) + bean.getKey() + "_val");
|
||||||
if (model == null || val == null) {
|
if (model == null || val == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -104,10 +106,20 @@ public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
|||||||
if(key==null){
|
if(key==null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adapter.save(getName(this) + "_model", key);
|
adapter.save(getName(this), key);
|
||||||
adapter.save(getName(this) + bean.getKey() + "_val", adapter.getSeekBar().getProgress() + "");
|
adapter.save(getName(this) + bean.getKey() + "_val", adapter.getSeekBar().getProgress() + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.del(getName(this));
|
||||||
|
for (BaseBean bean : list) {
|
||||||
|
adapter.del(getName(this) + bean.getKey() + "_val");
|
||||||
|
}
|
||||||
|
itemView.callOnClick();
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
|
}
|
||||||
|
|
||||||
public String getMakeupKey(int beanType) {
|
public String getMakeupKey(int beanType) {
|
||||||
String key = null;
|
String key = null;
|
||||||
switch (beanType) {
|
switch (beanType) {
|
||||||
|
@ -10,6 +10,8 @@ import com.yunbao.faceunity.R;
|
|||||||
import com.yunbao.faceunity.entity.BaseBean;
|
import com.yunbao.faceunity.entity.BaseBean;
|
||||||
import com.yunbao.faceunity.entity.MakeupCombinationBean;
|
import com.yunbao.faceunity.entity.MakeupCombinationBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 美妆
|
* 美妆
|
||||||
*/
|
*/
|
||||||
@ -47,6 +49,17 @@ public class MakeupViewHolder extends BaseViewHolder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
|
MakeupCombinationBean bean = (MakeupCombinationBean) itemView.getTag();
|
||||||
|
String val = adapter.getString(getName(this));
|
||||||
|
if(val==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!val.equals(bean.getKey())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
icon.setSelected(true);
|
||||||
|
title.setSelected(true);
|
||||||
|
adapter.getMakeupDataFactory().onMakeupCombinationSelected(bean);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -56,4 +69,9 @@ public class MakeupViewHolder extends BaseViewHolder {
|
|||||||
MakeupCombinationBean bean = (MakeupCombinationBean) itemView.getTag();
|
MakeupCombinationBean bean = (MakeupCombinationBean) itemView.getTag();
|
||||||
adapter.save(getName(this),bean.getKey());
|
adapter.save(getName(this),bean.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean>list) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ import com.yunbao.faceunity.entity.BaseBean;
|
|||||||
import com.yunbao.faceunity.entity.FunctionEnum;
|
import com.yunbao.faceunity.entity.FunctionEnum;
|
||||||
import com.yunbao.faceunity.entity.PropBean;
|
import com.yunbao.faceunity.entity.PropBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 普通贴纸
|
* 普通贴纸
|
||||||
*/
|
*/
|
||||||
@ -23,6 +25,7 @@ public class StickerViewHolder extends BaseViewHolder{
|
|||||||
adapter.getPropDataFactory().setPropType(FunctionEnum.STICKER);
|
adapter.getPropDataFactory().setPropType(FunctionEnum.STICKER);
|
||||||
adapter.getPropDataFactory().onItemSelected(bean);
|
adapter.getPropDataFactory().onItemSelected(bean);
|
||||||
setSelectPosition(getAdapterPosition());
|
setSelectPosition(getAdapterPosition());
|
||||||
|
saveData();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +33,9 @@ public class StickerViewHolder extends BaseViewHolder{
|
|||||||
public void setData(BaseBean data) {
|
public void setData(BaseBean data) {
|
||||||
itemView.setTag(data);
|
itemView.setTag(data);
|
||||||
icon.setImageResource(data.getImageRes());
|
icon.setImageResource(data.getImageRes());
|
||||||
|
if(loadData()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(getAdapterPosition()==0){
|
if(getAdapterPosition()==0){
|
||||||
icon.setBackgroundResource(R.drawable.bg_control_oval2_selector);
|
icon.setBackgroundResource(R.drawable.bg_control_oval2_selector);
|
||||||
}
|
}
|
||||||
@ -38,12 +44,31 @@ public class StickerViewHolder extends BaseViewHolder{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
|
PropBean bean= (PropBean) itemView.getTag();
|
||||||
|
String val = adapter.getString(getName(this));
|
||||||
|
if(val==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!val.equals(bean.getKey())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
icon.setSelected(true);
|
||||||
|
adapter.getPropDataFactory().setPropType(FunctionEnum.STICKER);
|
||||||
|
adapter.getPropDataFactory().onItemSelected(bean);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
|
PropBean bean= (PropBean) itemView.getTag();
|
||||||
|
adapter.save(getName(this),bean.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.del(getName(this));
|
||||||
|
itemView.callOnClick();
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ 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 java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 风格推荐
|
* 风格推荐
|
||||||
*/
|
*/
|
||||||
@ -23,6 +25,7 @@ public class StyleViewHolder extends BaseViewHolder{
|
|||||||
BaseBean bean= (BaseBean) itemView.getTag();
|
BaseBean bean= (BaseBean) itemView.getTag();
|
||||||
adapter.getFaceBeautyDataFactory().onStyleSelected(bean.getKey());
|
adapter.getFaceBeautyDataFactory().onStyleSelected(bean.getKey());
|
||||||
setSelectPosition(getAdapterPosition());
|
setSelectPosition(getAdapterPosition());
|
||||||
|
saveData();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,18 +34,40 @@ public class StyleViewHolder extends BaseViewHolder{
|
|||||||
itemView.setTag(data);
|
itemView.setTag(data);
|
||||||
icon.setImageResource(data.getImageRes());
|
icon.setImageResource(data.getImageRes());
|
||||||
title.setText(data.getDesRes());
|
title.setText(data.getDesRes());
|
||||||
|
if(loadData()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
icon.setSelected(getSelectPosition()==getAdapterPosition());
|
icon.setSelected(getSelectPosition()==getAdapterPosition());
|
||||||
title.setSelected(getSelectPosition()==getAdapterPosition());
|
title.setSelected(getSelectPosition()==getAdapterPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadData() {
|
public boolean loadData() {
|
||||||
|
BaseBean bean= (BaseBean) itemView.getTag();
|
||||||
|
String val = adapter.getString(getName(this));
|
||||||
|
if(val==null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(!val.equals(bean.getKey())){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
icon.setSelected(true);
|
||||||
|
title.setSelected(true);
|
||||||
|
adapter.getFaceBeautyDataFactory().onStyleSelected(bean.getKey());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveData() {
|
public void saveData() {
|
||||||
|
BaseBean bean= (BaseBean) itemView.getTag();
|
||||||
|
adapter.save(getName(this),bean.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(List<? extends BaseBean> list) {
|
||||||
|
adapter.del(getName(this));
|
||||||
|
itemView.callOnClick();
|
||||||
|
adapter.setSelectPosition(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,9 @@ public class FaceUnityView extends LinearLayout implements StickerDownloadHelper
|
|||||||
ArrayList<MakeupCustomClassBean> list = MakeupSource.buildCustomClasses();
|
ArrayList<MakeupCustomClassBean> list = MakeupSource.buildCustomClasses();
|
||||||
setTab(createTabs(list));
|
setTab(createTabs(list));
|
||||||
});
|
});
|
||||||
|
menu2Reset.setOnClickListener(view -> {
|
||||||
|
containerAdapter.reset();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goBackMainMenu() {
|
private void goBackMainMenu() {
|
||||||
|
@ -26,4 +26,8 @@ public class FaceSPUtils {
|
|||||||
public boolean saveBool(String key,boolean value){
|
public boolean saveBool(String key,boolean value){
|
||||||
return mSharedPreferences.getBoolean(key,false);
|
return mSharedPreferences.getBoolean(key,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void del(String key) {
|
||||||
|
mSharedPreferences.edit().remove(key).apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user