From d7e4ad9aca4a04b48170ab547e137df07486a3f0 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 23 Oct 2023 14:35:18 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E9=87=91=E5=B8=81=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E7=A0=96=E7=9F=B3=EF=BC=8C=E6=98=9F=E5=B8=81=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E6=B6=88=E8=B4=B9=E8=AE=B0=E5=BD=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OneToOne/src/main/AndroidManifest.xml | 5 +- .../activity/DiamondExchangeActivity.java | 155 +++++++++++++++++- .../activity/ExchangeRecordActivity.java | 114 +++++++++++++ .../onetoone/activity/MyArnActivity.java | 4 +- .../adapter/DiamondExchangeAdapter.java | 19 ++- .../adapter/ExchangeRecordAdapter.java | 46 ++++++ .../shayu/onetoone/bean/ExchangeModel.java | 16 +- .../onetoone/bean/ExchangeRecordModel.java | 140 ++++++++++++++++ .../onetoone/event/DiamondExchangeEvent.java | 57 +++++++ .../shayu/onetoone/manager/OTONetManager.java | 66 +++++++- .../shayu/onetoone/manager/RouteManager.java | 1 + .../shayu/onetoone/network/OneToOneApi.java | 21 +++ .../view/DiamondExchangeViewHolder.java | 57 ++++++- .../view/ExchangeRecordViewHolder.java | 41 +++++ .../res/layout/activity_diamond_exchange.xml | 20 ++- .../res/layout/activity_exchange_record.xml | 62 +++++++ .../view_diamond_exchange_item_holder.xml | 2 + .../view_exchange_record_item_holder.xml | 77 +++++++++ .../main/res/mipmap-xxhdpi/icon_one_back.png | Bin 0 -> 1415 bytes OneToOne/src/main/res/values/strings.xml | 1 + 20 files changed, 891 insertions(+), 13 deletions(-) create mode 100644 OneToOne/src/main/java/com/shayu/onetoone/activity/ExchangeRecordActivity.java create mode 100644 OneToOne/src/main/java/com/shayu/onetoone/adapter/ExchangeRecordAdapter.java create mode 100644 OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeRecordModel.java create mode 100644 OneToOne/src/main/java/com/shayu/onetoone/event/DiamondExchangeEvent.java create mode 100644 OneToOne/src/main/java/com/shayu/onetoone/view/ExchangeRecordViewHolder.java create mode 100644 OneToOne/src/main/res/layout/activity_exchange_record.xml create mode 100644 OneToOne/src/main/res/layout/view_exchange_record_item_holder.xml create mode 100644 OneToOne/src/main/res/mipmap-xxhdpi/icon_one_back.png diff --git a/OneToOne/src/main/AndroidManifest.xml b/OneToOne/src/main/AndroidManifest.xml index 4f1f2dfc4..7a3c4cdb9 100644 --- a/OneToOne/src/main/AndroidManifest.xml +++ b/OneToOne/src/main/AndroidManifest.xml @@ -145,9 +145,12 @@ - + diff --git a/OneToOne/src/main/java/com/shayu/onetoone/activity/DiamondExchangeActivity.java b/OneToOne/src/main/java/com/shayu/onetoone/activity/DiamondExchangeActivity.java index 2402bee34..7aaf89663 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/activity/DiamondExchangeActivity.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/activity/DiamondExchangeActivity.java @@ -2,6 +2,11 @@ package com.shayu.onetoone.activity; import android.graphics.Color; import android.os.Bundle; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.widget.EditText; +import android.widget.TextView; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -10,11 +15,17 @@ import com.alibaba.android.arouter.facade.annotation.Route; import com.shayu.onetoone.R; import com.shayu.onetoone.adapter.DiamondExchangeAdapter; import com.shayu.onetoone.bean.ExchangeModel; +import com.shayu.onetoone.event.DiamondExchangeEvent; import com.shayu.onetoone.manager.OTONetManager; import com.shayu.onetoone.manager.RouteManager; import com.yunbao.common.custom.ItemDecoration; import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; import java.util.List; @@ -22,6 +33,12 @@ import java.util.List; public class DiamondExchangeActivity extends AbsOTOActivity { private RecyclerView diamondExchangeList; private DiamondExchangeAdapter exchangeAdapter; + private TextView title, totalConvertibility; + private String type = "yuanbao"; + + private EditText diamondExchangeInput; + private String number; + private int index = 0; @Override protected int getLayoutId() { @@ -30,23 +47,150 @@ public class DiamondExchangeActivity extends AbsOTOActivity { @Override protected void main(Bundle savedInstanceState) { + Bus.getOn(this); initView(); initData(); } + @Override + protected void onDestroy() { + super.onDestroy(); + Bus.getOff(this); + } + private void initView() { diamondExchangeList = findViewById(R.id.diamond_exchange_list); + title = findViewById(R.id.title); + diamondExchangeInput = findViewById(R.id.diamond_exchange_input); + totalConvertibility = findViewById(R.id.total_convertibility); diamondExchangeList.addItemDecoration(new ItemDecoration(mContext, Color.parseColor("#ffffff"), 10, 2)); diamondExchangeList.setLayoutManager(new GridLayoutManager(mContext, 3)); exchangeAdapter = new DiamondExchangeAdapter(); diamondExchangeList.setAdapter(exchangeAdapter); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.arn_toggle), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (TextUtils.equals(type, "yuanbao")) { + Bundle bundle = new Bundle(); + bundle.putString("type", "coin"); + RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE, bundle); + finish(); + } else { + Bundle bundle = new Bundle(); + bundle.putString("type", "yuanbao"); + RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE, bundle); + finish(); + } + + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exchange_record), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (TextUtils.equals(type, "yuanbao")) { + Bundle bundle = new Bundle(); + bundle.putString("type", "coin"); + RouteManager.forwardActivity(RouteManager.ACTIVITY_EXCHANGE_RECORD, bundle); + } else { + Bundle bundle = new Bundle(); + bundle.putString("type", "yuanbao"); + RouteManager.forwardActivity(RouteManager.ACTIVITY_EXCHANGE_RECORD, bundle); + } + + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.immediate_exchange), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + String exchangeNumber = ""; + if (TextUtils.isEmpty(number)) { + exchangeNumber = diamondExchangeInput.getText().toString(); + } else { + exchangeNumber = number; + } + OTONetManager.getInstance(mContext).getTransform(type, exchangeNumber, new HttpCallback>() { + @Override + public void onSuccess(List data) { + if (data.size() > 0) { + if ((data.size() - 1) > index && index > 0) { + data.get(index).setSelect(true); + totalConvertibility.setText(String.valueOf(data.get(0).getNum())); + number = data.get(index).getNum(); + } else { + if (TextUtils.isEmpty(diamondExchangeInput.getText().toString())) { + data.get(0).setSelect(true); + totalConvertibility.setText(String.valueOf(data.get(0).getNum())); + number = data.get(0).getNum(); + } else { + totalConvertibility.setText(String.valueOf(data.get(0).getNum())); + for (int i = 0; i < data.size(); i++) { + data.get(i).setSelect(false); + } + } + + } + + exchangeAdapter.addData(data); + } + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + }); + diamondExchangeInput.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void afterTextChanged(Editable editable) { + if (!TextUtils.isEmpty(diamondExchangeInput.getText().toString()) && !TextUtils.isEmpty(number)) { + exchangeAdapter.unSelect(); + number = null; + index = -1; + } + + + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.one_back), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + finish(); + } + }); } private void initData() { - OTONetManager.getInstance(mContext).getExchangeList("yuanbao", new HttpCallback>() { + + if (getIntent() != null && getIntent().getBundleExtra("bundle") != null) { + type = getIntent().getBundleExtra("bundle").getString("type"); + if (TextUtils.equals(type, "yuanbao")) { + title.setText(getString(R.string.my_arnings_exchange_star)); + } else { + title.setText(getString(R.string.my_arnings_exchange_diamond)); + } + } + OTONetManager.getInstance(mContext).getExchangeList(type, new HttpCallback>() { @Override public void onSuccess(List data) { - exchangeAdapter.addData(data); + if (data.size() > 0) { + data.get(0).setSelect(true); + totalConvertibility.setText(String.valueOf(data.get(0).getNum())); + number = data.get(0).getNum(); + exchangeAdapter.addData(data); + } + } @Override @@ -55,4 +199,11 @@ public class DiamondExchangeActivity extends AbsOTOActivity { } }); } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onExchangeModel(DiamondExchangeEvent event) { + number = event.getNum(); + index = event.getIndex(); + diamondExchangeInput.setText(""); + } } diff --git a/OneToOne/src/main/java/com/shayu/onetoone/activity/ExchangeRecordActivity.java b/OneToOne/src/main/java/com/shayu/onetoone/activity/ExchangeRecordActivity.java new file mode 100644 index 000000000..a2ef40e51 --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/activity/ExchangeRecordActivity.java @@ -0,0 +1,114 @@ +package com.shayu.onetoone.activity; + +import android.os.Bundle; +import android.text.TextUtils; + +import androidx.annotation.NonNull; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.shayu.onetoone.R; +import com.shayu.onetoone.adapter.ExchangeRecordAdapter; +import com.shayu.onetoone.bean.ExchangeRecordModel; +import com.shayu.onetoone.manager.OTONetManager; +import com.shayu.onetoone.manager.RouteManager; +import com.yanzhenjie.recyclerview.SwipeRecyclerView; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import java.util.List; + +import io.rong.imkit.widget.refresh.SmartRefreshLayout; +import io.rong.imkit.widget.refresh.api.RefreshLayout; +import io.rong.imkit.widget.refresh.listener.OnLoadMoreListener; +import io.rong.imkit.widget.refresh.listener.OnRefreshListener; +import io.rong.imkit.widget.refresh.wrapper.RongRefreshHeader; + +@Route(path = RouteManager.ACTIVITY_EXCHANGE_RECORD) +public class ExchangeRecordActivity extends AbsOTOActivity { + private ExchangeRecordAdapter recordAdapter; + private SmartRefreshLayout mRefreshLayout; + private SwipeRecyclerView recyclerView; + private int page = 1; + + private String type = "10"; + private String mType = "10"; + + @Override + protected int getLayoutId() { + return R.layout.activity_exchange_record; + + } + + @Override + protected void main(Bundle savedInstanceState) { + if (getIntent() != null && getIntent().getBundleExtra("bundle") != null) { + mType = getIntent().getBundleExtra("bundle").getString("type"); + if (TextUtils.equals(mType, "yuanbao")) { + type = "11"; + } else { + type = "10"; + } + } + initView(); + initData(); + + } + + private void initView() { + recyclerView = findViewById(R.id.recyclerView); + mRefreshLayout = findViewById(R.id.swipeRefreshLayout); + recordAdapter = new ExchangeRecordAdapter(); + recyclerView.setAdapter(recordAdapter); + mRefreshLayout.setNestedScrollingEnabled(false); + mRefreshLayout.setRefreshHeader(new RongRefreshHeader(mContext)); + mRefreshLayout.setRefreshFooter(new RongRefreshHeader(mContext)); + mRefreshLayout.setOnRefreshListener(new OnRefreshListener() { + public void onRefresh(@NonNull RefreshLayout refreshLayout) { + page = 1; + initData(); + } + }); + this.mRefreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() { + public void onLoadMore(@NonNull RefreshLayout refreshLayout) { + onConversationListLoadMore(); + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.one_back), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + finish(); + } + }); + } + + private void initData() { + OTONetManager.getInstance(mContext). + getExchangeRecord(type, "3", "2", page, new HttpCallback>() { + @Override + public void onSuccess(List data) { + if (page != 1 && data.isEmpty()) { + mRefreshLayout.finishLoadMore(); + return; + } + if (page != 1) { + recordAdapter.addLst(data); + } else { + recordAdapter.setList(data); + } + mRefreshLayout.finishRefresh(); + } + + @Override + public void onError(String error) { + mRefreshLayout.finishRefresh(); + } + }); + + } + + private void onConversationListLoadMore() { + page++; + initData(); + mRefreshLayout.finishLoadMore(); + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/activity/MyArnActivity.java b/OneToOne/src/main/java/com/shayu/onetoone/activity/MyArnActivity.java index 3f35eddb0..e05f5582d 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/activity/MyArnActivity.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/activity/MyArnActivity.java @@ -56,7 +56,9 @@ public class MyArnActivity extends AbsOTOActivity { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.diamond_star_coins), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE); + Bundle bundle = new Bundle(); + bundle.putString("type","yuanbao"); + RouteManager.forwardActivity(RouteManager.ACTIVITY_DIAMOND_EXCHANGE,bundle); } }); diff --git a/OneToOne/src/main/java/com/shayu/onetoone/adapter/DiamondExchangeAdapter.java b/OneToOne/src/main/java/com/shayu/onetoone/adapter/DiamondExchangeAdapter.java index 8e2280552..dd649372c 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/adapter/DiamondExchangeAdapter.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/adapter/DiamondExchangeAdapter.java @@ -27,7 +27,16 @@ public class DiamondExchangeAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { DiamondExchangeViewHolder exchangeViewHolder = (DiamondExchangeViewHolder) holder; - exchangeViewHolder.showData(exchangeModels.get(position)); + exchangeViewHolder.showData(exchangeModels.get(position), position); + exchangeViewHolder.setListener(new DiamondExchangeViewHolder.DiamondExchangeClickListener() { + @Override + public void onDiamondExchangeClickListener(ExchangeModel model, int position) { + for (int i = 0; i < exchangeModels.size(); i++) { + exchangeModels.get(i).setSelect(i == position); + } + notifyDataSetChanged(); + } + }); } @Override @@ -38,5 +47,13 @@ public class DiamondExchangeAdapter extends RecyclerView.Adapter { public void addData(List mExchangeModels) { exchangeModels.clear(); exchangeModels.addAll(mExchangeModels); + notifyDataSetChanged(); + } + + public void unSelect() { + for (int i = 0; i < exchangeModels.size(); i++) { + exchangeModels.get(i).setSelect(false); + } + notifyDataSetChanged(); } } diff --git a/OneToOne/src/main/java/com/shayu/onetoone/adapter/ExchangeRecordAdapter.java b/OneToOne/src/main/java/com/shayu/onetoone/adapter/ExchangeRecordAdapter.java new file mode 100644 index 000000000..ad16ca98d --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/adapter/ExchangeRecordAdapter.java @@ -0,0 +1,46 @@ +package com.shayu.onetoone.adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.shayu.onetoone.R; +import com.shayu.onetoone.bean.ExchangeRecordModel; +import com.shayu.onetoone.view.ExchangeRecordViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class ExchangeRecordAdapter extends RecyclerView.Adapter { + private List exchangeRecordModels = new ArrayList<>(); + + @NonNull + @Override + public ExchangeRecordViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View bodyView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_exchange_record_item_holder, parent, false); + return new ExchangeRecordViewHolder(bodyView); + } + + @Override + public void onBindViewHolder(@NonNull ExchangeRecordViewHolder holder, int position) { + holder.setData(exchangeRecordModels.get(position), position); + } + + @Override + public int getItemCount() { + return exchangeRecordModels.size(); + } + + public void setList(List mExchangeRecordModels) { + this.exchangeRecordModels = mExchangeRecordModels; + notifyDataSetChanged(); + } + + public void addLst(List mExchangeRecordModels) { + this.exchangeRecordModels.addAll(mExchangeRecordModels); + notifyDataSetChanged(); + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeModel.java b/OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeModel.java index 8fc31278a..a952a364c 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeModel.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeModel.java @@ -12,7 +12,17 @@ public class ExchangeModel extends BaseModel { @SerializedName("title") private String title; @SerializedName("num") - private int num; + private String num; + private boolean select = false; + + public boolean isSelect() { + return select; + } + + public ExchangeModel setSelect(boolean select) { + this.select = select; + return this; + } public String getTop() { return top; @@ -41,11 +51,11 @@ public class ExchangeModel extends BaseModel { return this; } - public int getNum() { + public String getNum() { return num; } - public ExchangeModel setNum(int num) { + public ExchangeModel setNum(String num) { this.num = num; return this; } diff --git a/OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeRecordModel.java b/OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeRecordModel.java new file mode 100644 index 000000000..a71322dc4 --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/bean/ExchangeRecordModel.java @@ -0,0 +1,140 @@ +package com.shayu.onetoone.bean; + +import com.google.gson.annotations.SerializedName; +import com.yunbao.common.bean.BaseModel; + +public class ExchangeRecordModel extends BaseModel { + + @SerializedName("id") + private int id; + @SerializedName("uid") + private int uid; + @SerializedName("income") + private int income; + @SerializedName("before_money") + private String beforeMoney; + @SerializedName("money") + private String money; + @SerializedName("after_money") + private String afterMoney; + @SerializedName("memo") + private String memo; + @SerializedName("type") + private String type; + @SerializedName("currency_type") + private String currencyType; + @SerializedName("service_id") + private String serviceId; + @SerializedName("create_time") + private long createTime; + @SerializedName("tuid") + private int tuid; + + public int getId() { + return id; + } + + public ExchangeRecordModel setId(int id) { + this.id = id; + return this; + } + + public int getUid() { + return uid; + } + + public ExchangeRecordModel setUid(int uid) { + this.uid = uid; + return this; + } + + public int getIncome() { + return income; + } + + public ExchangeRecordModel setIncome(int income) { + this.income = income; + return this; + } + + public String getBeforeMoney() { + return beforeMoney; + } + + public ExchangeRecordModel setBeforeMoney(String beforeMoney) { + this.beforeMoney = beforeMoney; + return this; + } + + public String getMoney() { + return money; + } + + public ExchangeRecordModel setMoney(String money) { + this.money = money; + return this; + } + + public String getAfterMoney() { + return afterMoney; + } + + public ExchangeRecordModel setAfterMoney(String afterMoney) { + this.afterMoney = afterMoney; + return this; + } + + public String getMemo() { + return memo; + } + + public ExchangeRecordModel setMemo(String memo) { + this.memo = memo; + return this; + } + + public String getType() { + return type; + } + + public ExchangeRecordModel setType(String type) { + this.type = type; + return this; + } + + public String getCurrencyType() { + return currencyType; + } + + public ExchangeRecordModel setCurrencyType(String currencyType) { + this.currencyType = currencyType; + return this; + } + + public String getServiceId() { + return serviceId; + } + + public ExchangeRecordModel setServiceId(String serviceId) { + this.serviceId = serviceId; + return this; + } + + public long getCreateTime() { + return createTime; + } + + public ExchangeRecordModel setCreateTime(long createTime) { + this.createTime = createTime; + return this; + } + + public int getTuid() { + return tuid; + } + + public ExchangeRecordModel setTuid(int tuid) { + this.tuid = tuid; + return this; + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/event/DiamondExchangeEvent.java b/OneToOne/src/main/java/com/shayu/onetoone/event/DiamondExchangeEvent.java new file mode 100644 index 000000000..a3ad6babd --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/event/DiamondExchangeEvent.java @@ -0,0 +1,57 @@ +package com.shayu.onetoone.event; + +import com.yunbao.common.bean.BaseModel; + +public class DiamondExchangeEvent extends BaseModel { + private String top; + private String name; + private String title; + private String num; + + private int index = 0; + + public int getIndex() { + return index; + } + + public DiamondExchangeEvent setIndex(int index) { + this.index = index; + return this; + } + + public String getTop() { + return top; + } + + public DiamondExchangeEvent setTop(String top) { + this.top = top; + return this; + } + + public String getName() { + return name; + } + + public DiamondExchangeEvent setName(String name) { + this.name = name; + return this; + } + + public String getTitle() { + return title; + } + + public DiamondExchangeEvent setTitle(String title) { + this.title = title; + return this; + } + + public String getNum() { + return num; + } + + public DiamondExchangeEvent setNum(String num) { + this.num = num; + return this; + } +} diff --git a/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java b/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java index 1af8fa3ee..49d61ebf1 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/manager/OTONetManager.java @@ -9,6 +9,7 @@ import com.shayu.onetoone.bean.AuthBean; import com.shayu.onetoone.bean.AuthBloggerBean; import com.shayu.onetoone.bean.AvatarBean; import com.shayu.onetoone.bean.ExchangeModel; +import com.shayu.onetoone.bean.ExchangeRecordModel; import com.shayu.onetoone.bean.FollowBean; import com.shayu.onetoone.bean.FriendAppMoneyLogModel; import com.shayu.onetoone.bean.FriendAppMoneySumModel; @@ -1170,8 +1171,7 @@ public class OTONetManager { } /** - * - * @param type coin砖石 yuanbao 星币 + * @param type coin砖石 yuanbao 星币 * @param callback */ public void getExchangeList(String type, HttpCallback> callback) { @@ -1197,4 +1197,66 @@ public class OTONetManager { } }).isDisposed(); } + + /** + * 收益转换星币或砖石 + * + * @param type coin砖石 yuanbao 星币 + * @param number 转换 星币 或 砖石 数量 + * @param callback + */ + public void getTransform(String type, String number, HttpCallback> callback) { + API.get().otoApi(mContext). + getTransform(type, number) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (listResponseModel.getData().getCode() == 0) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } else { + callback.onError(listResponseModel.getData().getMsg()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(com.yunbao.common.R.string.net_error)); + } + } + }).isDisposed(); + } + + /** + * @param type 10 转换星币 11转换砖石 + * @param currencyType 1星币 2砖石 3社交新币种 + * @param income 1收入 2支出 + * @param page + * @param callback + */ + public void getExchangeRecord(String type, String currencyType, String income, int page, HttpCallback> callback) { + API.get().otoApi(mContext). + getExchangeRecord(type, currencyType, income, page) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (listResponseModel.getData().getCode() == 0) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } else { + callback.onError(listResponseModel.getData().getMsg()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(com.yunbao.common.R.string.net_error)); + } + } + }).isDisposed(); + } } diff --git a/OneToOne/src/main/java/com/shayu/onetoone/manager/RouteManager.java b/OneToOne/src/main/java/com/shayu/onetoone/manager/RouteManager.java index ba37fbba0..a178d75cd 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/manager/RouteManager.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/manager/RouteManager.java @@ -19,6 +19,7 @@ public class RouteManager { public static final String ACTIVITY_HOME_RANK = "/activity/HomepageRankingActivity"; public static final String ACTIVITY_MY_ARN = "/activity/MyAarningsActivity"; public static final String ACTIVITY_DIAMOND_EXCHANGE = "/activity/DiamondExchangeActivity"; + public static final String ACTIVITY_EXCHANGE_RECORD = "/activity/ExchangeRecordActivity"; public static final String ACTIVITY_HOME_SEARCH = "/activity/HomeSearchActivity"; public static final String ACTIVITY_HOME_SCREEN = "/activity/HomeScreenActivity"; public static final String ACTIVITY_CALL_VIDEO = "/activity/CallVideoActivity"; diff --git a/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java b/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java index 7ba9f8b70..add5c2553 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/network/OneToOneApi.java @@ -4,6 +4,7 @@ import com.shayu.onetoone.bean.AuthBean; import com.shayu.onetoone.bean.AuthBloggerBean; import com.shayu.onetoone.bean.AvatarBean; import com.shayu.onetoone.bean.ExchangeModel; +import com.shayu.onetoone.bean.ExchangeRecordModel; import com.shayu.onetoone.bean.FollowBean; import com.shayu.onetoone.bean.FriendAppMoneyLogModel; import com.shayu.onetoone.bean.FriendAppMoneySumModel; @@ -244,6 +245,7 @@ public interface OneToOneApi { Observable>> getExchangeList( @Query("type") String type ); + /** * 设置基本信息 */ @@ -305,6 +307,25 @@ public interface OneToOneApi { @GET("/api/public/?service=Friendappinfos.getSage") Observable> getBloggerInfo( ); + /** + * 收益转换星币或砖石 + */ + @GET("/api/public/?service=Friendappmoney.transform") + Observable>> getTransform( + @Query("type") String type, + @Query("num") String number + ); + + /** + * 收益转换星币或砖石 + */ + @GET("/api/public/?service=Friendappmoney.logs") + Observable>> getExchangeRecord( + @Query("type") String type, + @Query("currency_type") String currencyType, + @Query("income") String income, + @Query("p") int page + ); } diff --git a/OneToOne/src/main/java/com/shayu/onetoone/view/DiamondExchangeViewHolder.java b/OneToOne/src/main/java/com/shayu/onetoone/view/DiamondExchangeViewHolder.java index 984ca3020..cfc96be51 100644 --- a/OneToOne/src/main/java/com/shayu/onetoone/view/DiamondExchangeViewHolder.java +++ b/OneToOne/src/main/java/com/shayu/onetoone/view/DiamondExchangeViewHolder.java @@ -1,5 +1,7 @@ package com.shayu.onetoone.view; +import android.graphics.Color; +import android.text.TextUtils; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; @@ -9,6 +11,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.shayu.onetoone.R; import com.shayu.onetoone.bean.ExchangeModel; +import com.shayu.onetoone.event.DiamondExchangeEvent; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.views.weight.ViewClicksAntiShake; public class DiamondExchangeViewHolder extends RecyclerView.ViewHolder { private LinearLayout diamondExchangeBtn; @@ -22,7 +27,57 @@ public class DiamondExchangeViewHolder extends RecyclerView.ViewHolder { goldCoin = itemView.findViewById(R.id.gold_coin); } - public void showData(ExchangeModel model) { + public void showData(ExchangeModel model, int position) { + diamondExchangeBtn.setSelected(model.isSelect()); + coins.setText(model.getName()); + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append("(") + .append(model.getTitle()) + .append(")"); + goldCoin.setText(stringBuffer); + if (!TextUtils.isEmpty(model.getTop())) { + fullConversion.setVisibility(View.VISIBLE); + fullConversion.setText(model.getTop()); + if (model.isSelect()) { + fullConversion.setTextColor(Color.parseColor("#C274EC")); + } else { + fullConversion.setTextColor(Color.parseColor("#333333")); + } + } else { + fullConversion.setVisibility(View.GONE); + } + if (model.isSelect()) { + coins.setTextColor(Color.parseColor("#C274EC")); + goldCoin.setTextColor(Color.parseColor("#C274EC")); + } else { + coins.setTextColor(Color.parseColor("#333333")); + goldCoin.setTextColor(Color.parseColor("#333333")); + } + ViewClicksAntiShake.clicksAntiShake(diamondExchangeBtn, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (listener != null) { + listener.onDiamondExchangeClickListener(model, position); + Bus.get().post(new DiamondExchangeEvent() + .setName(model.getName()) + .setTitle(model.getTitle()) + .setTop(model.getTop()) + .setNum(model.getNum()) + .setIndex(position)); + } + } + }); + } + + private DiamondExchangeClickListener listener; + + public DiamondExchangeViewHolder setListener(DiamondExchangeClickListener listener) { + this.listener = listener; + return this; + } + + public interface DiamondExchangeClickListener { + void onDiamondExchangeClickListener(ExchangeModel model, int position); } } diff --git a/OneToOne/src/main/java/com/shayu/onetoone/view/ExchangeRecordViewHolder.java b/OneToOne/src/main/java/com/shayu/onetoone/view/ExchangeRecordViewHolder.java new file mode 100644 index 000000000..8d8de835e --- /dev/null +++ b/OneToOne/src/main/java/com/shayu/onetoone/view/ExchangeRecordViewHolder.java @@ -0,0 +1,41 @@ +package com.shayu.onetoone.view; + +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.shayu.onetoone.R; +import com.shayu.onetoone.bean.ExchangeRecordModel; + +import java.text.SimpleDateFormat; +import java.util.Date; + +public class ExchangeRecordViewHolder extends RecyclerView.ViewHolder { + private TextView memoName, createTime, money; + + public ExchangeRecordViewHolder(@NonNull View itemView) { + super(itemView); + memoName = itemView.findViewById(R.id.memo_name); + createTime = itemView.findViewById(R.id.create_time); + money = itemView.findViewById(R.id.money); + } + + public void setData(ExchangeRecordModel model, int position) { + StringBuilder builder = new StringBuilder(); + builder + .append(model.getMoney()); + memoName.setText(model.getMemo()); + money.setText(builder.toString()); + createTime.setText(getDateStr(new Date((model.getCreateTime()) * 1000), null)); + } + + public String getDateStr(Date date, String format) { + if (format == null || format.isEmpty()) { + format = "yyyy-MM-dd HH:mm"; + } + SimpleDateFormat formatter = new SimpleDateFormat(format); + return formatter.format(date); + } +} diff --git a/OneToOne/src/main/res/layout/activity_diamond_exchange.xml b/OneToOne/src/main/res/layout/activity_diamond_exchange.xml index 8ad6e253d..fc064d93f 100644 --- a/OneToOne/src/main/res/layout/activity_diamond_exchange.xml +++ b/OneToOne/src/main/res/layout/activity_diamond_exchange.xml @@ -16,7 +16,17 @@ android:layout_height="wrap_content" android:layout_marginTop="30dp"> + + + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginTop="29dp" + android:layout_marginEnd="16dp" />