update
This commit is contained in:
parent
05f598fd22
commit
e4cd95951c
@ -1,9 +1,11 @@
|
|||||||
package com.shayu.onetoone.activity.message;
|
package com.shayu.onetoone.activity.message;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
@ -13,15 +15,28 @@ import com.alibaba.android.arouter.facade.annotation.Route;
|
|||||||
import com.shayu.onetoone.R;
|
import com.shayu.onetoone.R;
|
||||||
import com.shayu.onetoone.activity.AbsOTOActivity;
|
import com.shayu.onetoone.activity.AbsOTOActivity;
|
||||||
import com.shayu.onetoone.adapter.MsgGreetConfigAdapter;
|
import com.shayu.onetoone.adapter.MsgGreetConfigAdapter;
|
||||||
import com.shayu.onetoone.bean.MsgGreetConfigBean;
|
import com.shayu.onetoone.bean.AvatarBean;
|
||||||
|
import com.shayu.onetoone.bean.GreetBean;
|
||||||
|
import com.shayu.onetoone.manager.OTONetManager;
|
||||||
import com.shayu.onetoone.manager.RouteManager;
|
import com.shayu.onetoone.manager.RouteManager;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.bean.HttpCallbackModel;
|
||||||
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
|
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||||
|
import com.yunbao.common.utils.ProcessImageUtil;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打招呼设置界面
|
* 打招呼设置界面
|
||||||
*/
|
*/
|
||||||
@Route(path = RouteManager.ACTIVITY_MSG_MORE_CONFIG_ACTIVITY)
|
@Route(path = RouteManager.ACTIVITY_MSG_MORE_CONFIG_ACTIVITY)
|
||||||
public class MsgMoreConfigActivity extends AbsOTOActivity {
|
public class MsgMoreConfigActivity extends AbsOTOActivity {
|
||||||
|
List<GreetBean> deleteList = new ArrayList<>();
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
MsgGreetConfigAdapter adapter;
|
MsgGreetConfigAdapter adapter;
|
||||||
SwitchCompat msgSwitch;
|
SwitchCompat msgSwitch;
|
||||||
@ -29,6 +44,8 @@ public class MsgMoreConfigActivity extends AbsOTOActivity {
|
|||||||
View editLayout;
|
View editLayout;
|
||||||
Button cancel, apply;
|
Button cancel, apply;
|
||||||
|
|
||||||
|
ProcessImageUtil imageUtil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
return R.layout.activity_msg_config;
|
return R.layout.activity_msg_config;
|
||||||
@ -37,6 +54,7 @@ public class MsgMoreConfigActivity extends AbsOTOActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void main(Bundle savedInstanceState) {
|
protected void main(Bundle savedInstanceState) {
|
||||||
setTitle("打招呼設置");
|
setTitle("打招呼設置");
|
||||||
|
imageUtil = new ProcessImageUtil(this);
|
||||||
recyclerView = findViewById(R.id.msg_recyclerView);
|
recyclerView = findViewById(R.id.msg_recyclerView);
|
||||||
msgSwitch = findViewById(R.id.msg_switch);
|
msgSwitch = findViewById(R.id.msg_switch);
|
||||||
add = findViewById(R.id.add_msg);
|
add = findViewById(R.id.add_msg);
|
||||||
@ -47,21 +65,148 @@ public class MsgMoreConfigActivity extends AbsOTOActivity {
|
|||||||
adapter = new MsgGreetConfigAdapter(this);
|
adapter = new MsgGreetConfigAdapter(this);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
adapter.setDeleteListener((size, position) -> {
|
adapter.setDeleteListener((bean, position) -> {
|
||||||
if (size >= 10) {
|
if (position >= 10) {
|
||||||
add.setVisibility(View.GONE);
|
add.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
add.setVisibility(View.VISIBLE);
|
add.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
if (!StringUtil.isEmpty(bean.getId())) {
|
||||||
|
deleteList.add(bean);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
add.setOnClickListener(v -> {
|
add.setOnClickListener(v -> {
|
||||||
adapter.addItem(new MsgGreetConfigBean());
|
adapter.addItem(new GreetBean());
|
||||||
if (adapter.getItemCount() >= 10) {
|
if (adapter.getItemCount() >= 10) {
|
||||||
add.setVisibility(View.GONE);
|
add.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
msgSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> editLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE));
|
msgSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
|
editLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.setGreetConfigGreet(isChecked, null);
|
||||||
|
});
|
||||||
|
apply.setOnClickListener(v -> {
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(this::save,100);
|
||||||
|
});
|
||||||
|
cancel.setOnClickListener(v -> clearGreet());
|
||||||
|
recyclerView.setOnClickListener(v -> adapter.notifyDataSetChanged());
|
||||||
|
findViewById(R.id.upload_img).setOnClickListener(v -> {
|
||||||
|
imageUtil.getImageByAlumb();
|
||||||
|
});
|
||||||
|
initData();
|
||||||
|
imageUtil.setImageResultCallback(new ImageResultCallback() {
|
||||||
|
@Override
|
||||||
|
public void beforeCamera() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(File file) {
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.updateFile(file, new HttpCallback<AvatarBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(AvatarBean data) {
|
||||||
|
System.out.println("头像地址:" + data);
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.addMessageMoreGreetConfig(data.getAvatar(), "2", new HttpCallback<HttpCallbackModel>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(HttpCallbackModel upload) {
|
||||||
|
if (upload.getCode() == 0) {
|
||||||
|
ImgLoader.display(mContext, data.getAvatar(), (ImageView) findViewById(R.id.imageView5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearGreet() {
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.cleanMoreGreetConfig(new HttpCallback<HttpCallbackModel>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(HttpCallbackModel data) {
|
||||||
|
ToastUtil.show(data.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
ToastUtil.show(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void save() {
|
||||||
|
if (!msgSwitch.isChecked()) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (GreetBean bean : adapter.getNotEmptyList()) {
|
||||||
|
if (StringUtil.isEmpty(bean.getId())) {
|
||||||
|
addGreet(bean);
|
||||||
|
} else if (bean.isEdit()) {
|
||||||
|
editGreet(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (GreetBean bean : deleteList) {
|
||||||
|
OTONetManager.getInstance(mContext).removeMoreGreetConfig(bean.getId(), null);
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addGreet(GreetBean bean) {
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.addMessageMoreGreetConfig(bean.getContent(), bean.getType() + "", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editGreet(GreetBean bean) {
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.setMoreGreetConfig(bean.getId(), bean.getContent(), bean.getType() + "", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initData() {
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.getMessageMoreGreetConfig(new HttpCallback<List<GreetBean>>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<GreetBean> data) {
|
||||||
|
adapter.setList(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
OTONetManager.getInstance(mContext)
|
||||||
|
.getGreetConfigStatus(new HttpCallback<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Boolean data) {
|
||||||
|
msgSwitch.setChecked(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,20 @@ import android.content.Context;
|
|||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
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.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.shayu.onetoone.R;
|
import com.shayu.onetoone.R;
|
||||||
import com.shayu.onetoone.bean.MsgGreetConfigBean;
|
import com.shayu.onetoone.bean.GreetBean;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,34 +26,38 @@ import java.util.List;
|
|||||||
* 打招呼设置适配器
|
* 打招呼设置适配器
|
||||||
*/
|
*/
|
||||||
public class MsgGreetConfigAdapter extends RecyclerView.Adapter<MsgGreetConfigAdapter.ViewHolder> {
|
public class MsgGreetConfigAdapter extends RecyclerView.Adapter<MsgGreetConfigAdapter.ViewHolder> {
|
||||||
List<MsgGreetConfigBean> mList;
|
List<GreetBean> mList;
|
||||||
Context mContext;
|
Context mContext;
|
||||||
OnItemClickListener<Integer> deleteListener;
|
OnItemClickListener<GreetBean> deleteListener;
|
||||||
|
|
||||||
public MsgGreetConfigAdapter(Context mContext) {
|
public MsgGreetConfigAdapter(Context mContext) {
|
||||||
this.mContext = mContext;
|
this.mContext = mContext;
|
||||||
this.mList = new ArrayList<>();
|
this.mList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setList(List<MsgGreetConfigBean> mList) {
|
public void setList(List<GreetBean> mList) {
|
||||||
this.mList = mList;
|
this.mList = mList;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeleteListener(OnItemClickListener<Integer> deleteListener) {
|
public void setDeleteListener(OnItemClickListener<GreetBean> deleteListener) {
|
||||||
this.deleteListener = deleteListener;
|
this.deleteListener = deleteListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MsgGreetConfigBean> getNotEmptyList() {
|
public List<GreetBean> getNotEmptyList() {
|
||||||
List<MsgGreetConfigBean> tmp = new ArrayList<>();
|
List<GreetBean> tmp = new ArrayList<>();
|
||||||
for (MsgGreetConfigBean bean : mList) {
|
for (GreetBean bean : mList) {
|
||||||
if (bean.getContent() != null) {
|
if (!StringUtil.isEmpty(bean.getContent())) {
|
||||||
tmp.add(bean);
|
tmp.add(bean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GreetBean> getmList() {
|
||||||
|
return mList;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||||
@ -60,6 +67,7 @@ public class MsgGreetConfigAdapter extends RecyclerView.Adapter<MsgGreetConfigAd
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
|
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
|
||||||
viewHolder.setData(mList.get(i), i);
|
viewHolder.setData(mList.get(i), i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,9 +75,9 @@ public class MsgGreetConfigAdapter extends RecyclerView.Adapter<MsgGreetConfigAd
|
|||||||
return mList.size();
|
return mList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(MsgGreetConfigBean msgGreetConfigBean) {
|
public void addItem(GreetBean GreetBean) {
|
||||||
mList.add(msgGreetConfigBean);
|
mList.add(GreetBean);
|
||||||
notifyDataSetChanged();
|
notifyItemChanged(getItemCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
@ -83,17 +91,21 @@ public class MsgGreetConfigAdapter extends RecyclerView.Adapter<MsgGreetConfigAd
|
|||||||
edit = itemView.findViewById(R.id.edit);
|
edit = itemView.findViewById(R.id.edit);
|
||||||
del = itemView.findViewById(R.id.del);
|
del = itemView.findViewById(R.id.del);
|
||||||
editText.setEnabled(false);
|
editText.setEnabled(false);
|
||||||
|
itemView.setOnClickListener(v -> notifyDataSetChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(MsgGreetConfigBean bean, int position) {
|
public void setData(GreetBean bean, int position) {
|
||||||
del.setOnClickListener(v -> {
|
del.setOnClickListener(v -> {
|
||||||
|
mList.get(position).setContent(editText.getText().toString());
|
||||||
|
editText.setEnabled(false);
|
||||||
mList.remove(position);
|
mList.remove(position);
|
||||||
if (deleteListener != null) {
|
if (deleteListener != null) {
|
||||||
deleteListener.onItemClick(mList.size(), position);
|
deleteListener.onItemClick(bean, mList.size());
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
});
|
});
|
||||||
edit.setOnClickListener(v -> {
|
edit.setOnClickListener(v -> {
|
||||||
|
mList.get(position).setEdit(true);
|
||||||
editText.setEnabled(true);
|
editText.setEnabled(true);
|
||||||
editText.requestFocus();
|
editText.requestFocus();
|
||||||
});
|
});
|
||||||
@ -108,7 +120,6 @@ public class MsgGreetConfigAdapter extends RecyclerView.Adapter<MsgGreetConfigAd
|
|||||||
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
Log.i("编辑", "onFocusChange: " + hasFocus);
|
|
||||||
if (!hasFocus && editText.getText().toString().length() > 0) {
|
if (!hasFocus && editText.getText().toString().length() > 0) {
|
||||||
mList.get(position).setContent(editText.getText().toString());
|
mList.get(position).setContent(editText.getText().toString());
|
||||||
editText.setEnabled(false);
|
editText.setEnabled(false);
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.BaseModel;
|
||||||
|
|
||||||
|
public class AvatarBean extends BaseModel {
|
||||||
|
private String avatar;
|
||||||
|
private String avatarThumb;
|
||||||
|
|
||||||
|
public AvatarBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar() {
|
||||||
|
return avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatar(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatarThumb() {
|
||||||
|
return avatarThumb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatarThumb(String avatarThumb) {
|
||||||
|
this.avatarThumb = avatarThumb;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package com.shayu.onetoone.bean;
|
||||||
|
|
||||||
|
import com.yunbao.common.bean.BaseModel;
|
||||||
|
|
||||||
|
public class GreetBean extends BaseModel {
|
||||||
|
private String id;
|
||||||
|
private int uid;
|
||||||
|
private String content;
|
||||||
|
private int type;
|
||||||
|
private long createTime;
|
||||||
|
private long updateTime;
|
||||||
|
private int status;
|
||||||
|
private boolean isEdit;
|
||||||
|
|
||||||
|
public GreetBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUid(int uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(long createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(long updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEdit() {
|
||||||
|
return isEdit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEdit(boolean edit) {
|
||||||
|
isEdit = edit;
|
||||||
|
}
|
||||||
|
}
|
@ -1,42 +0,0 @@
|
|||||||
package com.shayu.onetoone.bean;
|
|
||||||
|
|
||||||
import com.yunbao.common.bean.BaseModel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打招呼设置
|
|
||||||
*/
|
|
||||||
public class MsgGreetConfigBean extends BaseModel {
|
|
||||||
private int id;
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
public MsgGreetConfigBean(String content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgGreetConfigBean() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getContent() {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setContent(String content) {
|
|
||||||
this.content = content;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "MsgGreetConfigBean{" +
|
|
||||||
"id=" + id +
|
|
||||||
", content='" + content + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,6 +3,8 @@ package com.shayu.onetoone.manager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.shayu.onetoone.bean.AvatarBean;
|
||||||
|
import com.shayu.onetoone.bean.GreetBean;
|
||||||
import com.shayu.onetoone.bean.JoinAnchorBean;
|
import com.shayu.onetoone.bean.JoinAnchorBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
import com.shayu.onetoone.network.API;
|
import com.shayu.onetoone.network.API;
|
||||||
@ -14,11 +16,15 @@ import com.yunbao.common.http.ResponseModel;
|
|||||||
import com.yunbao.common.http.base.HttpCallback;
|
import com.yunbao.common.http.base.HttpCallback;
|
||||||
import com.yunbao.common.utils.MD5Util;
|
import com.yunbao.common.utils.MD5Util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.functions.Consumer;
|
import io.reactivex.functions.Consumer;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.MultipartBody;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络管理类 使用参考{@link com.yunbao.common.http.live.LiveNetManager}
|
* 网络管理类 使用参考{@link com.yunbao.common.http.live.LiveNetManager}
|
||||||
@ -177,5 +183,193 @@ public class OTONetManager {
|
|||||||
}).isDisposed();
|
}).isDisposed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getMessageMoreGreetConfig(HttpCallback<List<GreetBean>> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.getMessageMoreGreetConfig()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<List<GreetBean>>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<List<GreetBean>> liveGiftBeanResponseModel) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(liveGiftBeanResponseModel.getData().getInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMessageMoreGreetConfig(String content, String type, HttpCallback<HttpCallbackModel> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.addMoreGreetConfig("1", content, type)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<BaseModel> model) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(new HttpCallbackModel(model.getData().getCode(), model.getData().getMsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMoreGreetConfig(String id, String content, String type, HttpCallback<HttpCallbackModel> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.setMoreGreetConfig(id, "1", content, type)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<BaseModel> model) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(new HttpCallbackModel(model.getData().getCode(), model.getData().getMsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMoreGreetConfig(String id, HttpCallback<HttpCallbackModel> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.removeMoreGreetConfig(id)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<BaseModel> model) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(new HttpCallbackModel(model.getData().getCode(), model.getData().getMsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanMoreGreetConfig(HttpCallback<HttpCallbackModel> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.cleanMoreGreetConfig()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<BaseModel> model) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(new HttpCallbackModel(model.getData().getCode(), model.getData().getMsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getGreetConfigStatus(HttpCallback<Boolean> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.getGreetConfigStatus()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<Integer>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<Integer> model) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(model.getData().getInfo() == 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGreetConfigGreet(boolean status, HttpCallback<HttpCallbackModel> callback) {
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.setGreetConfigGreet("1", status ? "2" : "1")
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<BaseModel>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<BaseModel> model) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(new HttpCallbackModel(model.getData().getCode(), model.getData().getMsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateFile(File file, HttpCallback<AvatarBean> callback) {
|
||||||
|
MultipartBody.Part uploadFile = createUploadFile(file);
|
||||||
|
API.get().otoApi(mContext)
|
||||||
|
.updateFile(uploadFile)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Consumer<ResponseModel<AvatarBean>>() {
|
||||||
|
@Override
|
||||||
|
public void accept(ResponseModel<AvatarBean> model) throws Exception {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onSuccess(model.getData().getInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Consumer<Throwable>() {
|
||||||
|
@Override
|
||||||
|
public void accept(Throwable throwable) throws Exception {
|
||||||
|
Log.e(TAG, "accept: ", throwable);
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onError(mContext.getString(com.yunbao.common.R.string.net_error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).isDisposed();
|
||||||
|
}
|
||||||
|
|
||||||
|
private MultipartBody.Part createUploadFile(File file) {
|
||||||
|
RequestBody requestBody = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||||
|
return MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,77 +1,24 @@
|
|||||||
package com.shayu.onetoone.network;
|
package com.shayu.onetoone.network;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.shayu.onetoone.bean.AvatarBean;
|
||||||
|
import com.shayu.onetoone.bean.GreetBean;
|
||||||
import com.shayu.onetoone.bean.JoinAnchorBean;
|
import com.shayu.onetoone.bean.JoinAnchorBean;
|
||||||
import com.shayu.onetoone.bean.UserBean;
|
import com.shayu.onetoone.bean.UserBean;
|
||||||
import com.yunbao.common.bean.ActiveModel;
|
|
||||||
import com.yunbao.common.bean.AnchorRecommendItemModel;
|
|
||||||
import com.yunbao.common.bean.AnchorRecommendModel;
|
|
||||||
import com.yunbao.common.bean.BaseModel;
|
import com.yunbao.common.bean.BaseModel;
|
||||||
import com.yunbao.common.bean.BlindBoxInfoModel;
|
|
||||||
import com.yunbao.common.bean.CheckLiveModel;
|
|
||||||
import com.yunbao.common.bean.ContributeModel;
|
|
||||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
|
||||||
import com.yunbao.common.bean.DiscountsModel;
|
|
||||||
import com.yunbao.common.bean.EnterRoomNewModel;
|
|
||||||
import com.yunbao.common.bean.FaceBookUpModel;
|
|
||||||
import com.yunbao.common.bean.FansCheckRed;
|
|
||||||
import com.yunbao.common.bean.FansGroupGiftPack;
|
|
||||||
import com.yunbao.common.bean.FansGroupGiftPackInfo;
|
|
||||||
import com.yunbao.common.bean.GiftAlreadyWallModel;
|
|
||||||
import com.yunbao.common.bean.GiftGuideModel;
|
|
||||||
import com.yunbao.common.bean.GiftNamingInfoModel;
|
|
||||||
import com.yunbao.common.bean.GiftWallGiftDetail;
|
|
||||||
import com.yunbao.common.bean.GiftWallModel;
|
|
||||||
import com.yunbao.common.bean.HourRank;
|
|
||||||
import com.yunbao.common.bean.HttpCallbackModel;
|
|
||||||
import com.yunbao.common.bean.IMLoginModel;
|
import com.yunbao.common.bean.IMLoginModel;
|
||||||
import com.yunbao.common.bean.LinkMicUserBeanV2;
|
|
||||||
import com.yunbao.common.bean.ListInfoMessageModel;
|
|
||||||
import com.yunbao.common.bean.LiveAiRobotBean;
|
|
||||||
import com.yunbao.common.bean.LiveAnchorCallMeModel;
|
|
||||||
import com.yunbao.common.bean.LiveAnchorSayModel;
|
|
||||||
import com.yunbao.common.bean.LiveDataInfoModel;
|
|
||||||
import com.yunbao.common.bean.LiveInfoModel;
|
|
||||||
import com.yunbao.common.bean.LiveRoomActivityBanner;
|
|
||||||
import com.yunbao.common.bean.LiveRoomVoteModel;
|
|
||||||
import com.yunbao.common.bean.LiveStetUpStatusModel;
|
|
||||||
import com.yunbao.common.bean.LiveTaskModel;
|
|
||||||
import com.yunbao.common.bean.LiveUserMailBoxModel;
|
|
||||||
import com.yunbao.common.bean.MedalAchievementModel;
|
|
||||||
import com.yunbao.common.bean.MsgSwitchDetailModel;
|
|
||||||
import com.yunbao.common.bean.NewPeopleInfo;
|
|
||||||
import com.yunbao.common.bean.NobleRankHideUserListModel;
|
|
||||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
|
||||||
import com.yunbao.common.bean.PkRankBean;
|
|
||||||
import com.yunbao.common.bean.PrankGiftBean;
|
|
||||||
import com.yunbao.common.bean.PrankHttpTurntableBean;
|
|
||||||
import com.yunbao.common.bean.RandomPkUserBean;
|
|
||||||
import com.yunbao.common.bean.RankPkInfoBean;
|
|
||||||
import com.yunbao.common.bean.RedPacketDetailsBean;
|
|
||||||
import com.yunbao.common.bean.RedPacketGiftModel;
|
|
||||||
import com.yunbao.common.bean.RedPacketInfoModel;
|
|
||||||
import com.yunbao.common.bean.RedPacketListBean;
|
|
||||||
import com.yunbao.common.bean.SearchModel;
|
|
||||||
import com.yunbao.common.bean.SetAttentsModel;
|
|
||||||
import com.yunbao.common.bean.SlideInBannerModel;
|
|
||||||
import com.yunbao.common.bean.StarChallengeStatusModel;
|
|
||||||
import com.yunbao.common.bean.UserAreaBean;
|
|
||||||
import com.yunbao.common.bean.UserAvatarSelectBean;
|
|
||||||
import com.yunbao.common.bean.VipModel;
|
|
||||||
import com.yunbao.common.bean.WishListGiftConfModel;
|
|
||||||
import com.yunbao.common.bean.WishListModel;
|
|
||||||
import com.yunbao.common.http.ResponseModel;
|
import com.yunbao.common.http.ResponseModel;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
|
import okhttp3.MultipartBody;
|
||||||
import retrofit2.http.Field;
|
import retrofit2.http.Field;
|
||||||
import retrofit2.http.FormUrlEncoded;
|
import retrofit2.http.FormUrlEncoded;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Multipart;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
|
import retrofit2.http.Part;
|
||||||
import retrofit2.http.Query;
|
import retrofit2.http.Query;
|
||||||
import retrofit2.http.QueryMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1v1网络接口访问 参考 {@link com.yunbao.common.http.PDLiveApi}
|
* 1v1网络接口访问 参考 {@link com.yunbao.common.http.PDLiveApi}
|
||||||
@ -115,6 +62,30 @@ public interface OneToOneApi {
|
|||||||
@Query("type") String type,
|
@Query("type") String type,
|
||||||
@Query("pushid")String pushid
|
@Query("pushid")String pushid
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@GET("/api/public/?service=Friendappinfos.getText")
|
||||||
|
Observable<ResponseModel<List<GreetBean>>> getMessageMoreGreetConfig();
|
||||||
|
@GET("/api/public/?service=Friendappinfos.addText")
|
||||||
|
Observable<ResponseModel<BaseModel>> addMoreGreetConfig( @Query("status")String status,
|
||||||
|
@Query("content")String content,
|
||||||
|
@Query("type")String type);
|
||||||
|
@GET("/api/public/?service=Friendappinfos.editText")
|
||||||
|
Observable<ResponseModel<BaseModel>> setMoreGreetConfig( @Query("id")String id,
|
||||||
|
@Query("status")String status,
|
||||||
|
@Query("content")String content,
|
||||||
|
@Query("type")String type);
|
||||||
|
@GET("/api/public/?service=Friendappinfos.delText")
|
||||||
|
Observable<ResponseModel<BaseModel>> removeMoreGreetConfig( @Query("id")String id);
|
||||||
|
@GET("/api/public/?service=Friendappinfos.cleanText")
|
||||||
|
Observable<ResponseModel<BaseModel>> cleanMoreGreetConfig();
|
||||||
|
@GET("/api/public/?service=Friendappinfos.isHolle")
|
||||||
|
Observable<ResponseModel<Integer>> getGreetConfigStatus();
|
||||||
|
@GET("/api/public/?service=Friendappinfos.setTextStatus")
|
||||||
|
Observable<ResponseModel<BaseModel>> setGreetConfigGreet( @Query("id")String id, @Query("status")String status);
|
||||||
|
|
||||||
|
@POST("/api/public/?service=Friendappinfos.updateAvatar")
|
||||||
|
@Multipart
|
||||||
|
Observable<ResponseModel<AvatarBean>> updateFile(@Part MultipartBody.Part file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,4 +44,14 @@
|
|||||||
app:layout_constraintEnd_toStartOf="@+id/del"
|
app:layout_constraintEnd_toStartOf="@+id/del"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@mipmap/ic_msg_more_config_edit" />
|
app:srcCompat="@mipmap/ic_msg_more_config_edit" />
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/add"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="29dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/del"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@mipmap/ic_msg_more_config_edit" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
x
Reference in New Issue
Block a user