概述
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
//glid圆角图片依赖
implementation 'jp.wasabeef:glide-transformations:3.3.0'
//glide的依赖
implementation 'com.github.bumptech.glide:glide:4.8.0'
//tablayout依赖
implementation 'com.android.support:design:28.0.0'
//okhttp3的依赖
implementation 'com.squareup.okhttp3:okhttp:3.7.0'
implementation 'com.squareup.okio:okio:1.12.0'
//BottomTabBar依赖
implementation 'com.hjm:BottomTabBar:1.1.1'
//recyclerListView依赖
//implementation 'com.android.support:recyclerview-v7:28.0.0'
//gson的依赖
implementation 'com.google.code.gson:gson:2.8.5'
//xbanner的依赖
implementation 'com.xhb:xbanner:1.2.2'
//xrecyclerview的依赖
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.jcodecraeer:xrecyclerview:1.3.2'
//xrecyclerview的依赖编译出错问题
implementation 'com.android.support:design:28.0.0'
//流式布局
compile 'com.nex3z:flow-layout:0.1.2'
MainActivity
package com.bawei.appp;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import com.bawei.appp.frag.Frag1;
import com.bawei.appp.frag.Frag2;
import com.bawei.appp.frag.Frag3;
import com.hjm.bottomtabbar.BottomTabBar;
public class MainActivity extends AppCompatActivity {
private BottomTabBar bar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bar = findViewById(R.id.bar);
bar.init(getSupportFragmentManager())
.setChangeColor(Color.YELLOW,Color.RED)
.setImgSize(50,50)
.addTabItem("首页",R.drawable.yi,Frag1.class)
.addTabItem("列表",R.drawable.er,Frag2.class).
addTabItem("我的",R.drawable.san,Frag3.class);
}
}
Frag1
package com.bawei.appp.frag;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.bawei.appp.R;
import com.bawei.appp.adapter.MyAdapter;
import com.bawei.appp.bean.Bean;
import com.bawei.appp.present.Present;
import com.google.gson.Gson;
import java.util.List;
public class Frag1 extends Fragment {
private CheckBox quan;
private RecyclerView re1;
private Present present;
private List<Bean.DataBean> data1;
private MyAdapter myAdapter;
private Bean bean;
private TextView jie;
private int num1;
private int price11;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.frag1, container, false);
quan = view.findViewById(R.id.quan1);
re1 = view.findViewById(R.id.re1);
jie = view.findViewById(R.id.jie);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
re1.setLayoutManager(linearLayoutManager);
present = new Present(this);
present.Ipr();
quan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
checkedd(isChecked);
}
});
return view;
}
public void getView(String data) {
Gson gson = new Gson();
bean = gson.fromJson(data, Bean.class);
data1 = bean.getData();
data1.remove(0);
myAdapter = new MyAdapter(getActivity(), data1);
re1.setAdapter(myAdapter);
}
private void checkedd(boolean isChecked) {
int num11=0;
for (int i = 0; i <data1.size() ; i++) {
Bean.DataBean dataBean = data1.get(i);
dataBean.setIscheck(isChecked);
for (int j = 0; j <data1.get(i).getList().size() ; j++) {
data1.get(i).getList().get(j).setIscheck(isChecked);
if(quan.isChecked()){
String num = data1.get(i).getList().get(j).getNum();
String price = data1.get(i).getList().get(j).getPrice();
num1 = Integer.parseInt(num);
price11 = Integer.parseInt(price);
num11+=num1* price11;
}
}
jie.setText("总价为"+num11);
myAdapter.notifyDataSetChanged();
}
}
}
okhttp
package com.bawei.appp.okhttp;
import java.io.IOException;
import java.time.Instant;
import java.util.concurrent.TimeUnit;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class Okhttp {
private static FormBody build;
private static Okhttp instance;
private static Okhttp okhttp;
private static Okhttp okhttp1;
//单利
private static Okhttp get(){
if(instance==null){
synchronized (Okhttp.class){
if(null==instance){
okhttp1 = new Okhttp();
}
}
}
return okhttp1;
}
//拦截器
private Interceptor interceptor(){
Interceptor interceptor = new Interceptor(){
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Response proceed = chain.proceed(request);
return proceed;
}
};
return interceptor;
}
private Okhttp(){
OkHttpClient build = new OkHttpClient().newBuilder()
.addInterceptor(interceptor())
.connectTimeout(3000, TimeUnit.DAYS)
.writeTimeout(3000, TimeUnit.DAYS)
.readTimeout(3000, TimeUnit.DAYS)
.build();
}
public static void okhttpGet(String url, Callback callback){
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder().url(url).method("GET", null).build();
okHttpClient.newCall(request).enqueue(callback);
}
public static void okhttpPost(String url,String number,String pwd,Callback callback){
OkHttpClient okHttpClient = new OkHttpClient();
build = new FormBody.Builder().add("phone", number).add("pwd", pwd).build();
Request build1 = new Request.Builder().url(url).post(build).build();
okHttpClient.newCall(build1).enqueue(callback);
}
}
IModel
package com.bawei.appp.model;
import javax.security.auth.callback.Callback;
public interface IModel {
void Imo(String url, Callback callback);
interface Callback{
void Success(String data);
}
void DlImo(String url,String number,String pwd, DlCallback dlCallback);
interface DlCallback{
void Success(String data1);
}
void ZcImo(String url,String number,String pwd, ZcCallback zcCallback);
interface ZcCallback{
void Success(String data2);
}
}
Model
package com.bawei.appp.model;
import com.bawei.appp.okhttp.Okhttp;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class Model implements IModel {
@Override
public void Imo(String url, final Callback callback) {
Okhttp.okhttpGet(url, new okhttp3.Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
callback.Success(response.body().string());
}
});
}
@Override
public void DlImo(String url, String number, String pwd, final DlCallback dlCallback) {
Okhttp.okhttpPost(url, number, pwd, new okhttp3.Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
dlCallback.Success(response.body().string());
}
});
}
@Override
public void ZcImo(String url, String number, String pwd, final ZcCallback zcCallback) {
Okhttp.okhttpPost(url, number, pwd, new okhttp3.Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
zcCallback.Success(response.body().string());
}
});
}
}
Ipresent
package com.bawei.appp.present;
public interface IPresent {
void Ipr();
void DlIpr(String number,String pwd);
void ZcIpr(String number,String pwd);
}
present
package com.bawei.appp.present;
import com.bawei.appp.api.Api;
import com.bawei.appp.frag.Frag1;
import com.bawei.appp.frag.Frag3;
import com.bawei.appp.model.IModel;
import com.bawei.appp.model.Model;
import com.bawei.appp.view.IView;
import com.bawei.appp.view.IViews;
public class Present implements IPresent {
Frag1 frag1;
private final Model model;
public Present(Frag1 frag1) {
this.frag1 = frag1;
model = new Model();
}
IView iView;
public Present(IView iView) {
this.iView = iView;
model = new Model();
}
public Present(IViews iViews) {
this.iViews = iViews;
model = new Model();
}
IViews iViews;
@Override
public void Ipr() {
model.Imo(Api.str, new IModel.Callback() {
@Override
public void Success(String data) {
frag1.getView(data);
}
});
}
@Override
public void DlIpr(String number, String pwd) {
model.DlImo(Api.dl, number, pwd, new IModel.DlCallback() {
@Override
public void Success(String data1) {
iView.getView(data1);
}
});
}
@Override
public void ZcIpr(String number, String pwd) {
model.ZcImo(Api.zc, number, pwd, new IModel.ZcCallback() {
@Override
public void Success(String data2) {
iViews.getView(data2);
}
});
}
}
View
public interface IView {
void getView(String data1);
}
Views
public interface IViews {
void getView(String data2);
}
Api
public class Api {
public static String str="http://172.17.8.100/ks/product/getCarts?uid=51";
public static String dl="http://172.17.8.100/small/user/v1/login";
public static String zc="http://172.17.8.100/small/user/v1/register";
}
MyAdapter
package com.bawei.appp.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import com.bawei.appp.R;
import com.bawei.appp.bean.Bean;
import java.util.List;
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
private List<Bean.DataBean.ListBean> list1;
public MyAdapter(Context context, List<Bean.DataBean> list) {
this.context = context;
this.list = list;
}
Context context;
List<Bean.DataBean>list;
@NonNull
@Override
public MyAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = View.inflate(viewGroup.getContext(), R.layout.item1, null);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull final MyAdapter.ViewHolder viewHolder, final int i) {
viewHolder.text22.setText(list.get(i).getSellerName());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false);
viewHolder.re2.setLayoutManager(linearLayoutManager);
for (int j = 0; j <list.size() ; j++) {
list1 = this.list.get(i).getList();
}
YouAdapter youAdapter = new YouAdapter(context, list1);
viewHolder.re2.setAdapter(youAdapter);
viewHolder.quan.setChecked(list.get(i).getIscheck());
viewHolder.quan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
list.get(i).setIscheck(viewHolder.quan.isChecked());
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final CheckBox quan;
private final RecyclerView re2;
private final TextView text22;
public ViewHolder(@NonNull View itemView) {
super(itemView);
quan = itemView.findViewById(R.id.quan2);
re2 = itemView.findViewById(R.id.re2);
text22 = itemView.findViewById(R.id.text22);
}
}
}
YouAdapter
package com.bawei.appp.adapter;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import com.bawei.appp.R;
import com.bawei.appp.bean.Bean;
import com.bawei.appp.zdy.Zdy;
import com.bumptech.glide.Glide;
import java.util.List;
public class YouAdapter extends RecyclerView.Adapter<YouAdapter.ViewHolder> {
public YouAdapter(Context context, List<Bean.DataBean.ListBean> list) {
this.context = context;
this.list = list;
}
Context context;
List<Bean.DataBean.ListBean>list;
@NonNull
@Override
public YouAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = View.inflate(viewGroup.getContext(), R.layout.item2, null);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull YouAdapter.ViewHolder viewHolder, int i) {
viewHolder.text33.setText(list.get(i).getSubhead());
viewHolder.text333.setText(list.get(i).getBargainPrice());
viewHolder.quan3.setChecked(list.get(i).getIscheck());
viewHolder.zdy_text.setOnaddListenner(new Zdy.OnaddListenner() {
@Override
public void num1istenner(int num) {
}
});
Glide.with(context).load(list.get(0).getDetailUrl()).into(viewHolder.img3);
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private final TextView text33;
private final TextView text333;
private final CheckBox quan3;
private final ImageView img3;
private final Zdy zdy_text;
public ViewHolder(@NonNull View itemView) {
super(itemView);
text33 = itemView.findViewById(R.id.text33);
text333 = itemView.findViewById(R.id.text333);
quan3 = itemView.findViewById(R.id.quan3);
img3 = itemView.findViewById(R.id.img3);
zdy_text = itemView.findViewById(R.id.zdy_text1);
}
}
}
Bean
package com.bawei.appp.bean;
import java.util.List;
public class Bean {
/**
* msg : 请求成功
* code : 0
* data : [{"list":[{"bargainPrice":99,"createtime":"2017-10-14T21:38:26","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":45,"price":2999,"pscid":39,"selected":0,"sellerid":1,"subhead":"高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!","title":"一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家1","sellerid":"1"},{"list":[{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":3,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":3,"pid":25,"price":399,"pscid":2,"selected":0,"sellerid":2,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家2","sellerid":"2"},{"list":[{"bargainPrice":1599,"createtime":"2017-10-14T21:48:08","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":47,"price":111,"pscid":39,"selected":0,"sellerid":3,"subhead":"碳黑色 32GB 全网通 官方标配 1件","title":"锤子 坚果Pro 特别版 巧克力色 酒红色 全网通 移动联通电信4G手机 双卡双待 碳黑色 32GB 全网通"},{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":10,"price":556,"pscid":1,"selected":0,"sellerid":3,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家3","sellerid":"3"},{"list":[{"bargainPrice":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":3,"pid":48,"price":222,"pscid":39,"selected":0,"sellerid":4,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":1999,"createtime":"2017-10-10T16:09:02","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":1,"pid":49,"price":333,"pscid":39,"selected":0,"sellerid":5,"subhead":"vivo X20 带你开启全面屏时代!逆光也清晰,照亮你的美!","title":"vivo X20 全面屏手机 全网通 4GB+64GB 金色 移动联通电信4G手机 双卡双待"}],"sellerName":"商家5","sellerid":"5"},{"list":[{"bargainPrice":3455,"createtime":"2017-10-14T21:48:08","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":3,"pid":50,"price":444,"pscid":39,"selected":0,"sellerid":6,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家6","sellerid":"6"},{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":1,"pid":30,"price":688,"pscid":2,"selected":0,"sellerid":7,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"},{"bargainPrice":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":15,"pid":51,"price":555,"pscid":39,"selected":0,"sellerid":7,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家7","sellerid":"7"},{"list":[{"bargainPrice":3455,"createtime":"2017-10-03T23:53:28","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":9,"pid":54,"price":888,"pscid":39,"selected":0,"sellerid":10,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"},{"bargainPrice":22.9,"createtime":"2017-10-03T23:43:53","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":1,"pid":33,"price":988,"pscid":2,"selected":0,"sellerid":10,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}],"sellerName":"商家10","sellerid":"10"},{"list":[{"bargainPrice":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":1,"pid":55,"price":5999,"pscid":39,"selected":0,"sellerid":11,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家11","sellerid":"11"},{"list":[{"bargainPrice":159,"createtime":"2017-10-14T21:49:15","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":1,"pid":104,"price":369,"pscid":112,"selected":0,"sellerid":14,"subhead":"针织针织闪闪闪亮你的眼","title":"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL"}],"sellerName":"商家14","sellerid":"14"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":71,"price":32999,"pscid":40,"selected":0,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家15","sellerid":"15"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":7,"pid":1,"price":118,"pscid":1,"selected":0,"sellerid":17,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家17","sellerid":"17"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":5,"pid":2,"price":299,"pscid":1,"selected":0,"sellerid":18,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家18","sellerid":"18"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-03T23:53:28","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":206,"pid":3,"price":198,"pscid":1,"selected":0,"sellerid":19,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家19","sellerid":"19"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:48:08","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":4,"pid":4,"price":999,"pscid":1,"selected":0,"sellerid":20,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家20","sellerid":"20"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":5,"price":89,"pscid":1,"selected":0,"sellerid":21,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家21","sellerid":"21"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-03T23:53:28","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":1,"pid":6,"price":8,"pscid":1,"selected":0,"sellerid":22,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家22","sellerid":"22"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":1,"pid":7,"price":120,"pscid":1,"selected":0,"sellerid":23,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家23","sellerid":"23"}]
*/
private String msg;
private String code;
private List<DataBean> data;
/* private Boolean isCheck=false;
public void setCheck(Boolean check) {
isCheck = check;
}
public Boolean getCheck() {
return isCheck;
}*/
private Boolean ischeck=false;
public Boolean getIscheck() {
return ischeck;
}
public void setIscheck(Boolean ischeck) {
this.ischeck = ischeck;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
/**
* list : [{"bargainPrice":99,"createtime":"2017-10-14T21:38:26","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":45,"price":2999,"pscid":39,"selected":0,"sellerid":1,"subhead":"高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!","title":"一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机"},{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","images":"http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg","num":2,"pid":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋"}]
* sellerName : 商家1
* sellerid : 1
*/
private String sellerName;
private String sellerid;
private List<ListBean> list;
private Boolean ischeck=false;
public Boolean getIscheck() {
return ischeck;
}
public void setIscheck(Boolean ischeck) {
this.ischeck = ischeck;
}
public String getSellerName() {
return sellerName;
}
public void setSellerName(String sellerName) {
this.sellerName = sellerName;
}
public String getSellerid() {
return sellerid;
}
public void setSellerid(String sellerid) {
this.sellerid = sellerid;
}
public List<ListBean> getList() {
return list;
}
public void setList(List<ListBean> list) {
this.list = list;
}
public static class ListBean {
/**
* bargainPrice : 99
* createtime : 2017-10-14T21:38:26
* detailUrl : http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg
* images : http://172.17.8.100/images/small/commodity/xbsd/sjb/5/1.jpg
* num : 2
* pid : 45
* price : 2999
* pscid : 39
* selected : 0
* sellerid : 1
* subhead : 高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!
* title : 一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机
*/
private String bargainPrice;
private String createtime;
private String detailUrl;
private String images;
private String num;
private String pid;
private String price;
private String pscid;
private String selected;
private String sellerid;
private String subhead;
private String title;
private Boolean ischeck=false;
public Boolean getIscheck() {
return ischeck;
}
public void setIscheck(Boolean ischeck) {
this.ischeck = ischeck;
}
public String getBargainPrice() {
return bargainPrice;
}
public void setBargainPrice(String bargainPrice) {
this.bargainPrice = bargainPrice;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getDetailUrl() {
return detailUrl;
}
public void setDetailUrl(String detailUrl) {
this.detailUrl = detailUrl;
}
public String getImages() {
return images;
}
public void setImages(String images) {
this.images = images;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getPscid() {
return pscid;
}
public void setPscid(String pscid) {
this.pscid = pscid;
}
public String getSelected() {
return selected;
}
public void setSelected(String selected) {
this.selected = selected;
}
public String getSellerid() {
return sellerid;
}
public void setSellerid(String sellerid) {
this.sellerid = sellerid;
}
public String getSubhead() {
return subhead;
}
public void setSubhead(String subhead) {
this.subhead = subhead;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
}
}
dlbean
package com.bawei.appp.bean;
public class dlBean {
/**
* result : {"headPic":"http://172.17.8.100/images/small/default/user.jpg","nickName":"nu_4OIuU","phone":"15862430000","sessionId":"15545359699223058","sex":1,"userId":3058}
* message : 登录成功
* status : 0000
*/
private ResultBean result;
private String message;
private String status;
public ResultBean getResult() {
return result;
}
public void setResult(ResultBean result) {
this.result = result;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public static class ResultBean {
/**
* headPic : http://172.17.8.100/images/small/default/user.jpg
* nickName : nu_4OIuU
* phone : 15862430000
* sessionId : 15545359699223058
* sex : 1
* userId : 3058
*/
private String headPic;
private String nickName;
private String phone;
private String sessionId;
private int sex;
private int userId;
public String getHeadPic() {
return headPic;
}
public void setHeadPic(String headPic) {
this.headPic = headPic;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
}
}
Zcc
package com.bawei.appp.bean;
public class ZccBean {
private String message;
private String status;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
main3Activity
package com.bawei.appp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.bawei.appp.bean.dlBean;
import com.bawei.appp.present.Present;
import com.bawei.appp.view.IView;
import com.bawei.appp.view.IViews;
import com.google.gson.Gson;
public class Main3Activity extends AppCompatActivity implements IView {
private EditText number;
private EditText pwd;
private Button zc;
private Button dl;
private Present present;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
number = findViewById(R.id.number);
pwd = findViewById(R.id.pwd);
zc = findViewById(R.id.zc);
dl = findViewById(R.id.dl);
present = new Present(this);
zc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Main3Activity.this,RegistActivity.class);
startActivity(intent);
finish();
}
});
dl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String numbers = number.getText().toString();
String pwds = pwd.getText().toString();
if(TextUtils.isEmpty(numbers)||TextUtils.isEmpty(pwds)){
Toast.makeText(Main3Activity.this,"用户名或密码不能为空",Toast.LENGTH_SHORT).show();
}else{
present.DlIpr(numbers,pwds);
}
}
});
}
@Override
public void getView(final String data1) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
dlBean dlBean = gson.fromJson(data1, dlBean.class);
String status = dlBean.getStatus();
if(status.equals("0000")){
Intent intent = new Intent(Main3Activity.this,ShowActivity.class);
startActivity(intent);
finish();
}else{
Toast.makeText(Main3Activity.this,"登录失败",Toast.LENGTH_SHORT).show();
}
}
});
}
}
registactivity
package com.bawei.appp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ZoomControls;
import com.bawei.appp.bean.ZccBean;
import com.bawei.appp.present.Present;
import com.bawei.appp.view.IView;
import com.bawei.appp.view.IViews;
import com.google.gson.Gson;
public class RegistActivity extends AppCompatActivity implements IViews {
private EditText number;
private EditText pwd;
private Button zc;
private Button dl;
private Present present;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_regist);
number = findViewById(R.id.number);
pwd = findViewById(R.id.pwd);
zc = findViewById(R.id.zc);
dl = findViewById(R.id.dl);
present = new Present(this);
dl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(RegistActivity.this,Main3Activity.class);
startActivity(intent);
finish();
}
});
zc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String numbers = number.getText().toString();
String pwds = pwd.getText().toString();
if(TextUtils.isEmpty(numbers)||TextUtils.isEmpty(pwds)){
Toast.makeText(RegistActivity.this,"用户名或密码不能为空",Toast.LENGTH_SHORT).show();
}else{
present.ZcIpr(numbers,pwds);
}
}
});
}
@Override
public void getView(final String data2) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
ZccBean zccBean = gson.fromJson(data2, ZccBean.class);
String status = zccBean.getStatus();
if(status.equals("0000")){
Intent intent = new Intent(RegistActivity.this,Main3Activity.class);
startActivity(intent);
finish();
}else {
Toast.makeText(RegistActivity.this,"登录失败",Toast.LENGTH_SHORT).show();
}
}
});
}
}
showactivity
package com.bawei.appp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class ShowActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show);
}
}
zdy
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/jian"
android:text="-"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/zdy_text"
android:text="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/jia"
android:text="+"/>
</LinearLayout>
item1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/quan2"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sssss"
android:id="@+id/text22"
/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/re2"></android.support.v7.widget.RecyclerView>
</LinearLayout>
item2
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/quan3"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/ic_launcher_background"
android:id="@+id/img3"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/text33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="1234" />
<TextView
android:id="@+id/text333"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="1234" />
</LinearLayout>
</LinearLayout>
<com.bawei.appp.zdy.Zdy
android:id="@+id/zdy_text1"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:layout_marginRight="30dp"
></com.bawei.appp.zdy.Zdy>
</RelativeLayout>
frag1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="购物车"
android:gravity="center"
android:textSize="30sp"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/quan1"
android:text="全选"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/re1"></android.support.v7.widget.RecyclerView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/jie"
android:text="结算"
android:background="#f00"/>
</LinearLayout>
regist
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RegistActivity"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/number"
android:hint="请输入账号"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pwd"
android:hint="请输入密码"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="已注册"
android:id="@+id/zc"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录"
android:id="@+id/dl"/>
</LinearLayout>
main3
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main3Activity"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/number"
android:hint="请输入账号"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pwd"
android:hint="请输入密码"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册"
android:id="@+id/zc"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录"
android:id="@+id/dl"/>
</LinearLayout>
main
<?xml version="1.0" encoding="utf-8"?>
<com.hjm.bottomtabbar.BottomTabBar
android:layout_width=“match_parent”
android:layout_height=“0dp”
android:layout_weight=“7”
android:id="@+id/bar"></com.hjm.bottomtabbar.BottomTabBar>
package com.bawei.appp.frag;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import com.bawei.appp.Main3Activity;
import com.bawei.appp.R;
import com.bawei.appp.present.Present;
public class Frag3 extends Fragment {
private Button button;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.frag3, container, false);
button = view.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getActivity(),Main3Activity.class));
}
});
return view;
}
}
最后
以上就是灵巧小懒猪为你收集整理的YK的全部内容,希望文章能够帮你解决YK所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复