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();
|
||||
}
|
||||
}
|
||||
|
||||
196
app/src/main/java/com/uiuios/aios/activity/GoodsActivity.java
Normal file
196
app/src/main/java/com/uiuios/aios/activity/GoodsActivity.java
Normal file
@@ -0,0 +1,196 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.adapter.GoodsListAdapter;
|
||||
import com.uiuios.aios.base.BaseDataBindingActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.bean.GoodsList;
|
||||
import com.uiuios.aios.bean.GoodsType;
|
||||
import com.uiuios.aios.databinding.ActivityGoodsBinding;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class GoodsActivity extends BaseDataBindingActivity {
|
||||
private static final String TAG = GoodsActivity.class.getSimpleName();
|
||||
|
||||
private ActivityGoodsBinding mBinding;
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private GoodsListAdapter mGoodsAdapter;
|
||||
|
||||
private HashMap<String, GoodsType> mGoodsTypeMap;
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_goods);
|
||||
mBinding.setListener(new Listener());
|
||||
mRecyclerView = mBinding.recyclerView;
|
||||
mGoodsAdapter = new GoodsListAdapter();
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
mRecyclerView.setAdapter(mGoodsAdapter);
|
||||
|
||||
mBinding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
Log.e(TAG, "onTabSelected: " + tab.getText());
|
||||
if (tab.getText() != null && !TextUtils.isEmpty(tab.getText())) {
|
||||
String text = tab.getText().toString();
|
||||
if (mGoodsTypeMap.get(text) != null) {
|
||||
getAllGoods(mGoodsTypeMap.get(text).getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
Log.e(TAG, "onTabUnselected: " + tab.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
Log.e(TAG, "onTabReselected: " + tab.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
@Override
|
||||
public void initData() {
|
||||
getGoodsType();
|
||||
}
|
||||
|
||||
private void getGoodsType() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsTypeListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<GoodsType>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getGoodsType", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<GoodsType>> listBaseResponse) {
|
||||
Log.e("getGoodsType", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
mBinding.tabLayout.setVisibility(View.VISIBLE);
|
||||
List<GoodsType> goodsTypeList = listBaseResponse.data;
|
||||
List<String> typeString = goodsTypeList.stream().map(GoodsType::getName).collect(Collectors.toList());
|
||||
String[] type = new String[goodsTypeList.size()];
|
||||
type = typeString.toArray(type);
|
||||
mGoodsTypeMap = new HashMap<>();
|
||||
for (int i = 0; i < type.length; i++) {
|
||||
mGoodsTypeMap.put(type[i], goodsTypeList.get(i));
|
||||
TabLayout.Tab tab = mBinding.tabLayout.newTab();//关键的创建一个Tab,注意这里使用的是已经实例的mTablayout创建的Tab,很容易疏忽使用new Tablayout().new Tab()的方式创建,这个是会报错的.
|
||||
tab.setText(type[i]);
|
||||
if (i == 0) {
|
||||
mBinding.tabLayout.addTab(tab, 0, true);//设置选择的item
|
||||
} else {
|
||||
mBinding.tabLayout.addTab(tab);
|
||||
}
|
||||
}
|
||||
getAllGoods(goodsTypeList.get(0).getId());
|
||||
} else {
|
||||
mBinding.tabLayout.setVisibility(View.GONE);
|
||||
getAllGoods();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getGoodsType", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getGoodsType", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void getAllGoods(int type) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable(type)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(getGoodsListObservable());
|
||||
}
|
||||
|
||||
|
||||
private void getAllGoods() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(getGoodsListObservable());
|
||||
}
|
||||
|
||||
private Observer<BaseResponse<GoodsList>> getGoodsListObservable() {
|
||||
return new Observer<BaseResponse<GoodsList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAllGoods", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<GoodsList> listBaseResponse) {
|
||||
Log.e("getAllGoods", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
GoodsList goodsList = listBaseResponse.data;
|
||||
List<GoodsInfo> goodsInfos = goodsList.getData();
|
||||
mGoodsAdapter.setGoodsInfoList(goodsInfos);
|
||||
mRecyclerView.setVisibility(View.VISIBLE);
|
||||
mBinding.clNodata.setVisibility(View.GONE);
|
||||
} else {
|
||||
mRecyclerView.setVisibility(View.GONE);
|
||||
mBinding.clNodata.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAllGoods", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAllGoods", "onComplete: ");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public class Listener {
|
||||
public void back(View view) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.adapter.ArticleAdapter;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.ArticleList;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
@@ -69,16 +70,17 @@ public class InfoListActivity extends BaseActivity {
|
||||
public void initData() {
|
||||
NetInterfaceManager.getInstance().getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ArticleInfo>>>() {
|
||||
.subscribe(new Observer<BaseResponse<ArticleList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getArticle", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ArticleInfo>> listBaseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<ArticleList> listBaseResponse) {
|
||||
Log.e("getArticle", "onNext: " + listBaseResponse);
|
||||
List<ArticleInfo> articleInfoList = listBaseResponse.data;
|
||||
ArticleList articleList = listBaseResponse.data;
|
||||
List<ArticleInfo> articleInfoList = articleList.getData();
|
||||
if (articleInfoList != null && articleInfoList.size() != 0) {
|
||||
iv1.setVisibility(android.view.View.GONE);
|
||||
mArticleAdapter.setArticleBeanList(articleInfoList);
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.adapter.InformationAdapter;
|
||||
import com.uiuios.aios.adapter.TitleAdapter;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.base.BaseDataBindingActivity;
|
||||
import com.uiuios.aios.base.DataBindingActivity;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.ArticleList;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.CategoryBean;
|
||||
import com.uiuios.aios.databinding.ActivityInformationBinding;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@@ -28,54 +35,66 @@ import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class InformationActivity extends BaseActivity {
|
||||
public class InformationActivity extends DataBindingActivity {
|
||||
private static final String TAG = InformationActivity.class.getSimpleName();
|
||||
|
||||
@BindView(R.id.rv_title)
|
||||
RecyclerView rv_title;
|
||||
@BindView(R.id.tabLayout)
|
||||
TabLayout tabLayout;
|
||||
@BindView(R.id.root)
|
||||
ConstraintLayout root;
|
||||
@BindView(R.id.rv_video)
|
||||
RecyclerView rv_video;
|
||||
@BindView(R.id.cl_nodata)
|
||||
ConstraintLayout cl_nodata;
|
||||
|
||||
private TitleAdapter mTitleAdapter;
|
||||
private ActivityInformationBinding mBinding;
|
||||
private InformationAdapter mInformationAdapter;
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.activity_information;
|
||||
}
|
||||
private HashMap<String, CategoryBean> mCategoryMap;
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_information);
|
||||
ButterKnife.bind(this);
|
||||
mTitleAdapter = new TitleAdapter();
|
||||
mTitleAdapter.setTitleChangeCallback(new TitleAdapter.TitleChangeCallback() {
|
||||
@Override
|
||||
public void onTitleChange(CategoryBean categoryBean) {
|
||||
int id = categoryBean.getId();
|
||||
if (id == -100) {
|
||||
UltimateBarX.statusBarOnly(this)
|
||||
.transparent()
|
||||
.apply();
|
||||
|
||||
} else {
|
||||
UltimateBarX.addStatusBarTopPadding(tabLayout);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
rv_title.setLayoutManager(linearLayoutManager);
|
||||
rv_title.setAdapter(mTitleAdapter);
|
||||
|
||||
mInformationAdapter =new InformationAdapter();
|
||||
LinearLayoutManager linearLayoutManager1 = new LinearLayoutManager(this);
|
||||
mInformationAdapter = new InformationAdapter();
|
||||
LinearLayoutManager linearLayoutManager1 = new LinearLayoutManager(this);
|
||||
linearLayoutManager1.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
rv_video.setLayoutManager(linearLayoutManager1);
|
||||
rv_video.setAdapter(mInformationAdapter);
|
||||
|
||||
mBinding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
Log.e(TAG, "onTabSelected: " + tab.getText());
|
||||
if (tab.getText() != null && !TextUtils.isEmpty(tab.getText())) {
|
||||
String text = tab.getText().toString();
|
||||
if (mCategoryMap.get(text) != null) {
|
||||
getArticleList(mCategoryMap.get(text).getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
Log.e(TAG, "onTabUnselected: " + tab.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
Log.e(TAG, "onTabReselected: " + tab.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
getCategorys();
|
||||
getArticleList();
|
||||
}
|
||||
|
||||
private void getCategorys() {
|
||||
@@ -91,9 +110,26 @@ public class InformationActivity extends BaseActivity {
|
||||
public void onNext(@NonNull BaseResponse<List<CategoryBean>> listBaseResponse) {
|
||||
Log.e("getCategorys", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
mTitleAdapter.setCategoryList(listBaseResponse.data);
|
||||
mBinding.tabLayout.setVisibility(View.VISIBLE);
|
||||
List<CategoryBean> categoryList = listBaseResponse.data;
|
||||
List<String> typeString = categoryList.stream().map(CategoryBean::getName).collect(Collectors.toList());
|
||||
String[] type = new String[categoryList.size()];
|
||||
type = typeString.toArray(type);
|
||||
mCategoryMap = new HashMap<>();
|
||||
for (int i = 0; i < type.length; i++) {
|
||||
mCategoryMap.put(type[i], categoryList.get(i));
|
||||
TabLayout.Tab tab = mBinding.tabLayout.newTab();//关键的创建一个Tab,注意这里使用的是已经实例的mTablayout创建的Tab,很容易疏忽使用new Tablayout().new Tab()的方式创建,这个是会报错的.
|
||||
tab.setText(type[i]);
|
||||
if (i == 0) {
|
||||
mBinding.tabLayout.addTab(tab, 0, true);//设置选择的item
|
||||
} else {
|
||||
mBinding.tabLayout.addTab(tab);
|
||||
}
|
||||
}
|
||||
getArticleList(categoryList.get(0).getId());
|
||||
} else {
|
||||
mTitleAdapter.setCategoryList(null);
|
||||
mBinding.tabLayout.setVisibility(View.GONE);
|
||||
getArticleList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,38 +147,55 @@ public class InformationActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void getArticleList() {
|
||||
NetInterfaceManager.getInstance().getArticleListObservable()
|
||||
NetInterfaceManager.getInstance()
|
||||
.getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ArticleInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getArticle", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ArticleInfo>> listBaseResponse) {
|
||||
Log.e("getArticle", "onNext: " + listBaseResponse);
|
||||
List<ArticleInfo> articleInfoList = listBaseResponse.data;
|
||||
if (articleInfoList != null && articleInfoList.size() != 0) {
|
||||
mInformationAdapter.setArticleInfos(articleInfoList);
|
||||
rv_video.setVisibility(View.VISIBLE);
|
||||
cl_nodata.setVisibility(android.view.View.GONE);
|
||||
} else {
|
||||
rv_video.setVisibility(android.view.View.GONE);
|
||||
cl_nodata.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getArticle", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getArticle", "onComplete: ");
|
||||
}
|
||||
});
|
||||
.subscribe(getArticleListObserver());
|
||||
}
|
||||
|
||||
private void getArticleList(int id) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getArticleListObservable(id)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(getArticleListObserver());
|
||||
}
|
||||
|
||||
private Observer<BaseResponse<ArticleList>> getArticleListObserver() {
|
||||
return new Observer<BaseResponse<ArticleList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getArticle", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<ArticleList> listBaseResponse) {
|
||||
Log.e("getArticle", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code == 200) {
|
||||
ArticleList articleList = listBaseResponse.data;
|
||||
List<ArticleInfo> articleInfoList = articleList.getData();
|
||||
if (articleInfoList != null && articleInfoList.size() != 0) {
|
||||
mInformationAdapter.setArticleInfos(articleInfoList);
|
||||
rv_video.setVisibility(View.VISIBLE);
|
||||
cl_nodata.setVisibility(android.view.View.GONE);
|
||||
} else {
|
||||
rv_video.setVisibility(android.view.View.GONE);
|
||||
cl_nodata.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
rv_video.setVisibility(android.view.View.GONE);
|
||||
cl_nodata.setVisibility(android.view.View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getArticle", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getArticle", "onComplete: ");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
177
app/src/main/java/com/uiuios/aios/activity/OrderActivity.java
Normal file
177
app/src/main/java/com/uiuios/aios/activity/OrderActivity.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
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.OrderBean;
|
||||
import com.uiuios.aios.databinding.ActivityOrderBinding;
|
||||
import com.uiuios.aios.manager.RemoteManager;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
public class OrderActivity extends BaseDataBindingActivity {
|
||||
private static final String TAG = OrderActivity.class.getSimpleName();
|
||||
|
||||
private ActivityOrderBinding mBinding;
|
||||
|
||||
private GoodsInfo mGoodsInfo;
|
||||
private int mStock;
|
||||
private int mNumer = 1;
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_order);
|
||||
mBinding.ivReduce.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String numberString = mBinding.editText.getText().toString();
|
||||
int number = Integer.parseInt(numberString);
|
||||
if (number > 1) {
|
||||
mBinding.editText.setText(String.valueOf(number - 1));
|
||||
mNumer = number - 1;
|
||||
mBinding.tvPay.setText("立即支付 ¥" + multi(mGoodsInfo.getBuying_price(), mNumer));
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.ivAdd.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String numberString = mBinding.editText.getText().toString();
|
||||
int number = Integer.parseInt(numberString);
|
||||
if (number < mStock) {
|
||||
mBinding.editText.setText(String.valueOf(number + 1));
|
||||
mNumer = number + 1;
|
||||
mBinding.tvPay.setText("立即支付 ¥" + multi(mGoodsInfo.getBuying_price(), mNumer));
|
||||
}
|
||||
}
|
||||
});
|
||||
mBinding.editText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
Log.e("editText", "beforeTextChanged: " + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
Log.e("editText", "onTextChanged: " + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
Log.e("editText", "afterTextChanged: " + s);
|
||||
String numberString = s.toString();
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
return;
|
||||
}
|
||||
int number = Integer.parseInt(numberString);
|
||||
if (number > mStock) {
|
||||
mNumer = mStock;
|
||||
mBinding.tvPay.setText("立即支付 ¥" + multi(mGoodsInfo.getBuying_price(), mNumer));
|
||||
} else if (number == 0) {
|
||||
mNumer = 1;
|
||||
mBinding.editText.setText("1");
|
||||
mBinding.tvPay.setText("立即支付 ¥" + multi(mGoodsInfo.getBuying_price(), mNumer));
|
||||
} else {
|
||||
mNumer = number;
|
||||
mBinding.tvPay.setText("立即支付 ¥" + multi(mGoodsInfo.getBuying_price(), mNumer));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String multi(String v1, int v2) {
|
||||
BigDecimal b1 = new BigDecimal(v1);
|
||||
BigDecimal b2 = new BigDecimal(String.valueOf(v2));
|
||||
return b1.multiply(b2).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
@Override
|
||||
public void initData() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) return;
|
||||
GoodsInfo goodsInfo = (GoodsInfo) intent.getSerializableExtra("GoodsInfo");
|
||||
if (goodsInfo == null) return;
|
||||
mGoodsInfo = goodsInfo;
|
||||
mBinding.setGoodsInfo(mGoodsInfo);
|
||||
mBinding.tvPrice.setText("券后¥" + mGoodsInfo.getBuying_price());
|
||||
mBinding.tvOriginalPrice.setText("券前¥" + mGoodsInfo.getOriginal_price());
|
||||
mStock = mGoodsInfo.getStock();
|
||||
mBinding.tvStock.setText("库存:" + mStock);
|
||||
mBinding.tvPay.setText("立即支付 ¥" + mGoodsInfo.getBuying_price());
|
||||
mBinding.clPay.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
creactOrder();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void creactOrder() {
|
||||
Map<String, RequestBody> params = new HashMap<>();
|
||||
params.put("goods_id", NetInterfaceManager.convertToRequestBody(mGoodsInfo.getId()));
|
||||
params.put("num", NetInterfaceManager.convertToRequestBody(mBinding.editText.getText().toString()));
|
||||
params.put("sn", NetInterfaceManager.convertToRequestBody(RemoteManager.getInstance().getSerial()));
|
||||
params.put("desktop_app_package", NetInterfaceManager.convertToRequestBody(BuildConfig.APPLICATION_ID));
|
||||
NetInterfaceManager.getInstance().getGoodsBuyObservable(params)
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<OrderBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("goodsPay", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<OrderBean> baseResponse) {
|
||||
Log.e("goodsPay", "onNext: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
OrderBean orderBean = baseResponse.data;
|
||||
Intent intent1 = new Intent(OrderActivity.this, PayActivity.class);
|
||||
intent1.putExtra("OrderBean", orderBean);
|
||||
startActivity(intent1);
|
||||
} else {
|
||||
ToastUtil.show("下单失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("goodsPay", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("goodsPay", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
185
app/src/main/java/com/uiuios/aios/activity/PayActivity.java
Normal file
185
app/src/main/java/com/uiuios/aios/activity/PayActivity.java
Normal file
@@ -0,0 +1,185 @@
|
||||
package com.uiuios.aios.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.base.BaseDataBindingActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.OrderBean;
|
||||
import com.uiuios.aios.bean.WxpayBean;
|
||||
import com.uiuios.aios.databinding.ActivityPayBinding;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.uiuios.aios.utils.BitmapUtils;
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.functions.Consumer;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class PayActivity extends BaseDataBindingActivity {
|
||||
private static final String TAG = PayActivity.class.getSimpleName();
|
||||
|
||||
private ActivityPayBinding mBinding;
|
||||
|
||||
private OrderBean mOrderBean;
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
@Override
|
||||
public void initView() {
|
||||
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_pay);
|
||||
mBinding.tvRefresh.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getWechatPayQrcode(mOrderBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
@Override
|
||||
public void initData() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) return;
|
||||
OrderBean orderBean = (OrderBean) intent.getSerializableExtra("OrderBean");
|
||||
if (orderBean == null) return;
|
||||
mOrderBean = orderBean;
|
||||
getWechatPayQrcode(mOrderBean);
|
||||
}
|
||||
|
||||
private Disposable mCountdownSubscribe;
|
||||
|
||||
private void getWechatPayQrcode(OrderBean orderBean) {
|
||||
if (orderBean == null) return;
|
||||
NetInterfaceManager.getInstance()
|
||||
.getOrderPayObservable(orderBean.getOrder_sn(), orderBean.getOrder_id())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<WxpayBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getOrderPayObservable", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<WxpayBean> wxpayBeanBaseResponse) {
|
||||
Log.e("getOrderPayObservable", "onNext: " + wxpayBeanBaseResponse);
|
||||
if (wxpayBeanBaseResponse.code == 200) {
|
||||
WxpayBean wxpayBean = wxpayBeanBaseResponse.data;
|
||||
mBinding.setWxpayBean(wxpayBean);
|
||||
mBinding.tvOrderId.setText("订单编号:" + wxpayBean.getOrder_sn());
|
||||
long expireTime = wxpayBean.getTime_expire();
|
||||
mBinding.ivWxQrcode.setImageBitmap(BitmapUtils.createQRImage(wxpayBean.getCode_url(), 400, 400));
|
||||
initCountdown(expireTime);
|
||||
checkOrder(wxpayBean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getOrderPayObservable", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getOrderPayObservable", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCountdown(long second) {
|
||||
if (mCountdownSubscribe != null && !mCountdownSubscribe.isDisposed()) {
|
||||
mCountdownSubscribe.dispose();
|
||||
}
|
||||
mCountdownSubscribe = Observable.interval(1, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Long>() {
|
||||
|
||||
@Override
|
||||
public void accept(Long aLong) throws Exception {
|
||||
long timestamp = System.currentTimeMillis() / 1000;
|
||||
Log.e("initCountdown", "accept: time_expire = " + second);
|
||||
Log.e("initCountdown", "accept: aLong = " + aLong);
|
||||
Log.e("initCountdown", "accept: timestamp = " + timestamp);
|
||||
if (timestamp >= second) {
|
||||
mBinding.ivWxQrcode.setImageDrawable(getDrawable(R.drawable.qrcode_expired));
|
||||
if (mCountdownSubscribe != null && !mCountdownSubscribe.isDisposed()) {
|
||||
mCountdownSubscribe.dispose();
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Disposable mCheckOrderSubscribe;
|
||||
|
||||
private void checkOrder(WxpayBean wxpayBean) {
|
||||
if (mCheckOrderSubscribe != null && !mCheckOrderSubscribe.isDisposed()) {
|
||||
mCheckOrderSubscribe.dispose();
|
||||
}
|
||||
mCheckOrderSubscribe = Observable.interval(5, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Long>() {
|
||||
|
||||
@Override
|
||||
public void accept(Long aLong) throws Exception {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getOrderPayCheckObservable(wxpayBean.getOrder_sn(), wxpayBean.getOrder_id())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("checkOrder", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("checkOrder", "onNext: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
if (mCountdownSubscribe != null && !mCountdownSubscribe.isDisposed()) {
|
||||
mCountdownSubscribe.dispose();
|
||||
}
|
||||
if (mCheckOrderSubscribe != null && !mCheckOrderSubscribe.isDisposed()) {
|
||||
mCheckOrderSubscribe.dispose();
|
||||
}
|
||||
ToastUtil.show("支付成功");
|
||||
finish();
|
||||
} else {
|
||||
Log.e("checkOrder", "onNext: " + "支付失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("checkOrder", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("checkOrder", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.uiuios.aios.adapter.GoodsListAdapter;
|
||||
import com.uiuios.aios.base.BaseActivity;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.bean.GoodsList;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
@@ -76,16 +77,17 @@ public class SpikeListActivity extends BaseActivity {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycleSubject, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<GoodsInfo>>>() {
|
||||
.subscribe(new Observer<BaseResponse<GoodsList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getGoods", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<GoodsInfo>> listBaseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<GoodsList> listBaseResponse) {
|
||||
Log.e("getGoods", "onNext: " + listBaseResponse);
|
||||
List<GoodsInfo> goodsInfos = listBaseResponse.data;
|
||||
GoodsList goodsList = listBaseResponse.data;
|
||||
List<GoodsInfo> goodsInfos = goodsList.getData();
|
||||
if (goodsInfos != null && goodsInfos.size() != 0) {
|
||||
iv1.setVisibility(android.view.View.GONE);
|
||||
mGoodsAdapter.setGoodsInfoList(goodsInfos);
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.bumptech.glide.Glide;
|
||||
import com.shehuan.niv.NiceImageView;
|
||||
import com.uiuios.aios.R;
|
||||
import com.uiuios.aios.activity.DetailsActivity;
|
||||
import com.uiuios.aios.activity.GoodsActivity;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -41,8 +42,22 @@ public class NewGoodsAdapter extends RecyclerView.Adapter<NewGoodsAdapter.GoodsH
|
||||
public void onBindViewHolder(@NonNull GoodsHolder holder, int position) {
|
||||
GoodsInfo goodsInfo = goodsInfoList.get(position);
|
||||
Glide.with(holder.nv_goods_pic).load(goodsInfo.getImg()).error(mContext.getResources().getDrawable(R.drawable.nodata)).into(holder.nv_goods_pic);
|
||||
holder.root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mContext.startActivity(new Intent(mContext, GoodsActivity.class));
|
||||
}
|
||||
});
|
||||
holder.tv_goods_title.setText(goodsInfo.getGoods_desc());
|
||||
holder.tv_goods_pirce.setText("热卖促销¥" + goodsInfo.getBuying_price());
|
||||
holder.tv_buy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(mContext, DetailsActivity.class);
|
||||
intent.putExtra("GoodsInfo", goodsInfo);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,6 +66,7 @@ public class NewGoodsAdapter extends RecyclerView.Adapter<NewGoodsAdapter.GoodsH
|
||||
}
|
||||
|
||||
static class GoodsHolder extends RecyclerView.ViewHolder {
|
||||
ConstraintLayout root;
|
||||
NiceImageView nv_goods_pic;
|
||||
TextView tv_goods_title;
|
||||
TextView tv_goods_pirce;
|
||||
@@ -58,6 +74,7 @@ public class NewGoodsAdapter extends RecyclerView.Adapter<NewGoodsAdapter.GoodsH
|
||||
|
||||
public GoodsHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
root = itemView.findViewById(R.id.root);
|
||||
nv_goods_pic = itemView.findViewById(R.id.nv_goods_pic);
|
||||
tv_goods_title = itemView.findViewById(R.id.tv_goods_title);
|
||||
tv_goods_pirce = itemView.findViewById(R.id.tv_goods_pirce);
|
||||
|
||||
112
app/src/main/java/com/uiuios/aios/base/DataBindingActivity.java
Normal file
112
app/src/main/java/com/uiuios/aios/base/DataBindingActivity.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package com.uiuios.aios.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.ContentView;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
import com.uiuios.aios.R;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
public abstract class DataBindingActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {
|
||||
public final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
public DataBindingActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ContentView
|
||||
public DataBindingActivity(@LayoutRes int contentLayoutId) {
|
||||
super(contentLayoutId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final Observable<ActivityEvent> lifecycle() {
|
||||
return lifecycleSubject.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {
|
||||
return RxLifecycle.bindUntilEvent(lifecycleSubject, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
@CheckResult
|
||||
public final <T> LifecycleTransformer<T> bindToLifecycle() {
|
||||
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化视图
|
||||
*/
|
||||
public abstract void initView();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
public abstract void initData();
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
lifecycleSubject.onNext(ActivityEvent.START);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
lifecycleSubject.onNext(ActivityEvent.RESUME);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onPause() {
|
||||
lifecycleSubject.onNext(ActivityEvent.PAUSE);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onStop() {
|
||||
lifecycleSubject.onNext(ActivityEvent.STOP);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CallSuper
|
||||
protected void onDestroy() {
|
||||
lifecycleSubject.onNext(ActivityEvent.DESTROY);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
27
app/src/main/java/com/uiuios/aios/bean/ArticleList.java
Normal file
27
app/src/main/java/com/uiuios/aios/bean/ArticleList.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class ArticleList implements Serializable {
|
||||
private static final long serialVersionUID = 2429549762527224397L;
|
||||
|
||||
int current_page;
|
||||
List<ArticleInfo> data;
|
||||
|
||||
public int getCurrent_page() {
|
||||
return current_page;
|
||||
}
|
||||
|
||||
public void setCurrent_page(int current_page) {
|
||||
this.current_page = current_page;
|
||||
}
|
||||
|
||||
public List<ArticleInfo> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<ArticleInfo> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.io.Serializable;
|
||||
|
||||
public class GoodsInfo implements Serializable {
|
||||
private static final long serialVersionUID = -229267734972111105L;
|
||||
int id;
|
||||
String id;
|
||||
/*商品名*/
|
||||
String goods_name;
|
||||
/*简介*/
|
||||
@@ -18,9 +18,9 @@ public class GoodsInfo implements Serializable {
|
||||
/*视频链接*/
|
||||
String video_url;
|
||||
/*原价*/
|
||||
float original_price;
|
||||
String original_price;
|
||||
/*抢购价*/
|
||||
float buying_price;
|
||||
String buying_price;
|
||||
/*库存*/
|
||||
int stock;
|
||||
/*跳转链接*/
|
||||
@@ -31,14 +31,16 @@ public class GoodsInfo implements Serializable {
|
||||
String ensure;
|
||||
@SerializedName("class")
|
||||
String type;
|
||||
int weight;
|
||||
int click_count;
|
||||
int type_id;
|
||||
|
||||
|
||||
|
||||
public int getId() {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -82,19 +84,19 @@ public class GoodsInfo implements Serializable {
|
||||
this.video_url = video_url;
|
||||
}
|
||||
|
||||
public float getOriginal_price() {
|
||||
public String getOriginal_price() {
|
||||
return original_price;
|
||||
}
|
||||
|
||||
public void setOriginal_price(float original_price) {
|
||||
public void setOriginal_price(String original_price) {
|
||||
this.original_price = original_price;
|
||||
}
|
||||
|
||||
public float getBuying_price() {
|
||||
public String getBuying_price() {
|
||||
return buying_price;
|
||||
}
|
||||
|
||||
public void setBuying_price(float buying_price) {
|
||||
public void setBuying_price(String buying_price) {
|
||||
this.buying_price = buying_price;
|
||||
}
|
||||
|
||||
@@ -153,4 +155,28 @@ public class GoodsInfo implements Serializable {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(int weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public int getClick_count() {
|
||||
return click_count;
|
||||
}
|
||||
|
||||
public void setClick_count(int click_count) {
|
||||
this.click_count = click_count;
|
||||
}
|
||||
|
||||
public int getType_id() {
|
||||
return type_id;
|
||||
}
|
||||
|
||||
public void setType_id(int type_id) {
|
||||
this.type_id = type_id;
|
||||
}
|
||||
}
|
||||
|
||||
27
app/src/main/java/com/uiuios/aios/bean/GoodsList.java
Normal file
27
app/src/main/java/com/uiuios/aios/bean/GoodsList.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class GoodsList implements Serializable {
|
||||
private static final long serialVersionUID = 2691720359257416172L;
|
||||
|
||||
int current_page;
|
||||
List<GoodsInfo> data;
|
||||
|
||||
public int getCurrent_page() {
|
||||
return current_page;
|
||||
}
|
||||
|
||||
public void setCurrent_page(int current_page) {
|
||||
this.current_page = current_page;
|
||||
}
|
||||
|
||||
public List<GoodsInfo> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<GoodsInfo> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
25
app/src/main/java/com/uiuios/aios/bean/GoodsType.java
Normal file
25
app/src/main/java/com/uiuios/aios/bean/GoodsType.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class GoodsType implements Serializable {
|
||||
private static final long serialVersionUID = -3861404325733396969L;
|
||||
int id;
|
||||
String name;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
35
app/src/main/java/com/uiuios/aios/bean/OrderBean.java
Normal file
35
app/src/main/java/com/uiuios/aios/bean/OrderBean.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OrderBean implements Serializable {
|
||||
private static final long serialVersionUID = -7589758006696263943L;
|
||||
|
||||
String order_id;
|
||||
String order_sn;
|
||||
String sn;
|
||||
|
||||
public String getOrder_id() {
|
||||
return order_id;
|
||||
}
|
||||
|
||||
public void setOrder_id(String order_id) {
|
||||
this.order_id = order_id;
|
||||
}
|
||||
|
||||
public String getOrder_sn() {
|
||||
return order_sn;
|
||||
}
|
||||
|
||||
public void setOrder_sn(String order_sn) {
|
||||
this.order_sn = order_sn;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
}
|
||||
34
app/src/main/java/com/uiuios/aios/bean/RegionInfo.java
Normal file
34
app/src/main/java/com/uiuios/aios/bean/RegionInfo.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class RegionInfo implements Serializable {
|
||||
private static final long serialVersionUID = 6794758421072894673L;
|
||||
String id;
|
||||
String area_name;
|
||||
String parent_id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getArea_name() {
|
||||
return area_name;
|
||||
}
|
||||
|
||||
public void setArea_name(String area_name) {
|
||||
this.area_name = area_name;
|
||||
}
|
||||
|
||||
public String getParent_id() {
|
||||
return parent_id;
|
||||
}
|
||||
|
||||
public void setParent_id(String parent_id) {
|
||||
this.parent_id = parent_id;
|
||||
}
|
||||
}
|
||||
80
app/src/main/java/com/uiuios/aios/bean/WxpayBean.java
Normal file
80
app/src/main/java/com/uiuios/aios/bean/WxpayBean.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package com.uiuios.aios.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class WxpayBean implements Serializable {
|
||||
private static final long serialVersionUID = -8399062772511195038L;
|
||||
|
||||
String price;
|
||||
String code_url;
|
||||
long time_expire;
|
||||
String goods_name;
|
||||
String goods_img;
|
||||
String order_sn;
|
||||
String order_id;
|
||||
String num;
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getCode_url() {
|
||||
return code_url;
|
||||
}
|
||||
|
||||
public void setCode_url(String code_url) {
|
||||
this.code_url = code_url;
|
||||
}
|
||||
|
||||
public long getTime_expire() {
|
||||
return time_expire;
|
||||
}
|
||||
|
||||
public void setTime_expire(long time_expire) {
|
||||
this.time_expire = time_expire;
|
||||
}
|
||||
|
||||
public String getGoods_name() {
|
||||
return goods_name;
|
||||
}
|
||||
|
||||
public void setGoods_name(String goods_name) {
|
||||
this.goods_name = goods_name;
|
||||
}
|
||||
|
||||
public String getGoods_img() {
|
||||
return goods_img;
|
||||
}
|
||||
|
||||
public void setGoods_img(String goods_img) {
|
||||
this.goods_img = goods_img;
|
||||
}
|
||||
|
||||
public String getOrder_sn() {
|
||||
return order_sn;
|
||||
}
|
||||
|
||||
public void setOrder_sn(String order_sn) {
|
||||
this.order_sn = order_sn;
|
||||
}
|
||||
|
||||
public String getOrder_id() {
|
||||
return order_id;
|
||||
}
|
||||
|
||||
public void setOrder_id(String order_id) {
|
||||
this.order_id = order_id;
|
||||
}
|
||||
|
||||
public String getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(String num) {
|
||||
this.num = num;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,11 @@ public class CommonConfig {
|
||||
public static final String MAP_LONGITUDE_KEY = "map_longitude_key";
|
||||
public static final String MAP_LATITUDE_KEY = "map_latitude_key";
|
||||
public static final String MAP_ADDRESS_KEY = "map_address_key";
|
||||
public static final String MAP_PROVINCE_KEY = "map_province_key";
|
||||
public static final String MAP_CITY_KEY = "map_city_key";
|
||||
public static final String MAP_DISTRICT_KEY = "map_district_key";
|
||||
public static final String MAP_STREET_KEY = "map_street_key";
|
||||
public static final String MAP_LOCATION_DESCRIBE_KEY = "map_locationDescribe_key";
|
||||
public static final String MAP_ERROR_KEY = "map_error_key";
|
||||
|
||||
public static final String LOCK_SCREEN_PASSWORD ="aios_lockScreenPasswordKey";
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSnapHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -54,6 +55,9 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
@BindView(R.id.rv_knowledge)
|
||||
RecyclerView rv_knowledge;
|
||||
|
||||
@BindView(R.id.cl_service)
|
||||
ConstraintLayout cl_service;
|
||||
|
||||
private View rootView;
|
||||
private Context mContext;
|
||||
private ContentResolver mCRv;
|
||||
@@ -174,13 +178,13 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
Log.e("rv_goods", "onScrollStateChanged: newState = " + newState);
|
||||
Log.i("rv_goods", "onScrollStateChanged: newState = " + newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
mGoodsScrolling = false;
|
||||
// 获取当前滚动到的条目位置
|
||||
int firstIndex = linearLayoutManager.findFirstVisibleItemPosition();
|
||||
Log.e("rv_goods", "onScrollStateChanged: firstIndex = " + firstIndex);
|
||||
Log.e("rv_goods", "onScrollStateChanged: mCurrentGoodsIndex = " + mCurrentGoodsIndex);
|
||||
Log.i("rv_goods", "onScrollStateChanged: firstIndex = " + firstIndex);
|
||||
Log.i("rv_goods", "onScrollStateChanged: mCurrentGoodsIndex = " + mCurrentGoodsIndex);
|
||||
mCurrentGoodsIndex = firstIndex + 1;
|
||||
} else {
|
||||
mGoodsScrolling = true;
|
||||
@@ -204,13 +208,13 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
Log.e("rv_article", "onScrollStateChanged: newState = " + newState);
|
||||
Log.i("rv_article", "onScrollStateChanged: newState = " + newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
mArticleScrolling = false;
|
||||
// 获取当前滚动到的条目位置
|
||||
int firstIndex = linearLayoutManager2.findFirstVisibleItemPosition();
|
||||
Log.e("rv_article", "onScrollStateChanged: firstIndex = " + firstIndex);
|
||||
Log.e("rv_article", "onScrollStateChanged: mCurrentArticleIndex = " + mCurrentArticleIndex);
|
||||
Log.i("rv_article", "onScrollStateChanged: firstIndex = " + firstIndex);
|
||||
Log.i("rv_article", "onScrollStateChanged: mCurrentArticleIndex = " + mCurrentArticleIndex);
|
||||
mCurrentArticleIndex = firstIndex + 1;
|
||||
} else {
|
||||
mArticleScrolling = true;
|
||||
@@ -274,6 +278,13 @@ public class SecondFragment extends BaseFragment implements SecondContact.View,
|
||||
rv_knowledge.setAdapter(mKnowledgeVideoAdapter);
|
||||
LinearSnapHelper snapHelper4 = new LinearSnapHelper();
|
||||
snapHelper4.attachToRecyclerView(rv_knowledge);
|
||||
|
||||
cl_service.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.video.bean.VideoInfo;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.ArticleList;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.bean.GoodsList;
|
||||
import com.uiuios.aios.network.NetInterfaceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -54,16 +56,17 @@ public class SecondPresenter implements SecondContact.Presenter {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getGoodsListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<GoodsInfo>>>() {
|
||||
.subscribe(new Observer<BaseResponse<GoodsList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getGoods", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<GoodsInfo>> listBaseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<GoodsList> listBaseResponse) {
|
||||
Log.e("getGoods", "onNext: " + listBaseResponse);
|
||||
List<GoodsInfo> goodsInfos = listBaseResponse.data;
|
||||
GoodsList goodsList = listBaseResponse.data;
|
||||
List<GoodsInfo> goodsInfos = goodsList.getData();
|
||||
mView.setGoods(goodsInfos);
|
||||
}
|
||||
|
||||
@@ -83,16 +86,18 @@ public class SecondPresenter implements SecondContact.Presenter {
|
||||
public void getArticle() {
|
||||
NetInterfaceManager.getInstance().getArticleListObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<List<ArticleInfo>>>() {
|
||||
.subscribe(new Observer<BaseResponse<ArticleList>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getArticle", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<ArticleInfo>> listBaseResponse) {
|
||||
public void onNext(@NonNull BaseResponse<ArticleList> listBaseResponse) {
|
||||
Log.e("getArticle", "onNext: " + listBaseResponse);
|
||||
mView.setArticle(listBaseResponse.data);
|
||||
ArticleList articleList = listBaseResponse.data;
|
||||
List<ArticleInfo> articleInfoList = articleList.getData();
|
||||
mView.setArticle(articleInfoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +125,7 @@ public class SecondPresenter implements SecondContact.Presenter {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<ArrayList<VideoInfo>> listBaseResponse) {
|
||||
Log.e("getLivenVideoList", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code==200){
|
||||
if (listBaseResponse.code == 200) {
|
||||
mView.setLivenVideoList(listBaseResponse.data);
|
||||
}
|
||||
}
|
||||
@@ -149,7 +154,7 @@ public class SecondPresenter implements SecondContact.Presenter {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<ArrayList<VideoInfo>> listBaseResponse) {
|
||||
Log.e("getKnowledgeVideoList", "onNext: " + listBaseResponse);
|
||||
if (listBaseResponse.code==200){
|
||||
if (listBaseResponse.code == 200) {
|
||||
mView.setKnowledgeVideoList(listBaseResponse.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,13 @@ public class RemoteManager {
|
||||
}.getType();
|
||||
MapBean mapBean = gson.fromJson(jsonString, type);
|
||||
mMMKV.encode(CommonConfig.MAP_ADDRESS_KEY, mapBean.getAddress() + mapBean.getLocationDescribe());
|
||||
mMMKV.encode(CommonConfig.MAP_LONGITUDE_KEY, mapBean.getLongitude());
|
||||
mMMKV.encode(CommonConfig.MAP_LATITUDE_KEY, mapBean.getLatitude());
|
||||
mMMKV.encode(CommonConfig.MAP_LONGITUDE_KEY, String.valueOf(mapBean.getLongitude()));
|
||||
mMMKV.encode(CommonConfig.MAP_LATITUDE_KEY, String.valueOf(mapBean.getLatitude()));
|
||||
mMMKV.encode(CommonConfig.MAP_PROVINCE_KEY, mapBean.getProvince());
|
||||
mMMKV.encode(CommonConfig.MAP_CITY_KEY, mapBean.getCity());
|
||||
mMMKV.encode(CommonConfig.MAP_DISTRICT_KEY, mapBean.getDistrict());
|
||||
mMMKV.encode(CommonConfig.MAP_STREET_KEY, mapBean.getTown() + mapBean.getStreet());
|
||||
mMMKV.encode(CommonConfig.MAP_LOCATION_DESCRIBE_KEY, mapBean.getStreet() + mapBean.getLocationDescribe());
|
||||
return mapBean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,23 +11,28 @@ import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.uiui.video.bean.VideoInfo;
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.alarm.AlarmUtils;
|
||||
import com.uiuios.aios.bean.ActivityBean;
|
||||
import com.uiuios.aios.alarm.AlarmClockData;
|
||||
import com.uiuios.aios.bean.AlarmClockId;
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.ArticleList;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.CategoryBean;
|
||||
import com.uiuios.aios.bean.Contact;
|
||||
import com.uiuios.aios.bean.DemandBean;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.bean.GoodsList;
|
||||
import com.uiuios.aios.bean.GoodsType;
|
||||
import com.uiuios.aios.bean.HealthCode;
|
||||
import com.uiuios.aios.bean.MapGeoBean;
|
||||
import com.uiuios.aios.bean.NetDesktopIcon;
|
||||
import com.uiuios.aios.bean.OrderBean;
|
||||
import com.uiuios.aios.bean.RegionInfo;
|
||||
import com.uiuios.aios.bean.SnInfo;
|
||||
import com.uiuios.aios.bean.SystemSettings;
|
||||
import com.uiuios.aios.bean.UserAvatarInfo;
|
||||
import com.uiuios.aios.bean.UserId;
|
||||
import com.uiuios.aios.bean.WxpayBean;
|
||||
import com.uiuios.aios.config.CommonConfig;
|
||||
import com.uiuios.aios.disklrucache.CacheHelper;
|
||||
import com.uiuios.aios.gson.GsonUtils;
|
||||
@@ -41,6 +46,7 @@ import com.uiuios.aios.network.api.AlarmClockDeleteApi;
|
||||
import com.uiuios.aios.network.api.AlarmClockEditApi;
|
||||
import com.uiuios.aios.network.api.AlarmClockQueryApi;
|
||||
import com.uiuios.aios.network.api.AppUsageRecordApi;
|
||||
import com.uiuios.aios.network.api.ArticleCategorysListApi;
|
||||
import com.uiuios.aios.network.api.ArticleListApi;
|
||||
import com.uiuios.aios.network.api.CategorysApi;
|
||||
import com.uiuios.aios.network.api.DemandListApi;
|
||||
@@ -48,11 +54,18 @@ import com.uiuios.aios.network.api.GetAdminSnSettingApi;
|
||||
import com.uiuios.aios.network.api.GetDesktopApi;
|
||||
import com.uiuios.aios.network.api.GetMailList;
|
||||
import com.uiuios.aios.network.api.GetUserIDApi;
|
||||
import com.uiuios.aios.network.api.GoodsBuyApi;
|
||||
import com.uiuios.aios.network.api.GoodsListApi;
|
||||
import com.uiuios.aios.network.api.GoodsTypeApi;
|
||||
import com.uiuios.aios.network.api.GoodsTypeListApi;
|
||||
import com.uiuios.aios.network.api.HealthCodeApi;
|
||||
import com.uiuios.aios.network.api.KnowledgeVideoListApi;
|
||||
import com.uiuios.aios.network.api.LivenVideoListApi;
|
||||
import com.uiuios.aios.network.api.MailListAddApi;
|
||||
import com.uiuios.aios.network.api.OrderPayApi;
|
||||
import com.uiuios.aios.network.api.OrderPayCheckApi;
|
||||
import com.uiuios.aios.network.api.RegionListApi;
|
||||
import com.uiuios.aios.network.api.RegionListCall;
|
||||
import com.uiuios.aios.network.api.RunNewApp;
|
||||
import com.uiuios.aios.network.api.SNInfoApi;
|
||||
import com.uiuios.aios.network.api.SOSRecordApi;
|
||||
@@ -83,9 +96,11 @@ import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@@ -210,6 +225,26 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(String param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), param);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(int param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(param));
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(long param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(param));
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(double param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(param));
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过sn获取设备的信息
|
||||
*
|
||||
@@ -271,27 +306,41 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<GoodsInfo>>> getGoodsListObservable() {
|
||||
public Observable<BaseResponse<GoodsList>> getGoodsListObservable() {
|
||||
return mRetrofit.create(GoodsListApi.class)
|
||||
.getGoodsList(RemoteManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<CategoryBean>>> getCategorysObservable() {
|
||||
return mRetrofit.create(CategorysApi.class)
|
||||
.getCategorys(RemoteManager.getInstance().getSerial())
|
||||
public Observable<BaseResponse<GoodsList>> getGoodsListObservable(int type) {
|
||||
return mRetrofit.create(GoodsTypeListApi.class)
|
||||
.getGoodsList(RemoteManager.getInstance().getSerial(), type)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<ArticleInfo>>> getArticleListObservable() {
|
||||
public Observable<BaseResponse<List<CategoryBean>>> getCategorysObservable() {
|
||||
return mRetrofit.create(CategorysApi.class)
|
||||
.getArticleCategorys(RemoteManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<ArticleList>> getArticleListObservable() {
|
||||
return mRetrofit.create(ArticleListApi.class)
|
||||
.getArticleList(RemoteManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<ArticleList>> getArticleListObservable(int id) {
|
||||
return mRetrofit.create(ArticleCategorysListApi.class)
|
||||
.getArticleList(RemoteManager.getInstance().getSerial(),id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<Contact>>> getContactListObservable() {
|
||||
return mRetrofit.create(GetMailList.class)
|
||||
.getContact(RemoteManager.getInstance().getSerial())
|
||||
@@ -320,6 +369,14 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
public Observable<BaseResponse<List<GoodsType>>> getGoodsTypeListObservable() {
|
||||
return mRetrofit.create(GoodsTypeApi.class)
|
||||
.getGoodsTypeList()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
/*
|
||||
*闹钟相关
|
||||
*/
|
||||
@@ -382,6 +439,42 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<RegionInfo>>> getRegionListObservable(String id) {
|
||||
return mRetrofit.create(RegionListApi.class)
|
||||
.getRegionList(id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<OrderBean>> getGoodsBuyObservable(Map<String, RequestBody> params) {
|
||||
return mRetrofit.create(GoodsBuyApi.class)
|
||||
.goodsBuy(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<WxpayBean>> getOrderPayObservable(String order_sn, String order_id) {
|
||||
return mRetrofit.create(OrderPayApi.class)
|
||||
.orderPay(RemoteManager.getInstance().getSerial(), order_sn, order_id, BuildConfig.APPLICATION_ID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getOrderPayCheckObservable(String order_sn, String order_id) {
|
||||
return mRetrofit.create(OrderPayCheckApi.class)
|
||||
.checkOrder(RemoteManager.getInstance().getSerial(), order_sn, order_id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
public RegionListApi getRegionListApi() {
|
||||
return mRetrofit.create(RegionListApi.class);
|
||||
}
|
||||
|
||||
public RegionListCall getRegionListCall() {
|
||||
return mRetrofit.create(RegionListCall.class);
|
||||
}
|
||||
|
||||
public interface onCompleteCallback {
|
||||
void onComplete();
|
||||
|
||||
@@ -24,14 +24,22 @@ public class UrlAddress {
|
||||
public static final String UPDATE_DESKTOP_LAYOUT = "updateDesktopLayout";
|
||||
/*获取桌面布局*/
|
||||
public static final String GET_DESKTOP_LAYOUT = "getDesktopLayout";
|
||||
/*获取商品分类列表*/
|
||||
public static final String GOODS_TYPE_LIST = "goods-type-list";
|
||||
/*获取抢购列表*/
|
||||
public static final String GET_GOODS_LIST = "getGoodsList";
|
||||
/*养生资讯分类*/
|
||||
public static final String CATEGORYS = "article/categorys";
|
||||
/*获取资讯列表*/
|
||||
public static final String GET_ARTICLE_LIST = "getArticleList";
|
||||
/*获取抢购详情*/
|
||||
public static final String GET_GOODS_DETAILS = "getGoodsDetails";
|
||||
/*商品下单*/
|
||||
public static final String GOODS_BUY = "goods/buy";
|
||||
/*商品调起支付*/
|
||||
public static final String ORDER_PAY = "pay/order-pay";
|
||||
/*商品支付查询(低频轮询)*/
|
||||
public static final String ORDER_PAY_CHECK = "pay/order-pay-check";
|
||||
/*养生资讯分类*/
|
||||
public static final String ARTICLE_CATEGORYS = "article/categorys";
|
||||
/*获取资讯列表*/
|
||||
public static final String GET_ARTICLE_LIST = "getArticleList";
|
||||
/*获取资讯详情*/
|
||||
public static final String GET_ARTICLE_DETAILS = "getArticleDetails";
|
||||
/*同城活动列表*/
|
||||
@@ -69,6 +77,18 @@ public class UrlAddress {
|
||||
|
||||
public static final String GET_USER_ID = "getUserId";
|
||||
|
||||
/*获取省市区数据*/
|
||||
public static final String REGION_LIST = "common/region-list";
|
||||
|
||||
/**
|
||||
* 订单管理
|
||||
*/
|
||||
/*订单列表*/
|
||||
public static final String ORDER_INDEX = "order/index";
|
||||
/*订单详情*/
|
||||
public static final String ORDER_SHOW = "order/show";
|
||||
/*订单物流查询*/
|
||||
public static final String ORDER_EXPRESS = "order/express";
|
||||
|
||||
|
||||
/*养生视频列表*/
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.ArticleList;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleCategorysListApi {
|
||||
@GET(UrlAddress.GET_ARTICLE_LIST)
|
||||
Observable<BaseResponse<ArticleList>> getArticleList(
|
||||
@Query("sn") String sn,
|
||||
@Query("article_type") int articleType
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.ArticleList;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
@@ -12,7 +13,7 @@ import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleListApi {
|
||||
@GET(UrlAddress.GET_ARTICLE_LIST)
|
||||
Observable<BaseResponse<List<ArticleInfo>>> getArticleList(
|
||||
Observable<BaseResponse<ArticleList>> getArticleList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface CategorysApi {
|
||||
@GET(UrlAddress.CATEGORYS)
|
||||
Observable<BaseResponse<List<CategoryBean>>> getCategorys(
|
||||
@GET(UrlAddress.ARTICLE_CATEGORYS)
|
||||
Observable<BaseResponse<List<CategoryBean>>> getArticleCategorys(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.OrderBean;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.PartMap;
|
||||
|
||||
public interface GoodsBuyApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.GOODS_BUY)
|
||||
Observable<BaseResponse<OrderBean>> goodsBuy(
|
||||
@PartMap Map<String, RequestBody> params
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.bean.GoodsList;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsListApi {
|
||||
@GET(UrlAddress.GET_GOODS_LIST)
|
||||
Observable<BaseResponse<List<GoodsInfo>>> getGoodsList(
|
||||
Observable<BaseResponse<GoodsList>> getGoodsList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsType;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
|
||||
public interface GoodsTypeApi {
|
||||
@GET(UrlAddress.GOODS_TYPE_LIST)
|
||||
Observable<BaseResponse<List<GoodsType>>> getGoodsTypeList(
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsList;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsTypeListApi {
|
||||
@GET(UrlAddress.GET_GOODS_LIST)
|
||||
Observable<BaseResponse<GoodsList>> getGoodsList(
|
||||
@Query("sn") String sn,
|
||||
@Query("goods_type") int goodsType
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.WxpayBean;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface OrderPayApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.ORDER_PAY)
|
||||
Observable<BaseResponse<WxpayBean>> orderPay(
|
||||
@Field("sn") String sn,
|
||||
@Field("order_sn") String order_sn,
|
||||
@Field("order_id") String order_id,
|
||||
@Field("desktop_app_package") String desktop_app_package
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface OrderPayCheckApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.ORDER_PAY_CHECK)
|
||||
Observable<BaseResponse> checkOrder(
|
||||
@Field("sn") String sn,
|
||||
@Field("order_sn") String order_sn,
|
||||
@Field("order_id") String order_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.RegionInfo;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface RegionListApi {
|
||||
@GET(UrlAddress.REGION_LIST)
|
||||
Observable<BaseResponse<List<RegionInfo>>> getRegionList(
|
||||
@Query("parent_id") String parent_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.RegionInfo;
|
||||
import com.uiuios.aios.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface RegionListCall {
|
||||
@GET(UrlAddress.REGION_LIST)
|
||||
Flowable<BaseResponse<List<RegionInfo>>> getRegionList(
|
||||
@Query("parent_id") String parent_id
|
||||
);
|
||||
}
|
||||
@@ -17,9 +17,17 @@ import android.graphics.drawable.VectorDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.uiuios.aios.R;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BitmapUtils {
|
||||
public static Bitmap Bytes2Bimap(byte[] b) {
|
||||
@@ -137,4 +145,59 @@ public class BitmapUtils {
|
||||
return background;
|
||||
}
|
||||
|
||||
|
||||
public static Bitmap createQRImage(String content, int widthPix, int heightPix) {
|
||||
try {
|
||||
// if (content == null || "".equals(content)) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
//配置参数
|
||||
Map<EncodeHintType, Object> hints = new HashMap<>();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
|
||||
//容错级别
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
|
||||
//设置空白边距的宽度
|
||||
hints.put(EncodeHintType.MARGIN, 1); //default is 4
|
||||
|
||||
// 图像数据转换,使用了矩阵转换
|
||||
BitMatrix bitMatrix = null;
|
||||
try {
|
||||
bitMatrix = new QRCodeWriter().encode(content, BarcodeFormat.QR_CODE, widthPix,
|
||||
heightPix, hints);
|
||||
} catch (WriterException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int[] pixels = new int[widthPix * heightPix];
|
||||
// 下面这里按照二维码的算法,逐个生成二维码的图片,
|
||||
// 两个for循环是图片横列扫描的结果
|
||||
for (int y = 0; y < heightPix; y++) {
|
||||
for (int x = 0; x < widthPix; x++) {
|
||||
if (bitMatrix.get(x, y)) {
|
||||
pixels[y * widthPix + x] = 0xff000000;
|
||||
} else {
|
||||
pixels[y * widthPix + x] = 0xffffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 生成二维码图片的格式,使用ARGB_8888
|
||||
Bitmap bitmap = Bitmap.createBitmap(widthPix, heightPix, Bitmap.Config.ARGB_8888);
|
||||
bitmap.setPixels(pixels, 0, widthPix, 0, 0, widthPix, heightPix);
|
||||
//
|
||||
// if (logoBm != null) {
|
||||
// bitmap = addLogo(bitmap, logoBm);
|
||||
// }
|
||||
|
||||
//必须使用compress方法将bitmap保存到文件中再进行读取。直接返回的bitmap是没有任何压缩的,
|
||||
// 内存消耗巨大!
|
||||
return bitmap;
|
||||
// return bitmap != null && bitmap.compress(Bitmap.CompressFormat.JPEG, 100);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
281
app/src/main/java/com/uiuios/aios/view/CounterView.java
Normal file
281
app/src/main/java/com/uiuios/aios/view/CounterView.java
Normal file
@@ -0,0 +1,281 @@
|
||||
package com.uiuios.aios.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.icu.math.BigDecimal;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.uiuios.aios.utils.ToastUtil;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2023-2024 Author
|
||||
*
|
||||
* 数量加减控件
|
||||
* 前面减号后面加号中间输入
|
||||
*
|
||||
* @author xiaolu
|
||||
* @date 2023/11/8
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class CounterView extends LinearLayout {
|
||||
private Button decreaseButton; // 减少按钮
|
||||
private Button increaseButton; // 增加按钮
|
||||
private EditText valueEditText; // 数值编辑框
|
||||
private View customView; // 自定义视图
|
||||
|
||||
private BigDecimal minValue = BigDecimal.ZERO; // 最小值
|
||||
private BigDecimal maxValue = BigDecimal.valueOf(100); // 最大值
|
||||
private BigDecimal increment = BigDecimal.ONE; // 步进值
|
||||
private BigDecimal defaultValue = BigDecimal.ZERO; // 默认值
|
||||
private OnValueChangedListener valueChangedListener; // 数值变化监听器
|
||||
private boolean decimalEnabled = false; // 是否允许小数
|
||||
private int decimalPlaces = 0; // 小数位数
|
||||
|
||||
/**
|
||||
* 构造方法,用于创建 CustomCounterView 实例。
|
||||
*
|
||||
* @param context 上下文参数,不能为空
|
||||
*/
|
||||
public CounterView(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法,用于创建 CustomCounterView 实例。
|
||||
*
|
||||
* @param context 上下文参数,不能为空
|
||||
* @param attrs 属性参数
|
||||
*/
|
||||
public CounterView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
applyAttributes(context, attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造方法,用于创建 CustomCounterView 实例。
|
||||
*
|
||||
* @param context 上下文参数,不能为空
|
||||
* @param attrs 属性参数
|
||||
* @param defStyle 默认样式参数
|
||||
*/
|
||||
public CounterView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init(context);
|
||||
applyAttributes(context, attrs);
|
||||
}
|
||||
|
||||
// 初始化方法
|
||||
private void init(Context context) {
|
||||
decreaseButton = new Button(context);
|
||||
decreaseButton.setText("-");
|
||||
addView(decreaseButton);
|
||||
|
||||
valueEditText = new EditText(context);
|
||||
valueEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
addView(valueEditText);
|
||||
|
||||
increaseButton = new Button(context);
|
||||
increaseButton.setText("+");
|
||||
addView(increaseButton);
|
||||
|
||||
customView = new View(context);
|
||||
addView(customView);
|
||||
|
||||
decreaseButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
decreaseValue();
|
||||
}
|
||||
});
|
||||
|
||||
increaseButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
increaseValue();
|
||||
}
|
||||
});
|
||||
|
||||
valueEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
try {
|
||||
BigDecimal currentValue = new BigDecimal(s.toString());
|
||||
if (currentValue.compareTo(minValue) < 0) {
|
||||
ToastUtil.show("输入数字不能小于最小值 " + minValue);
|
||||
setEditTextValue(minValue.toString());
|
||||
} else if (currentValue.compareTo(maxValue) > 0) {
|
||||
ToastUtil.show("输入数字不能大于最大值 " + maxValue);
|
||||
setEditTextValue(maxValue.toString());
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 应用属性方法
|
||||
private void applyAttributes(Context context, AttributeSet attrs) {
|
||||
|
||||
}
|
||||
|
||||
// 设置默认值方法
|
||||
public void setDefaultValue(BigDecimal defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
setValue(defaultValue);
|
||||
}
|
||||
|
||||
// 设置最小值方法
|
||||
public void setMinValue(BigDecimal minValue) {
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
// 设置最大值方法
|
||||
public void setMaxValue(BigDecimal maxValue) {
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
// 设置步进值方法
|
||||
public void setIncrement(BigDecimal increment) {
|
||||
this.increment = increment;
|
||||
}
|
||||
|
||||
// 获取当前数值方法
|
||||
public BigDecimal getValue() {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 设置数值方法
|
||||
public void setValue(BigDecimal value) {
|
||||
valueEditText.setText(value.toString());
|
||||
// 将光标移动到文本末尾
|
||||
valueEditText.setSelection(valueEditText.getText().length());
|
||||
}
|
||||
|
||||
// 更新文本数据方法
|
||||
private void setEditTextValue(String value) {
|
||||
valueEditText.setText(value);
|
||||
// 将光标移动到文本末尾
|
||||
valueEditText.setSelection(valueEditText.getText().length());
|
||||
}
|
||||
|
||||
// 减少数值方法
|
||||
private void decreaseValue() {
|
||||
try {
|
||||
String input = valueEditText.getText().toString().trim();
|
||||
if (!input.isEmpty()) {
|
||||
BigDecimal currentValue = new BigDecimal(input);
|
||||
BigDecimal newValue = currentValue.subtract(increment);
|
||||
if (newValue.compareTo(minValue) < 0) {
|
||||
ToastUtil.show("输入数字不能小于最小值 " + minValue);
|
||||
newValue = minValue;
|
||||
}
|
||||
setEditTextValue(newValue.toString());
|
||||
notifyValueChanged();
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
setEditTextValue("0");
|
||||
notifyValueChanged();
|
||||
}
|
||||
}
|
||||
|
||||
// 增加数值方法
|
||||
private void increaseValue() {
|
||||
try {
|
||||
String input = valueEditText.getText().toString().trim();
|
||||
if (!input.isEmpty()) {
|
||||
BigDecimal currentValue = new BigDecimal(input);
|
||||
BigDecimal newValue = currentValue.add(increment);
|
||||
if (newValue.compareTo(maxValue) > 0) {
|
||||
ToastUtil.show("输入数字不能大于最大值 " + maxValue);
|
||||
newValue = maxValue;
|
||||
}
|
||||
setEditTextValue(newValue.toString());
|
||||
notifyValueChanged();
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
setEditTextValue("0");
|
||||
notifyValueChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启小数输入
|
||||
* @param decimalEnabled 是否开启 开:true 关:false
|
||||
* @param decimalPlaces 小数位数控制,如果是-1不控制位数,否则就是小数位数
|
||||
*/
|
||||
public void setDecimalEnabled(boolean decimalEnabled, int decimalPlaces) {
|
||||
this.decimalEnabled = decimalEnabled;
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
if (decimalEnabled) {
|
||||
if (decimalPlaces == -1) {
|
||||
valueEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
} else {
|
||||
valueEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||
}
|
||||
} else {
|
||||
valueEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
}
|
||||
applyDecimalFilter();
|
||||
}
|
||||
|
||||
private void applyDecimalFilter() {
|
||||
valueEditText.setFilters(new InputFilter[]{new InputFilter() {
|
||||
@Override
|
||||
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
|
||||
if (decimalEnabled) {
|
||||
String value = dest.toString().substring(0, dstart) + source.toString() + dest.toString().substring(dend);
|
||||
if (!value.isEmpty() && !value.equals(".") && !value.equals("-")) {
|
||||
try {
|
||||
BigDecimal newValue = new BigDecimal(value);
|
||||
if (decimalPlaces >= 0 && newValue.scale() > decimalPlaces) {
|
||||
return "";
|
||||
}
|
||||
} catch (NumberFormatException | ArithmeticException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}});
|
||||
}
|
||||
|
||||
// 通知值已经改变方法
|
||||
private void notifyValueChanged() {
|
||||
if (valueChangedListener != null) {
|
||||
valueChangedListener.onValueChanged(new BigDecimal(valueEditText.getText().toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// 设置数值变化监听器方法
|
||||
public void setOnValueChangedListener(OnValueChangedListener listener) {
|
||||
this.valueChangedListener = listener;
|
||||
}
|
||||
|
||||
// 数值变化监听器接口
|
||||
public interface OnValueChangedListener {
|
||||
void onValueChanged(BigDecimal newValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user