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);
|
||||
if (seekY == 0) {
|
||||
seekY = seekBar.getY();
|
||||
}
|
||||
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() {
|
||||
@ -103,6 +110,7 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolde
|
||||
public void setList(ArrayList<? extends BaseBean> list) {
|
||||
this.list = list;
|
||||
this.selectPosition = -1;
|
||||
hideSeekBar();
|
||||
}
|
||||
|
||||
public int getSelectPosition() {
|
||||
@ -218,4 +226,12 @@ public class ContainerRecyclerAdapter extends RecyclerView.Adapter<BaseViewHolde
|
||||
public String getString(String 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,11 +9,14 @@ import com.yunbao.faceunity.R;
|
||||
import com.yunbao.faceunity.entity.AnimationFilterBean;
|
||||
import com.yunbao.faceunity.entity.BaseBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 动画滤镜 *暂无权限
|
||||
*/
|
||||
public class AnimViewHolder extends BaseViewHolder {
|
||||
ImageView icon;
|
||||
|
||||
public AnimViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.iv_control);
|
||||
@ -41,4 +44,9 @@ public class AnimViewHolder extends BaseViewHolder{
|
||||
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.BaseBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Animoji
|
||||
*/
|
||||
@ -41,7 +43,7 @@ public class AnimojiViewHolder extends BaseViewHolder {
|
||||
|
||||
@Override
|
||||
public boolean loadData() {
|
||||
String data = adapter.getString(getClass().getSimpleName());
|
||||
String data = adapter.getString(getName(this));
|
||||
if (data != null) {
|
||||
icon.setSelected(getAdapterPosition() == Integer.parseInt(data));
|
||||
return true;
|
||||
@ -51,6 +53,14 @@ public class AnimojiViewHolder extends BaseViewHolder {
|
||||
|
||||
@Override
|
||||
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 void saveData();
|
||||
public abstract void reset(List<? extends BaseBean> list);
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import com.yunbao.faceunity.entity.ModelAttributeData;
|
||||
import com.yunbao.faceunity.seekbar.DiscreteSeekBar;
|
||||
import com.yunbao.faceunity.utils.SeekBarUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 美体
|
||||
*/
|
||||
@ -60,7 +62,7 @@ public class BeautyBodyViewHolder extends BaseViewHolder{
|
||||
@Override
|
||||
public boolean loadData() {
|
||||
BodyBeautyBean bean = (BodyBeautyBean) itemView.getTag();
|
||||
String val = adapter.getString(getName(this) + bean);
|
||||
String val = adapter.getString(getName(this) + bean.getKey());
|
||||
if (val == null) {
|
||||
return false;
|
||||
}
|
||||
@ -79,4 +81,13 @@ public class BeautyBodyViewHolder extends BaseViewHolder{
|
||||
String key = getName(this) + bean.getKey();
|
||||
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.utils.SeekBarUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 美型
|
||||
*/
|
||||
@ -80,4 +82,13 @@ public class BeautyShapeViewHolder extends BaseViewHolder {
|
||||
FaceBeautyBean bean = (FaceBeautyBean) itemView.getTag();
|
||||
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.utils.SeekBarUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 美肤
|
||||
*/
|
||||
@ -81,4 +83,11 @@ public class BeautySkinViewHolder extends BaseViewHolder{
|
||||
String val= (String) value.getText();
|
||||
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.PropBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 大头
|
||||
*/
|
||||
@ -35,6 +37,7 @@ public class BigHeadViewHolder extends BaseViewHolder {
|
||||
if(loadData()){
|
||||
return;
|
||||
}
|
||||
|
||||
if (getAdapterPosition() == 0) {
|
||||
icon.setBackgroundResource(R.drawable.bg_control_oval2_selector);
|
||||
}
|
||||
@ -62,4 +65,11 @@ public class BigHeadViewHolder extends BaseViewHolder {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import com.yunbao.faceunity.R;
|
||||
import com.yunbao.faceunity.entity.BaseBean;
|
||||
import com.yunbao.faceunity.entity.FaceBeautyFilterBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 滤镜
|
||||
*/
|
||||
@ -63,4 +65,11 @@ public class FilterViewHolder extends BaseViewHolder {
|
||||
FaceBeautyFilterBean bean = (FaceBeautyFilterBean) 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);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ import com.yunbao.faceunity.entity.BaseBean;
|
||||
import com.yunbao.faceunity.entity.net.FineStickerEntity;
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(List<? extends BaseBean> list) {
|
||||
adapter.del(getName(this));
|
||||
itemView.callOnClick();
|
||||
adapter.setSelectPosition(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
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.seekbar.DiscreteSeekBar;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
||||
private ImageView icon;
|
||||
private TextView title;
|
||||
@ -73,7 +75,7 @@ public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
||||
@Override
|
||||
public boolean loadData() {
|
||||
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");
|
||||
if (model == null || val == null) {
|
||||
return false;
|
||||
@ -104,10 +106,20 @@ public class MakeupCustomItemViewHolder extends BaseViewHolder {
|
||||
if(key==null){
|
||||
return;
|
||||
}
|
||||
adapter.save(getName(this) + "_model", key);
|
||||
adapter.save(getName(this), key);
|
||||
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) {
|
||||
String key = null;
|
||||
switch (beanType) {
|
||||
|
@ -10,6 +10,8 @@ import com.yunbao.faceunity.R;
|
||||
import com.yunbao.faceunity.entity.BaseBean;
|
||||
import com.yunbao.faceunity.entity.MakeupCombinationBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 美妆
|
||||
*/
|
||||
@ -47,6 +49,17 @@ public class MakeupViewHolder extends BaseViewHolder {
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
}
|
||||
@ -56,4 +69,9 @@ public class MakeupViewHolder extends BaseViewHolder {
|
||||
MakeupCombinationBean bean = (MakeupCombinationBean) itemView.getTag();
|
||||
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.PropBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 普通贴纸
|
||||
*/
|
||||
@ -23,6 +25,7 @@ public class StickerViewHolder extends BaseViewHolder{
|
||||
adapter.getPropDataFactory().setPropType(FunctionEnum.STICKER);
|
||||
adapter.getPropDataFactory().onItemSelected(bean);
|
||||
setSelectPosition(getAdapterPosition());
|
||||
saveData();
|
||||
});
|
||||
}
|
||||
|
||||
@ -30,6 +33,9 @@ public class StickerViewHolder extends BaseViewHolder{
|
||||
public void setData(BaseBean data) {
|
||||
itemView.setTag(data);
|
||||
icon.setImageResource(data.getImageRes());
|
||||
if(loadData()){
|
||||
return;
|
||||
}
|
||||
if(getAdapterPosition()==0){
|
||||
icon.setBackgroundResource(R.drawable.bg_control_oval2_selector);
|
||||
}
|
||||
@ -38,12 +44,31 @@ public class StickerViewHolder extends BaseViewHolder{
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
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.entity.BaseBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 风格推荐
|
||||
*/
|
||||
@ -23,6 +25,7 @@ public class StyleViewHolder extends BaseViewHolder{
|
||||
BaseBean bean= (BaseBean) itemView.getTag();
|
||||
adapter.getFaceBeautyDataFactory().onStyleSelected(bean.getKey());
|
||||
setSelectPosition(getAdapterPosition());
|
||||
saveData();
|
||||
});
|
||||
}
|
||||
|
||||
@ -31,18 +34,40 @@ public class StyleViewHolder extends BaseViewHolder{
|
||||
itemView.setTag(data);
|
||||
icon.setImageResource(data.getImageRes());
|
||||
title.setText(data.getDesRes());
|
||||
if(loadData()){
|
||||
return;
|
||||
}
|
||||
icon.setSelected(getSelectPosition()==getAdapterPosition());
|
||||
title.setSelected(getSelectPosition()==getAdapterPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
setTab(createTabs(list));
|
||||
});
|
||||
|
||||
menu2Reset.setOnClickListener(view -> {
|
||||
containerAdapter.reset();
|
||||
});
|
||||
}
|
||||
|
||||
private void goBackMainMenu() {
|
||||
|
@ -26,4 +26,8 @@ public class FaceSPUtils {
|
||||
public boolean saveBool(String key,boolean value){
|
||||
return mSharedPreferences.getBoolean(key,false);
|
||||
}
|
||||
|
||||
public void del(String key) {
|
||||
mSharedPreferences.edit().remove(key).apply();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user