金币兑换砖石,星币页面,消费记录页面
This commit is contained in:
@@ -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<List<ExchangeModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ExchangeModel> 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<List<ExchangeModel>>() {
|
||||
|
||||
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<List<ExchangeModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ExchangeModel> 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("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<List<ExchangeRecordModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<ExchangeRecordModel> 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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user