version:4.4
fix: update:增加下单,微信支付,优化资讯分类
This commit is contained in:
@@ -3,6 +3,8 @@ package com.uiuios.aios.activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
@@ -12,16 +14,46 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.base.BaseDataBindingActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.bean.RegionInfo;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.databinding.ActivityDetailsBinding;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.ObservableSource;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.functions.Function;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class DetailsActivity extends AppCompatActivity {
|
||||
public class DetailsActivity extends BaseDataBindingActivity {
|
||||
@BindView(R.id.iv_details)
|
||||
ImageView iv_details;
|
||||
@BindView(R.id.iv_exit)
|
||||
@@ -53,23 +85,17 @@ public class DetailsActivity extends AppCompatActivity {
|
||||
@BindView(R.id.ll_buy)
|
||||
LinearLayout ll_buy;
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private ActivityDetailsBinding mBinding;
|
||||
private GoodsInfo mGoodsInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
UltimateBarX.statusBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
UltimateBarX.navigationBar(this)
|
||||
.transparent()
|
||||
.colorRes(R.color.colorPrimaryDark)
|
||||
.light(true)
|
||||
.apply();
|
||||
setContentView(R.layout.activity_details);
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_details);
|
||||
ButterKnife.bind(this);
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) return;
|
||||
@@ -94,7 +120,9 @@ public class DetailsActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
tv_stock.setText("库存:" + mGoodsInfo.getStock());
|
||||
tv_subsidy.setText("官方补贴" + (mGoodsInfo.getOriginal_price() - mGoodsInfo.getBuying_price()));
|
||||
BigDecimal d =new BigDecimal(mGoodsInfo.getOriginal_price());
|
||||
BigDecimal d2 =new BigDecimal(mGoodsInfo.getBuying_price());
|
||||
tv_subsidy.setText("官方补贴" + d.subtract(d2).toString());
|
||||
tv_buying_price.setText("¥" + mGoodsInfo.getBuying_price());
|
||||
tv_original_price.setText("原价:" + mGoodsInfo.getOriginal_price() + "元");
|
||||
tv_price.setText("抢购:" + mGoodsInfo.getBuying_price() + "元");
|
||||
@@ -107,13 +135,117 @@ public class DetailsActivity extends AppCompatActivity {
|
||||
ll_buy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Uri uri = Uri.parse(goodsInfo.getJump_url());
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
// Uri uri = Uri.parse(goodsInfo.getJump_url());
|
||||
// Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
// startActivity(intent);
|
||||
|
||||
Intent intent = new Intent(DetailsActivity.this, OrderActivity.class);
|
||||
intent.putExtra("GoodsInfo", mGoodsInfo);
|
||||
startActivity(intent);
|
||||
|
||||
// NetInterfaceManager.getInstance().getRegionListApi().getRegionList("0")
|
||||
// .flatMap(new Function<BaseResponse<List<RegionInfo>>, ObservableSource<?>>() {
|
||||
// @Override
|
||||
// public ObservableSource<?> apply(BaseResponse<List<RegionInfo>> listBaseResponse) throws Throwable {
|
||||
// if (listBaseResponse.code == 200) {
|
||||
// List<RegionInfo> regionInfos = listBaseResponse.data;
|
||||
// String province = mMMKV.decodeString(CommonConfig.MAP_PROVINCE_KEY, "");
|
||||
// Map<String, String> provinceMap = regionInfos.stream().collect(Collectors.toMap(RegionInfo::getArea_name, RegionInfo::getId));
|
||||
// if (TextUtils.isEmpty(provinceMap.get(province))) {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("110000000000");
|
||||
// } else {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList(provinceMap.get(province));
|
||||
// }
|
||||
// } else {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("110000000000");
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// .flatMap(new Function<Object, ObservableSource<?>>() {
|
||||
// @Override
|
||||
// public ObservableSource<?> apply(Object o) throws Throwable {
|
||||
// BaseResponse<List<RegionInfo>> listBaseResponse = (BaseResponse<List<RegionInfo>>) o;
|
||||
// if (listBaseResponse.code == 200) {
|
||||
// List<RegionInfo> regionInfos = listBaseResponse.data;
|
||||
// String province = mMMKV.decodeString(CommonConfig.MAP_CITY_KEY, "");
|
||||
// Map<String, String> provinceMap = regionInfos.stream().collect(Collectors.toMap(RegionInfo::getArea_name, RegionInfo::getId));
|
||||
// if (TextUtils.isEmpty(provinceMap.get(province))) {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("110100000000");
|
||||
// } else {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList(provinceMap.get(province));
|
||||
// }
|
||||
// } else {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("110100000000");
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// .flatMap(new Function<Object, ObservableSource<?>>() {
|
||||
// @Override
|
||||
// public ObservableSource<?> apply(Object o) throws Throwable {
|
||||
// BaseResponse<List<RegionInfo>> listBaseResponse = (BaseResponse<List<RegionInfo>>) o;
|
||||
// if (listBaseResponse.code == 200) {
|
||||
// List<RegionInfo> regionInfos = listBaseResponse.data;
|
||||
// String province = mMMKV.decodeString(CommonConfig.MAP_DISTRICT_KEY, "");
|
||||
// Map<String, String> provinceMap = regionInfos.stream().collect(Collectors.toMap(RegionInfo::getArea_name, RegionInfo::getId));
|
||||
// if (TextUtils.isEmpty(provinceMap.get(province))) {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("110101000000");
|
||||
// } else {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList(provinceMap.get(province));
|
||||
// }
|
||||
// } else {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("110101000000");
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// .subscribe(new Observer<Object>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e("getRegionList", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull Object o) {
|
||||
// Log.e("getRegionList", "onNext: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e("getRegionList", "onError: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("getRegionList", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
tv_type.setText(mGoodsInfo.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
// NetInterfaceManager.getInstance().getRegionListApi().getRegionList("0")
|
||||
// .subscribeOn(Schedulers.io())
|
||||
// .observeOn(Schedulers.io())//设定第一次请求结果放在io线程并同时执行第二次 请求
|
||||
// .flatMap(new Function<BaseResponse<List<RegionInfo>>, ObservableSource<?>>() {
|
||||
// @Override
|
||||
// public ObservableSource<?> apply(BaseResponse<List<RegionInfo>> listBaseResponse) throws Throwable {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("0");
|
||||
// }
|
||||
// })
|
||||
// .observeOn(Schedulers.io())//设定第三次请求结果放在io线程并同时执行次 自己的登录请求
|
||||
// .flatMap(new Function<Object, ObservableSource<?>>() {
|
||||
// @Override
|
||||
// public ObservableSource<?> apply(Object o) throws Throwable {
|
||||
// return NetInterfaceManager.getInstance().getRegionListApi().getRegionList("0");
|
||||
// }
|
||||
// })
|
||||
// .observeOn(AndroidSchedulers.mainThread())
|
||||
// .subscribe();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user