-<manifest package="com.bawei.test.okmvpreanview" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
-<application android:theme="@style/AppTheme" android:supportsRtl="true" android:roundIcon="@mipmap/ic_launcher_round" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="true">
-<activity android:name=".MainActivity">
-<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".Main2Activity"/>
<activity android:name=".Main22Activity"/>
</application>
</manifest>
导入依赖
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.okio:okio:1.5.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.jcodecraeer:xrecyclerview:1.3.2'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'org.greenrobot:eventbus:3.1.1'
compile 'com.youth.banner:banner:1.4.10'
- 布局管理
- activity_main
<LinearLayout
tools:context="com.bawei.test.okmvpreanview.MainActivity"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_width="match_parent"
xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">
<com.youth.banner.Banner android:layout_height="200dp" android:layout_width="match_parent" android:id="@+id/banner"/>
<com.jcodecraeer.xrecyclerview.XRecyclerView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/mRecyclerView"/>
</LinearLayout>
activity_main2
-<LinearLayout tools:context="com.bawei.test.okmvpreanview.Main2Activity" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/progressloading" android:id="@+id/img"/>
</LinearLayout>
activity_main22
-<LinearLayout tools:context="com.bawei.test.okmvpreanview.Main22Activity" android:orientation="vertical" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">
<ExpandableListView android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1" android:id="@+id/exlv"/>
-<RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/rl" android:background="#ffffff">
<CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/checkbox" android:layout_centerVertical="true"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/qx" android:layout_centerVertical="true" android:text="全选" android:layout_toRightOf="@id/checkbox"/>
-<LinearLayout android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_centerVertical="true" android:layout_toRightOf="@id/qx">
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/price" android:text="总价:0.0"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/num" android:text="共0件商品"/>
</LinearLayout>
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/jiesuan" android:background="#ff0000" android:text="去结算" android:layout_alignParentRight="true"/>
</RelativeLayout>
</LinearLayout>
chidren
-<RelativeLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="11dp" android:layout_centerVertical="true" android:id="@+id/z_che"/>
-<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginTop="30dp" android:id="@+id/linearLayout" android:orientation="vertical" android:layout_toRightOf="@id/z_che">
<TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/z_title" android:textStyle="bold" android:text="三只松鼠大礼包"/>
-<RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent">
<ImageView android:layout_height="140dp" android:layout_width="140dp" android:id="@+id/z_img" android:src="@mipmap/ic_launcher"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/z_price" android:layout_toRightOf="@+id/z_img" android:text="价钱" android:textColor="#ff0000" android:layout_toEndOf="@+id/z_img" android:layout_alignParentTop="true"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/z_shuxing" android:layout_toRightOf="@+id/z_img" android:text="价钱" android:layout_toEndOf="@+id/z_img" android:layout_below="@+id/z_price"/>
-<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginTop="10dp" android:orientation="horizontal" android:layout_toRightOf="@id/z_img" android:layout_below="@id/z_shuxing">
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:id="@+id/iv_jian" android:src="@drawable/shopcart_minus_red"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tv_num" android:text="1" android:layout_marginLeft="10dp"/>
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:id="@+id/iv_add" android:src="@drawable/shopcart_add_red" android:layout_marginLeft="5dp"/>
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:id="@+id/del" android:src="@drawable/rublish" android:layout_weight="1" android:layout_gravity="right"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<CheckBox android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginTop="11dp" android:layout_centerVertical="true" android:id="@+id/z_che"/>
-<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginTop="30dp" android:id="@+id/linearLayout" android:orientation="vertical" android:layout_toRightOf="@id/z_che">
<TextView android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/z_title" android:textStyle="bold" android:text="三只松鼠大礼包"/>
-<RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent">
<ImageView android:layout_height="140dp" android:layout_width="140dp" android:id="@+id/z_img" android:src="@mipmap/ic_launcher"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/z_price" android:layout_toRightOf="@+id/z_img" android:text="价钱" android:textColor="#ff0000" android:layout_toEndOf="@+id/z_img" android:layout_alignParentTop="true"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/z_shuxing" android:layout_toRightOf="@+id/z_img" android:text="价钱" android:layout_toEndOf="@+id/z_img" android:layout_below="@+id/z_price"/>
-<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_marginTop="10dp" android:orientation="horizontal" android:layout_toRightOf="@id/z_img" android:layout_below="@id/z_shuxing">
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:id="@+id/iv_jian" android:src="@drawable/shopcart_minus_red"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tv_num" android:text="1" android:layout_marginLeft="10dp"/>
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:id="@+id/iv_add" android:src="@drawable/shopcart_add_red" android:layout_marginLeft="5dp"/>
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:id="@+id/del" android:src="@drawable/rublish" android:layout_weight="1" android:layout_gravity="right"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
group
-<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBox android:layout_height="25dp" android:layout_width="25dp" android:id="@+id/che"/>
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:src="@drawable/dianpu" android:layout_marginLeft="20dp"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/g_title" android:layout_marginLeft="20dp" android:text="------------"/>
</LinearLayout>
<CheckBox android:layout_height="25dp" android:layout_width="25dp" android:id="@+id/che"/>
<ImageView android:layout_height="20dp" android:layout_width="20dp" android:src="@drawable/dianpu" android:layout_marginLeft="20dp"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/g_title" android:layout_marginLeft="20dp" android:text="------------"/>
</LinearLayout>
item
-<LinearLayout android:orientation="horizontal" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:layout_height="100dp" android:layout_width="100dp" android:id="@+id/img"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tv" android:textSize="20dp" android:layout_marginTop="20dp"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tv2" android:textSize="10dp"/>
</LinearLayout>
<ImageView android:layout_height="100dp" android:layout_width="100dp" android:id="@+id/img"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tv" android:textSize="20dp" android:layout_marginTop="20dp"/>
<TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tv2" android:textSize="10dp"/>
</LinearLayout>
代码实现:
MainActivity:
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import com.jcodecraeer.xrecyclerview.ProgressStyle;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
import java.util.ArrayList;
import java.util.List;
import model.Bean;
import model.MyImageLoader;
import prestern.MyAdapter;
import prestern.Presenter;
import view.Iv;
public class MainActivity extends AppCompatActivity implements Iv {
private Banner banner;
private List<String> ban ;
private XRecyclerView mRecyclerView;
private MyAdapter adapter;
private Presenter presenter;
private int page=1;
private boolean flag=true;
private List<Bean.NewslistBean> lists=new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//intData();
intView();
mRecyclerView= (XRecyclerView) findViewById(R.id.mRecyclerView);
LinearLayoutManager man =new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false);
mRecyclerView.setLayoutManager(man);
adapter=new MyAdapter(this,lists);
mRecyclerView.setAdapter(adapter);
mRecyclerView.setLoadingMoreEnabled(true);
mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.SquareSpin);
mRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
@Override
public void onRefresh() {
page=1;
flag=true;
loadData();
}
@Override
public void onLoadMore() {
page++;
flag=false;
loadData();
}
});
loadData();
adapter.setmOnItemClickListener(new MyAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Intent intent =new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent);
}
});
}
private void loadData() {
presenter =new Presenter(this);
presenter.get(page);
}
private void intView(){
banner= (Banner) findViewById(R.id.banner);
ImageLoaderConfiguration builder = new ImageLoaderConfiguration.Builder(this).build();
ImageLoader.getInstance().init(builder);
//设置banner样式
banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR_TITLE_INSIDE);
//设置图片加载器
banner.setImageLoader(new MyImageLoader());
ban =new ArrayList<>();
ban.add("http://m.xxxiao.com/wp-content/uploads/sites/3/2016/12/m.xxxiao.com_8d3ec6a8fce075bc94ca008f746c5fbd-683x1024.jpg");
ban.add("http://m.xxxiao.com/wp-content/uploads/sites/3/2016/02/m.xxxiao.com_71f2ebd5e0ce640e7da09-683x1024.jpg");
ban.add("http://m.xxxiao.com/wp-content/uploads/sites/3/2016/08/m.xxxiao.com_e8924efccf12b70d0cdcf34a91-683x1024.jpg");
ban.add("http://m.xxxiao.com/wp-content/uploads/sites/3/2016/10/m.xxxiao.com_8ed460a9347e9aa9df3dbf0d-683x1024.jpg");
//设置图片集合
banner.setImages(ban);
List<String> titles = new ArrayList<>();
titles.add("1");
titles.add("2");
titles.add("3");
titles.add("4");
banner.setBannerTitles(titles);
banner.setBannerAnimation(Transformer.DepthPage);
//设置轮播时间
banner.setDelayTime(3000);
banner.start();
}
@Override
public void onSuccess(List<Bean.NewslistBean> list) {
if (flag) {
mRecyclerView.refreshComplete();
}else {
mRecyclerView.loadMoreComplete();
}
lists.clear();
lists.addAll(list);
adapter.notifyDataSetChanged();
}
@Override
public void onFailed(Exception e) {
}
@Override
protected void onDestroy() {
super.onDestroy();
presenter.DetchView();
}
}
Main2Activity
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.content.Intent;
import android.graphics.PointF;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
public class Main2Activity extends AppCompatActivity {
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
imageView = (ImageView) findViewById(R.id.img);
ValueAnimator valueAnimator =new ValueAnimator();
valueAnimator.setDuration(5000);
valueAnimator.setObjectValues(new PointF(0, 0));
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.setEvaluator(new TypeEvaluator<PointF>()
{
// fraction = t / duration
@Override
public PointF evaluate(float fraction, PointF startValue, PointF endValue)
{
// x方向200px/s ,则y方向0.5 * 10 * t
PointF point = new PointF();
point.x = 200 * fraction * 3;
point.y = 0.5f * 200 * (fraction * 3) * (fraction * 3);
return point;
}
});
valueAnimator.start();
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
PointF point = (PointF) animation.getAnimatedValue();
imageView.setX(point.x);
imageView.setY(point.y);
}
});
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
Intent intent = new Intent(Main2Activity.this, Main22Activity.class);
startActivity(intent);
Main2Activity.this.finish();
}
}, 5000);
}
}
Main22Activity
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ExpandableListView;
import android.widget.TextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.util.ArrayList;
import java.util.List;
import model.ElvDataBean;
import prestern.Elvpresenter;
import prestern.MessageEvent;
import prestern.MyElvadapter;
import prestern.PriceAndCountEvent;
import view.Iview;
public class Main22Activity extends AppCompatActivity implements Iview {
private ExpandableListView exlv;
private CheckBox checkBox;
private MyElvadapter adapter;
private List<ElvDataBean.DataBean> grouplist = new ArrayList<>();
private List<List<ElvDataBean.DataBean.ListBean>> childlist = new ArrayList<>();
private TextView price;
private TextView num;
private Elvpresenter elvp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main22);
exlv= (ExpandableListView) findViewById(R.id.exlv);
checkBox= (CheckBox) findViewById(R.id.checkbox);
price= (TextView) findViewById(R.id.price);
num= (TextView) findViewById(R.id.num);
EventBus.getDefault().register(this);
//全选/全不选
checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//设置全选
adapter.changeAllListCbState(checkBox.isChecked());
}
});
loadData();
}
private void loadData() {
elvp = new Elvpresenter(this);
elvp.get();
}
@Override
public void Success(ElvDataBean elvDataBean) {
grouplist.clear();
List<ElvDataBean.DataBean> data = elvDataBean.getData();
grouplist.addAll(data);
childlist.clear();
for (int i=0;i<data.size();i++){
ElvDataBean.DataBean dataBean = data.get(i);
List<ElvDataBean.DataBean.ListBean> list = dataBean.getList();
childlist.add(list);
}
adapter =new MyElvadapter(this,grouplist,childlist);
exlv.setAdapter(adapter);
exlv.setGroupIndicator(null);
// 展开
for (int i=0;i<grouplist.size();i++){
exlv.expandGroup(i);
}
adapter.notifyDataSetChanged();
}
@Override
public void Failed(Exception e) {
}
@Subscribe
public void onMessageEvent(MessageEvent event) {
checkBox.setChecked(event.isCheckd());
}
@Subscribe
public void onMessageEven(PriceAndCountEvent event) {
price.setText("总价" + event.getPrice());
num.setText("共" + event.getCount() + "件商品");
}
@Override
protected void onDestroy() {
super.onDestroy();
//eventBus销毁
EventBus.getDefault().unregister(this);
elvp.onDetchView();
}
}
public class Bean {
/
* code : 200
* msg : success
* newslist : [{"ctime":"2016-12-19 12:00","title":"清纯美女 宋梓诺Bee 大尺度性感厨娘写真","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/12/m.xxxiao.com_8d3ec6a8fce075bc94ca008f746c5fbd-683x1024.jpg","url":"http://m.xxxiao.com/99529"},{"ctime":"2016-12-19 12:00","title":"熊熊的欲火刘奕宁Lynn撕开你的虚伪","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/02/m.xxxiao.com_71f2eb33724339167d5e0ce640e7da09-683x1024.jpg","url":"http://m.xxxiao.com/34711"},{"ctime":"2016-12-19 13:00","title":"宅男私藏 叶佳颐 前凸后翘大理大尺度清新靓拍","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/08/m.xxxiao.com_e8924efccf12b70d0c948268dcf34a91-683x1024.jpg","url":"http://m.xxxiao.com/70379"},{"ctime":"2016-12-19 13:00","title":"头条女神 沈晓爱 性感熟女无限风光在乳峰","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/10/m.xxxiao.com_8ed460a9347e9a83482398a9df3dbf0d-683x1024.jpg","url":"http://m.xxxiao.com/87092"},{"ctime":"2016-12-19 13:00","title":"[贴图]高挑旗袍女","description":"华声美女","picUrl":"http://image.hnol.net/c/2016-12/19/08/201612190817336721-4217076.jpg","url":"http://bbs.voc.com.cn/mm/meinv-7591495-0-1.html"},{"ctime":"2016-12-19 14:00","title":"安o的女孩 【2016.12.19】","description":"华声美女","picUrl":"http://image.hnol.net/c/2016-12/19/13/201612191333434331-4761447.jpg","url":"http://bbs.voc.com.cn/mm/meinv-7592036-0-1.html"},{"ctime":"2016-12-19 14:00","title":"美女一枚","description":"华声美女","picUrl":"http://image.hnol.net/c/2016-12/19/10/201612191024588571-3356886.jpg","url":"http://bbs.voc.com.cn/mm/meinv-7591680-0-1.html"},{"ctime":"2016-12-19 15:00","title":"Beautyleg 林瑞瑜Sara 美腿女神金衣裹臀裙写真","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/11/m.xxxiao.com_e8ea6b7f77ce050d74dfdcbb589b159a-683x1024.jpg","url":"http://m.xxxiao.com/91317"},{"ctime":"2016-12-19 15:00","title":"Beautyleg 张欣慈Olivia 黑丝美腿肉丝粉足内衣写真","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/11/m.xxxiao.com_f6a1eba2ece7e96007c32a6151b918a4-683x1024.jpg","url":"http://m.xxxiao.com/97088"},{"ctime":"2016-12-19 17:00","title":"萝莉美颜 程彤颜 黑丝网袜懵懂温柔小绵羊求带走","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/07/m.xxxiao.com_9319492510e5280cb2a574862961bb98-683x1024.jpg","url":"http://m.xxxiao.com/52322"}]
*/
private int code;
private String msg;
private List<NewslistBean> newslist;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<NewslistBean> getNewslist() {
return newslist;
}
public void setNewslist(List<NewslistBean> newslist) {
this.newslist = newslist;
}
public static class NewslistBean {
/
* ctime : 2016-12-19 12:00
* title : 清纯美女 宋梓诺Bee 大尺度性感厨娘写真
* description : 美女写真
* picUrl : http://m.xxxiao.com/wp-content/uploads/sites/3/2016/12/m.xxxiao.com_8d3ec6a8fce075bc94ca008f746c5fbd-683x1024.jpg
* url : http://m.xxxiao.com/99529
*/
private String ctime;
private String title;
private String description;
private String picUrl;
private String url;
public String getCtime() {
return ctime;
}
public void setCtime(String ctime) {
this.ctime = ctime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
}
/
* code : 200
* msg : success
* newslist : [{"ctime":"2016-12-19 12:00","title":"清纯美女 宋梓诺Bee 大尺度性感厨娘写真","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/12/m.xxxiao.com_8d3ec6a8fce075bc94ca008f746c5fbd-683x1024.jpg","url":"http://m.xxxiao.com/99529"},{"ctime":"2016-12-19 12:00","title":"熊熊的欲火刘奕宁Lynn撕开你的虚伪","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/02/m.xxxiao.com_71f2eb33724339167d5e0ce640e7da09-683x1024.jpg","url":"http://m.xxxiao.com/34711"},{"ctime":"2016-12-19 13:00","title":"宅男私藏 叶佳颐 前凸后翘大理大尺度清新靓拍","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/08/m.xxxiao.com_e8924efccf12b70d0c948268dcf34a91-683x1024.jpg","url":"http://m.xxxiao.com/70379"},{"ctime":"2016-12-19 13:00","title":"头条女神 沈晓爱 性感熟女无限风光在乳峰","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/10/m.xxxiao.com_8ed460a9347e9a83482398a9df3dbf0d-683x1024.jpg","url":"http://m.xxxiao.com/87092"},{"ctime":"2016-12-19 13:00","title":"[贴图]高挑旗袍女","description":"华声美女","picUrl":"http://image.hnol.net/c/2016-12/19/08/201612190817336721-4217076.jpg","url":"http://bbs.voc.com.cn/mm/meinv-7591495-0-1.html"},{"ctime":"2016-12-19 14:00","title":"安o的女孩 【2016.12.19】","description":"华声美女","picUrl":"http://image.hnol.net/c/2016-12/19/13/201612191333434331-4761447.jpg","url":"http://bbs.voc.com.cn/mm/meinv-7592036-0-1.html"},{"ctime":"2016-12-19 14:00","title":"美女一枚","description":"华声美女","picUrl":"http://image.hnol.net/c/2016-12/19/10/201612191024588571-3356886.jpg","url":"http://bbs.voc.com.cn/mm/meinv-7591680-0-1.html"},{"ctime":"2016-12-19 15:00","title":"Beautyleg 林瑞瑜Sara 美腿女神金衣裹臀裙写真","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/11/m.xxxiao.com_e8ea6b7f77ce050d74dfdcbb589b159a-683x1024.jpg","url":"http://m.xxxiao.com/91317"},{"ctime":"2016-12-19 15:00","title":"Beautyleg 张欣慈Olivia 黑丝美腿肉丝粉足内衣写真","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/11/m.xxxiao.com_f6a1eba2ece7e96007c32a6151b918a4-683x1024.jpg","url":"http://m.xxxiao.com/97088"},{"ctime":"2016-12-19 17:00","title":"萝莉美颜 程彤颜 黑丝网袜懵懂温柔小绵羊求带走","description":"美女写真","picUrl":"http://m.xxxiao.com/wp-content/uploads/sites/3/2016/07/m.xxxiao.com_9319492510e5280cb2a574862961bb98-683x1024.jpg","url":"http://m.xxxiao.com/52322"}]
*/
private int code;
private String msg;
private List<NewslistBean> newslist;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<NewslistBean> getNewslist() {
return newslist;
}
public void setNewslist(List<NewslistBean> newslist) {
this.newslist = newslist;
}
public static class NewslistBean {
/
* ctime : 2016-12-19 12:00
* title : 清纯美女 宋梓诺Bee 大尺度性感厨娘写真
* description : 美女写真
* picUrl : http://m.xxxiao.com/wp-content/uploads/sites/3/2016/12/m.xxxiao.com_8d3ec6a8fce075bc94ca008f746c5fbd-683x1024.jpg
* url : http://m.xxxiao.com/99529
*/
private String ctime;
private String title;
private String description;
private String picUrl;
private String url;
public String getCtime() {
return ctime;
}
public void setCtime(String ctime) {
this.ctime = ctime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
}
public class ElvDataBean {
/
* msg : 请求成功
* code : 0
* data : [{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.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":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=friends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","num":1,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"},{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=friends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":1,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"}],"sellerName":"商家2","sellerid":"2"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":87,"pid":10,"price":555.55,"pscid":1,"selected":0,"sellerid":3,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家3","sellerid":"3"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":61,"price":14999,"pscid":40,"selected":0,"sellerid":5,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家5","sellerid":"5"},{"list":[{"bargainPrice":159,"createtime":"2017-10-14T21:49:15","detailUrl":"https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t8716/197/1271594444/173291/2f40bb4f/59b743bcN8509428e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8347/264/1286771527/92188/5cf5ec04/59b7420fN65378e9e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7363/165/3000956253/190883/179a372/59b743bfNd0c79d93.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7399/112/2935531768/183594/b77c7d4a/59b7441aNc3d40133.jpg!q70.jpg","num":1,"pid":100,"price":2200,"pscid":112,"selected":0,"sellerid":11,"subhead":"针织针织闪闪闪亮你的眼","title":"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL"}],"sellerName":"商家11","sellerid":"11"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":69,"price":16999,"pscid":40,"selected":0,"sellerid":13,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家13","sellerid":"13"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":2,"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":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":3,"pid":2,"price":299,"pscid":1,"selected":0,"sellerid":18,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家18","sellerid":"18"}]
*/
private String msg;
private String code;
private List<DataBean> data;
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 {
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
/
* list : [{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.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 boolean checked;
private String sellerName;
private String sellerid;
private List<ListBean> list;
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 {
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
/
* bargainPrice : 22.9
* createtime : 2017-10-14T21:48:08
* detailUrl : https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends
* images : https://m.360buyimg.com/n0/jfs/t1930/284///e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336///e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31///c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166///531aa913/N.jpg!q70.jpg
* num : 2
* pid : 24
* price : 288
* pscid : 2
* selected : 0
* sellerid : 1
* subhead : 三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》
* title : 三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋
*/
private boolean checked;
private double bargainPrice;
private String createtime;
private String detailUrl;
private String images;
private int num;
private int pid;
private float price;
private int pscid;
private int selected;
private int sellerid;
private String subhead;
private String title;
public double getBargainPrice() {
return bargainPrice;
}
public void setBargainPrice(double 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 int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public int getPscid() {
return pscid;
}
public void setPscid(int pscid) {
this.pscid = pscid;
}
public int getSelected() {
return selected;
}
public void setSelected(int selected) {
this.selected = selected;
}
public int getSellerid() {
return sellerid;
}
public void setSellerid(int 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;
}
}
}
}
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
/
* Created by HASEE on 2017/11/21.
*/
public class Logger implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
HttpUrl url=original.url().newBuilder()
.addQueryParameter("source","android")
.build();
//添加请求头
Request request = original.newBuilder()
.url(url)
.build();
return chain.proceed(request);
}
}
/
* msg : 请求成功
* code : 0
* data : [{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.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":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=friends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","num":1,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"},{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=friends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":1,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"}],"sellerName":"商家2","sellerid":"2"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":87,"pid":10,"price":555.55,"pscid":1,"selected":0,"sellerid":3,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家3","sellerid":"3"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":61,"price":14999,"pscid":40,"selected":0,"sellerid":5,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家5","sellerid":"5"},{"list":[{"bargainPrice":159,"createtime":"2017-10-14T21:49:15","detailUrl":"https://item.m.jd.com/product/5061723.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t8716/197/1271594444/173291/2f40bb4f/59b743bcN8509428e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8347/264/1286771527/92188/5cf5ec04/59b7420fN65378e9e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7363/165/3000956253/190883/179a372/59b743bfNd0c79d93.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7399/112/2935531768/183594/b77c7d4a/59b7441aNc3d40133.jpg!q70.jpg","num":1,"pid":100,"price":2200,"pscid":112,"selected":0,"sellerid":11,"subhead":"针织针织闪闪闪亮你的眼","title":"维迩旎 2017秋冬新款长袖针织连衣裙韩版气质中长款名媛包臀A字裙 zx179709 黑色 XL"}],"sellerName":"商家11","sellerid":"11"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":1,"pid":69,"price":16999,"pscid":40,"selected":0,"sellerid":13,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家13","sellerid":"13"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":2,"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":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":3,"pid":2,"price":299,"pscid":1,"selected":0,"sellerid":18,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家18","sellerid":"18"}]
*/
private String msg;
private String code;
private List<DataBean> data;
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 {
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
/
* list : [{"bargainPrice":22.9,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends","images":"https://m.360buyimg.com/n0/jfs/t1930/284/2865629620/390243/e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336/2802996626/155915/e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31/2772215910/389956/c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166/2703833710/312660/531aa913/57709035N33857877.jpg!q70.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 boolean checked;
private String sellerName;
private String sellerid;
private List<ListBean> list;
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 {
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
/
* bargainPrice : 22.9
* createtime : 2017-10-14T21:48:08
* detailUrl : https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=friends
* images : https://m.360buyimg.com/n0/jfs/t1930/284///e3ade9c4/56f0a08fNbd3a1235.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2137/336///e5e90d7a/56f0a09cN33e01bd0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t1882/31///c8dbf370/56f0a0a2Na0c86ea6.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2620/166///531aa913/N.jpg!q70.jpg
* num : 2
* pid : 24
* price : 288
* pscid : 2
* selected : 0
* sellerid : 1
* subhead : 三只松鼠零食特惠,专区满99减50,满199减100,火速抢购》
* title : 三只松鼠 坚果炒货 零食奶油味 碧根果225g/袋
*/
private boolean checked;
private double bargainPrice;
private String createtime;
private String detailUrl;
private String images;
private int num;
private int pid;
private float price;
private int pscid;
private int selected;
private int sellerid;
private String subhead;
private String title;
public double getBargainPrice() {
return bargainPrice;
}
public void setBargainPrice(double 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 int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public int getPscid() {
return pscid;
}
public void setPscid(int pscid) {
this.pscid = pscid;
}
public int getSelected() {
return selected;
}
public void setSelected(int selected) {
this.selected = selected;
}
public int getSellerid() {
return sellerid;
}
public void setSellerid(int 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;
}
}
}
}
M层
import java.io.IOException;import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
/
* Created by HASEE on 2017/11/21.
*/
public class Logger implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
HttpUrl url=original.url().newBuilder()
.addQueryParameter("source","android")
.build();
//添加请求头
Request request = original.newBuilder()
.url(url)
.build();
return chain.proceed(request);
}
}
import android.content.Context;
import android.widget.ImageView;
import com.youth.banner.loader.ImageLoader;
/
* Created by HASEE on 2017/11/23.
*/
public class MyImageLoader extends ImageLoader {
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(path.toString(), imageView);
}
}
import android.widget.ImageView;
import com.youth.banner.loader.ImageLoader;
/
* Created by HASEE on 2017/11/23.
*/
public class MyImageLoader extends ImageLoader {
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(path.toString(), imageView);
}
}
P层
Elvpresenter
import android.content.Context;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import model.ElvDataBean;
import view.CallBack;
import view.Iview;
/
* Created by HASEE on 2017/11/22.
*/
public class Elvpresenter {
private Iview ivew;
public Elvpresenter(Iview ivew) {
this.ivew = ivew;
}
public void get(){
Map map = new HashMap<String,String>();
map.put("uid","100");
HttpUtils.getInstance().get("http://120.27.23.105/product/getCarts", map, new CallBack() {
@Override
public void onSuccess(Object o) {
ElvDataBean elvDataBean = (ElvDataBean) o;
ivew.Success(elvDataBean);
}
@Override
public void onFailed(Exception e) {
ivew.Failed(e);
}
},ElvDataBean.class);
}
public void onDetchView(){
if (ivew!=null){
ivew=null;
}
}
}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import model.ElvDataBean;
import view.CallBack;
import view.Iview;
/
* Created by HASEE on 2017/11/22.
*/
public class Elvpresenter {
private Iview ivew;
public Elvpresenter(Iview ivew) {
this.ivew = ivew;
}
public void get(){
Map map = new HashMap<String,String>();
map.put("uid","100");
HttpUtils.getInstance().get("http://120.27.23.105/product/getCarts", map, new CallBack() {
@Override
public void onSuccess(Object o) {
ElvDataBean elvDataBean = (ElvDataBean) o;
ivew.Success(elvDataBean);
}
@Override
public void onFailed(Exception e) {
ivew.Failed(e);
}
},ElvDataBean.class);
}
public void onDetchView(){
if (ivew!=null){
ivew=null;
}
}
}
HttpUtils
import android.os.Handler;
import android.util.Log;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.Map;
import model.Logger;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import view.CallBack;
/
* Created by HASEE on 2017/11/21.
*/
public class HttpUtils {
private static volatile HttpUtils instance;
private static Handler handler = new Handler();
private HttpUtils(){
}
public static HttpUtils getInstance() {
if (instance == null) {
synchronized (HttpUtils.class) {
if (instance == null) {
instance = new HttpUtils();
}
}
}
return instance;
}
public void get(String url, Map<String,String> map, final CallBack callBack, final Class c) {
//对url和参数做拼接处理
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(url);
//判断是否存在? if中是存在
if (stringBuffer.indexOf("?") != -1) {
//判断?是否在最后一位 if中是不在最后一位
if (stringBuffer.indexOf("?") != stringBuffer.length() - 1) {
stringBuffer.append("&");
}
} else {
stringBuffer.append("?");
}
for (Map.Entry<String, String> entry : map.entrySet()) {
stringBuffer.append(entry.getKey())
.append("=")
.append(entry.getValue())
.append("&");
}
//判断是否存在& if中是存在
if (stringBuffer.indexOf("&") != -1) {
stringBuffer.deleteCharAt(stringBuffer.lastIndexOf("&"));
}
Log.i("TAG",stringBuffer.toString());
OkHttpClient okHttpClient = new OkHttpClient
.Builder()
.addInterceptor(new Logger())
.build();
Request request = new Request.Builder().get().url(stringBuffer.toString()).build();
Call call = okHttpClient.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, final IOException e) {
handler.post(new Runnable() {
@Override
public void run() {
callBack.onFailed(e);
}
});
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String result = response.body().string();
Log.i("aaa",result);
//拿到数据开始解析
final Object o = new Gson().fromJson(result, c);
//当前是在子线程,回到主线程中
handler.post(new Runnable() {
@Override
public void run() {
//回调
callBack.onSuccess(o);
}
});
}
});
}
}
import android.util.Log;
import com.google.gson.Gson;
import java.io.IOException;
import java.util.Map;
import model.Logger;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import view.CallBack;
/
* Created by HASEE on 2017/11/21.
*/
public class HttpUtils {
private static volatile HttpUtils instance;
private static Handler handler = new Handler();
private HttpUtils(){
}
public static HttpUtils getInstance() {
if (instance == null) {
synchronized (HttpUtils.class) {
if (instance == null) {
instance = new HttpUtils();
}
}
}
return instance;
}
public void get(String url, Map<String,String> map, final CallBack callBack, final Class c) {
//对url和参数做拼接处理
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(url);
//判断是否存在? if中是存在
if (stringBuffer.indexOf("?") != -1) {
//判断?是否在最后一位 if中是不在最后一位
if (stringBuffer.indexOf("?") != stringBuffer.length() - 1) {
stringBuffer.append("&");
}
} else {
stringBuffer.append("?");
}
for (Map.Entry<String, String> entry : map.entrySet()) {
stringBuffer.append(entry.getKey())
.append("=")
.append(entry.getValue())
.append("&");
}
//判断是否存在& if中是存在
if (stringBuffer.indexOf("&") != -1) {
stringBuffer.deleteCharAt(stringBuffer.lastIndexOf("&"));
}
Log.i("TAG",stringBuffer.toString());
OkHttpClient okHttpClient = new OkHttpClient
.Builder()
.addInterceptor(new Logger())
.build();
Request request = new Request.Builder().get().url(stringBuffer.toString()).build();
Call call = okHttpClient.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, final IOException e) {
handler.post(new Runnable() {
@Override
public void run() {
callBack.onFailed(e);
}
});
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String result = response.body().string();
Log.i("aaa",result);
//拿到数据开始解析
final Object o = new Gson().fromJson(result, c);
//当前是在子线程,回到主线程中
handler.post(new Runnable() {
@Override
public void run() {
//回调
callBack.onSuccess(o);
}
});
}
});
}
}
MessageEvent
public class MessageEvent {
private boolean checkd;
public boolean isCheckd(){
return checkd;
}
public void setCheckd(boolean checkd){
this.checkd=checkd;
}
}
private boolean checkd;
public boolean isCheckd(){
return checkd;
}
public void setCheckd(boolean checkd){
this.checkd=checkd;
}
}
MyAdapter
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bawei.test.okmvpreanview.R;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
import model.Bean;
/
* Created by HASEE on 2017/11/21.
*/
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
private Context context;
private List<Bean.NewslistBean> list=new ArrayList<>();
private OnItemClickListener mOnItemClickListener;
private OnItemLongClickListener mOnItemLongClickListener;
public void setmOnItemClickListener(OnItemClickListener mOnItemClickListener) {
this.mOnItemClickListener = mOnItemClickListener;
}
public void setmOnItemLongClickListener(OnItemLongClickListener mOnItemLongClickListener) {
this.mOnItemLongClickListener = mOnItemLongClickListener;
}
public interface OnItemClickListener{
void onItemClick(View view,int position);
}
public interface OnItemLongClickListener{
void onItemLongClick(View view,int position);
}
public MyAdapter(Context context, List<Bean.NewslistBean> list) {
this.context = context;
this.list = list;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v=View.inflate(context, R.layout.item,null);
MyViewHolder holder =new MyViewHolder(v);
return holder;
}
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
Bean.NewslistBean songListBean = list.get(position);
Glide.with(context).load(songListBean.getPicUrl()).into(holder.img);
holder.tv.setText(songListBean.getTitle());
holder.tv2.setText(songListBean.getDescription());
if (mOnItemClickListener!=null){
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position= holder.getLayoutPosition();
mOnItemClickListener.onItemClick(holder.itemView,position);
}
});
}
if (mOnItemLongClickListener!=null){
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
int position= holder.getLayoutPosition();
mOnItemLongClickListener.onItemLongClick(holder.itemView,position);
return true;
}
});
}
}
@Override
public int getItemCount() {
return list.size();
}
class MyViewHolder extends RecyclerView.ViewHolder{
private ImageView img;
private TextView tv;
private TextView tv2;
public MyViewHolder(View itemView) {
super(itemView);
img=(ImageView) itemView.findViewById(R.id.img);
tv=(TextView)itemView.findViewById(R.id.tv);
tv2=(TextView)itemView.findViewById(R.id.tv2);
}
}
}
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bawei.test.okmvpreanview.R;
import com.bumptech.glide.Glide;
import java.util.ArrayList;
import java.util.List;
import model.Bean;
/
* Created by HASEE on 2017/11/21.
*/
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
private Context context;
private List<Bean.NewslistBean> list=new ArrayList<>();
private OnItemClickListener mOnItemClickListener;
private OnItemLongClickListener mOnItemLongClickListener;
public void setmOnItemClickListener(OnItemClickListener mOnItemClickListener) {
this.mOnItemClickListener = mOnItemClickListener;
}
public void setmOnItemLongClickListener(OnItemLongClickListener mOnItemLongClickListener) {
this.mOnItemLongClickListener = mOnItemLongClickListener;
}
public interface OnItemClickListener{
void onItemClick(View view,int position);
}
public interface OnItemLongClickListener{
void onItemLongClick(View view,int position);
}
public MyAdapter(Context context, List<Bean.NewslistBean> list) {
this.context = context;
this.list = list;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v=View.inflate(context, R.layout.item,null);
MyViewHolder holder =new MyViewHolder(v);
return holder;
}
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
Bean.NewslistBean songListBean = list.get(position);
Glide.with(context).load(songListBean.getPicUrl()).into(holder.img);
holder.tv.setText(songListBean.getTitle());
holder.tv2.setText(songListBean.getDescription());
if (mOnItemClickListener!=null){
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position= holder.getLayoutPosition();
mOnItemClickListener.onItemClick(holder.itemView,position);
}
});
}
if (mOnItemLongClickListener!=null){
holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
int position= holder.getLayoutPosition();
mOnItemLongClickListener.onItemLongClick(holder.itemView,position);
return true;
}
});
}
}
@Override
public int getItemCount() {
return list.size();
}
class MyViewHolder extends RecyclerView.ViewHolder{
private ImageView img;
private TextView tv;
private TextView tv2;
public MyViewHolder(View itemView) {
super(itemView);
img=(ImageView) itemView.findViewById(R.id.img);
tv=(TextView)itemView.findViewById(R.id.tv);
tv2=(TextView)itemView.findViewById(R.id.tv2);
}
}
}
MyElvadapter
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import com.bawei.test.okmvpreanview.R;
import com.bumptech.glide.Glide;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import model.ElvDataBean;
import static android.support.v7.widget.StaggeredGridLayoutManager.TAG;
/
* Created by HASEE on 2017/11/22.
*/
public class MyElvadapter extends BaseExpandableListAdapter {
private static final String TAG = "ExlvAdapter";
private Context context;
private List<ElvDataBean.DataBean> groupList;
private List<List<ElvDataBean.DataBean.ListBean>> childList;
private boolean allGroupCbSelect;
public MyElvadapter(Context context, List<ElvDataBean.DataBean> groupList, List<List<ElvDataBean.DataBean.ListBean>> childList) {
this.context = context;
this.groupList = groupList;
this.childList = childList;
}
@Override
public int getGroupCount() {
return groupList.size();
}
@Override
public int getChildrenCount(int i) {
return childList.get(i).size();
}
@Override
public Object getGroup(int i) {
return groupList.get(i);
}
@Override
public Object getChild(int i, int i1) {
return childList.get(i).get(i1);
}
@Override
public long getGroupId(int i) {
return i;
}
@Override
public long getChildId(int i, int i1) {
return i1;
}
@Override
public boolean hasStableIds() {
return false;
}
//一级列表布局
@Override
public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
final ElvDataBean.DataBean dataBean = groupList.get(i);
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = View.inflate(context, R.layout.group, null);
holder.textView = (TextView) view.findViewById(R.id.g_title);
holder.che = (CheckBox) view.findViewById(R.id.che);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.textView.setText(dataBean.getSellerName());
//设置一级列表checkBox的状态
holder.che.setChecked(dataBean.isChecked());
//一级列表checkBox的点击事件
holder.che.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//判断一级列表复选框的状态 设置为true或false
dataBean.setChecked(holder.che.isChecked());
//改变二级checkbod的状态
changeChildCbState(i, holder.che.isChecked());
//算钱
EventBus.getDefault().post(computer());
//改变全选状态 isAllGroupCbSelect判断一级是否全部选中
changeAllCbState(isAllGroupCbSelect());
//必刷新
notifyDataSetChanged();
}
});
return view;
}
//二级列表布局
@Override
public View getChildView(final int i, final int i1, boolean b, View view, ViewGroup viewGroup) {
final ElvDataBean.DataBean.ListBean listBean = childList.get(i).get(i1);
final ViewHolder2 holder2;
if (view == null) {
holder2 = new ViewHolder2();
view = View.inflate(context, R.layout.chidren, null);
holder2.z_title = (TextView) view.findViewById(R.id.z_title);
holder2.z_che = (CheckBox) view.findViewById(R.id.z_che);
holder2.img = (ImageView) view.findViewById(R.id.z_img);
holder2.price = view.findViewById(R.id.z_price);
holder2.xiangqing = view.findViewById(R.id.z_shuxing);
holder2.jian = view.findViewById(R.id.iv_jian);
holder2.jia = view.findViewById(R.id.iv_add);
holder2.del = view.findViewById(R.id.del);
holder2.num = view.findViewById(R.id.tv_num);
view.setTag(holder2);
} else {
holder2 = (ViewHolder2) view.getTag();
}
holder2.num.setText(listBean.getNum() + "");
holder2.z_title.setText(listBean.getTitle());
holder2.price.setText("¥" + listBean.getPrice());
holder2.xiangqing.setText(listBean.getSubhead());
//设置二级列表checkbox的属性
holder2.z_che.setChecked(listBean.isChecked());
String images = listBean.getImages();
String[] split = images.split("\\|");
Glide.with(context).load(split[0]).into(holder2.img);
//二级列表的点击事件
holder2.z_che.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//设置该条目中的checkbox属性值
listBean.setChecked(holder2.z_che.isChecked());
//计算价钱
PriceAndCountEvent priceAndCountEvent = computer();
EventBus.getDefault().post(priceAndCountEvent);
//判断当前checkbox是选中的状态
if (holder2.z_che.isChecked()) {
//如果全部选中(isAllChildCbSelected)
if (isAllChildCbSelected(i)) {
//改变一级列表的状态
changeGroupCbState(i, true);
//改变全选的状态
changeAllCbState(isAllGroupCbSelect());
}
} else {
//如果没有全部选中,一级列表的checkbox为false不为选中
changeGroupCbState(i, false);
changeAllCbState(isAllGroupCbSelect());
}
notifyDataSetChanged();
}
});
//加号
holder2.jia.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num = listBean.getNum();
//num为int类型所以要加空字符串
holder2.num.setText(++num + "");
listBean.setNum(num);
//如果二级列表的checkbox为选中,计算价钱
if (holder2.z_che.isChecked()) {
PriceAndCountEvent priceAndCountEvent = computer();
EventBus.getDefault().post(priceAndCountEvent);
}
}
});
//减号
holder2.jian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num = listBean.getNum();
if (num == 1) {
return;
}
holder2.num.setText(--num + "");
listBean.setNum(num);
if (holder2.z_che.isChecked()) {
PriceAndCountEvent priceAndCountEvent = computer();
EventBus.getDefault().post(priceAndCountEvent);
}
}
});
//删除
holder2.del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
ElvDataBean.DataBean.ListBean remove = listBeen.remove(i1);
if (listBeen.size() == 0) {
//先移除二级列表的集合,再移除一级列表的集合
childList.remove(i);
groupList.remove(i);
}
//算钱
EventBus.getDefault().post(computer());
notifyDataSetChanged();
}
});
return view;
}
@Override
public boolean isChildSelectable(int i, int i1) {
return true;
}
class ViewHolder {
TextView textView;
CheckBox che;
}
class ViewHolder2 {
ImageView img;
TextView z_title;
CheckBox z_che;
TextView price;
TextView xiangqing;
ImageView jia;
ImageView jian;
ImageView del;
TextView num;
}
//改变二级列表的checkbox的状态 如果一级选中,控制二级也选中
private void changeChildCbState(int i, boolean flag) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
for (int j = 0; j < listBeen.size(); j++) {
ElvDataBean.DataBean.ListBean listBean = listBeen.get(j);
listBean.setChecked(flag);
}
Log.i(TAG, "changeChildCbState: ");
}
//判断一级列表是否全部选中
public boolean isAllGroupCbSelect() {
for (int i = 0; i < groupList.size(); i++) {
ElvDataBean.DataBean dataBean = groupList.get(i);
if (!dataBean.isChecked()) {
return false;
}
}
return true;
}
//改变全选的状态
private void changeAllCbState(boolean flag) {
MessageEvent messageEvent = new MessageEvent();
messageEvent.setCheckd(flag);
EventBus.getDefault().post(messageEvent);
}
//改变一级列表的checkbox的状态
private void changeGroupCbState(int i, boolean flag) {
ElvDataBean.DataBean dataBean = groupList.get(i);
dataBean.setChecked(flag);
}
//判断二级列表是否全部选中
private boolean isAllChildCbSelected(int i) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
for (int j = 0; j < listBeen.size(); j++) {
ElvDataBean.DataBean.ListBean listBean = listBeen.get(j);
if (!listBean.isChecked()) {
return false;
}
}
return true;
}
//设置全选,反选
public void changeAllListCbState(boolean flag) {
for (int i = 0; i < groupList.size(); i++) {
changeGroupCbState(i, flag);
changeChildCbState(i, flag);
}
//算钱
EventBus.getDefault().post(computer());
//
notifyDataSetChanged();
}
//计算列表的价钱
private PriceAndCountEvent computer() {
int count = 0;
int price = 0;
for (int i = 0; i < childList.size(); i++) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
for (int j = 0; j < listBeen.size(); j++) {
ElvDataBean.DataBean.ListBean listBean = listBeen.get(j);
if (listBean.isChecked()) {
price += listBean.getNum() * listBean.getPrice();
count += listBean.getNum();
}
}
}
PriceAndCountEvent priceAndCountEvent = new PriceAndCountEvent();
priceAndCountEvent.setCount(count);
priceAndCountEvent.setPrice(price);
return priceAndCountEvent;
}
}
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;
import com.bawei.test.okmvpreanview.R;
import com.bumptech.glide.Glide;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import model.ElvDataBean;
import static android.support.v7.widget.StaggeredGridLayoutManager.TAG;
/
* Created by HASEE on 2017/11/22.
*/
public class MyElvadapter extends BaseExpandableListAdapter {
private static final String TAG = "ExlvAdapter";
private Context context;
private List<ElvDataBean.DataBean> groupList;
private List<List<ElvDataBean.DataBean.ListBean>> childList;
private boolean allGroupCbSelect;
public MyElvadapter(Context context, List<ElvDataBean.DataBean> groupList, List<List<ElvDataBean.DataBean.ListBean>> childList) {
this.context = context;
this.groupList = groupList;
this.childList = childList;
}
@Override
public int getGroupCount() {
return groupList.size();
}
@Override
public int getChildrenCount(int i) {
return childList.get(i).size();
}
@Override
public Object getGroup(int i) {
return groupList.get(i);
}
@Override
public Object getChild(int i, int i1) {
return childList.get(i).get(i1);
}
@Override
public long getGroupId(int i) {
return i;
}
@Override
public long getChildId(int i, int i1) {
return i1;
}
@Override
public boolean hasStableIds() {
return false;
}
//一级列表布局
@Override
public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
final ElvDataBean.DataBean dataBean = groupList.get(i);
final ViewHolder holder;
if (view == null) {
holder = new ViewHolder();
view = View.inflate(context, R.layout.group, null);
holder.textView = (TextView) view.findViewById(R.id.g_title);
holder.che = (CheckBox) view.findViewById(R.id.che);
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
holder.textView.setText(dataBean.getSellerName());
//设置一级列表checkBox的状态
holder.che.setChecked(dataBean.isChecked());
//一级列表checkBox的点击事件
holder.che.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//判断一级列表复选框的状态 设置为true或false
dataBean.setChecked(holder.che.isChecked());
//改变二级checkbod的状态
changeChildCbState(i, holder.che.isChecked());
//算钱
EventBus.getDefault().post(computer());
//改变全选状态 isAllGroupCbSelect判断一级是否全部选中
changeAllCbState(isAllGroupCbSelect());
//必刷新
notifyDataSetChanged();
}
});
return view;
}
//二级列表布局
@Override
public View getChildView(final int i, final int i1, boolean b, View view, ViewGroup viewGroup) {
final ElvDataBean.DataBean.ListBean listBean = childList.get(i).get(i1);
final ViewHolder2 holder2;
if (view == null) {
holder2 = new ViewHolder2();
view = View.inflate(context, R.layout.chidren, null);
holder2.z_title = (TextView) view.findViewById(R.id.z_title);
holder2.z_che = (CheckBox) view.findViewById(R.id.z_che);
holder2.img = (ImageView) view.findViewById(R.id.z_img);
holder2.price = view.findViewById(R.id.z_price);
holder2.xiangqing = view.findViewById(R.id.z_shuxing);
holder2.jian = view.findViewById(R.id.iv_jian);
holder2.jia = view.findViewById(R.id.iv_add);
holder2.del = view.findViewById(R.id.del);
holder2.num = view.findViewById(R.id.tv_num);
view.setTag(holder2);
} else {
holder2 = (ViewHolder2) view.getTag();
}
holder2.num.setText(listBean.getNum() + "");
holder2.z_title.setText(listBean.getTitle());
holder2.price.setText("¥" + listBean.getPrice());
holder2.xiangqing.setText(listBean.getSubhead());
//设置二级列表checkbox的属性
holder2.z_che.setChecked(listBean.isChecked());
String images = listBean.getImages();
String[] split = images.split("\\|");
Glide.with(context).load(split[0]).into(holder2.img);
//二级列表的点击事件
holder2.z_che.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//设置该条目中的checkbox属性值
listBean.setChecked(holder2.z_che.isChecked());
//计算价钱
PriceAndCountEvent priceAndCountEvent = computer();
EventBus.getDefault().post(priceAndCountEvent);
//判断当前checkbox是选中的状态
if (holder2.z_che.isChecked()) {
//如果全部选中(isAllChildCbSelected)
if (isAllChildCbSelected(i)) {
//改变一级列表的状态
changeGroupCbState(i, true);
//改变全选的状态
changeAllCbState(isAllGroupCbSelect());
}
} else {
//如果没有全部选中,一级列表的checkbox为false不为选中
changeGroupCbState(i, false);
changeAllCbState(isAllGroupCbSelect());
}
notifyDataSetChanged();
}
});
//加号
holder2.jia.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num = listBean.getNum();
//num为int类型所以要加空字符串
holder2.num.setText(++num + "");
listBean.setNum(num);
//如果二级列表的checkbox为选中,计算价钱
if (holder2.z_che.isChecked()) {
PriceAndCountEvent priceAndCountEvent = computer();
EventBus.getDefault().post(priceAndCountEvent);
}
}
});
//减号
holder2.jian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int num = listBean.getNum();
if (num == 1) {
return;
}
holder2.num.setText(--num + "");
listBean.setNum(num);
if (holder2.z_che.isChecked()) {
PriceAndCountEvent priceAndCountEvent = computer();
EventBus.getDefault().post(priceAndCountEvent);
}
}
});
//删除
holder2.del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
ElvDataBean.DataBean.ListBean remove = listBeen.remove(i1);
if (listBeen.size() == 0) {
//先移除二级列表的集合,再移除一级列表的集合
childList.remove(i);
groupList.remove(i);
}
//算钱
EventBus.getDefault().post(computer());
notifyDataSetChanged();
}
});
return view;
}
@Override
public boolean isChildSelectable(int i, int i1) {
return true;
}
class ViewHolder {
TextView textView;
CheckBox che;
}
class ViewHolder2 {
ImageView img;
TextView z_title;
CheckBox z_che;
TextView price;
TextView xiangqing;
ImageView jia;
ImageView jian;
ImageView del;
TextView num;
}
//改变二级列表的checkbox的状态 如果一级选中,控制二级也选中
private void changeChildCbState(int i, boolean flag) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
for (int j = 0; j < listBeen.size(); j++) {
ElvDataBean.DataBean.ListBean listBean = listBeen.get(j);
listBean.setChecked(flag);
}
Log.i(TAG, "changeChildCbState: ");
}
//判断一级列表是否全部选中
public boolean isAllGroupCbSelect() {
for (int i = 0; i < groupList.size(); i++) {
ElvDataBean.DataBean dataBean = groupList.get(i);
if (!dataBean.isChecked()) {
return false;
}
}
return true;
}
//改变全选的状态
private void changeAllCbState(boolean flag) {
MessageEvent messageEvent = new MessageEvent();
messageEvent.setCheckd(flag);
EventBus.getDefault().post(messageEvent);
}
//改变一级列表的checkbox的状态
private void changeGroupCbState(int i, boolean flag) {
ElvDataBean.DataBean dataBean = groupList.get(i);
dataBean.setChecked(flag);
}
//判断二级列表是否全部选中
private boolean isAllChildCbSelected(int i) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
for (int j = 0; j < listBeen.size(); j++) {
ElvDataBean.DataBean.ListBean listBean = listBeen.get(j);
if (!listBean.isChecked()) {
return false;
}
}
return true;
}
//设置全选,反选
public void changeAllListCbState(boolean flag) {
for (int i = 0; i < groupList.size(); i++) {
changeGroupCbState(i, flag);
changeChildCbState(i, flag);
}
//算钱
EventBus.getDefault().post(computer());
//
notifyDataSetChanged();
}
//计算列表的价钱
private PriceAndCountEvent computer() {
int count = 0;
int price = 0;
for (int i = 0; i < childList.size(); i++) {
List<ElvDataBean.DataBean.ListBean> listBeen = childList.get(i);
for (int j = 0; j < listBeen.size(); j++) {
ElvDataBean.DataBean.ListBean listBean = listBeen.get(j);
if (listBean.isChecked()) {
price += listBean.getNum() * listBean.getPrice();
count += listBean.getNum();
}
}
}
PriceAndCountEvent priceAndCountEvent = new PriceAndCountEvent();
priceAndCountEvent.setCount(count);
priceAndCountEvent.setPrice(price);
return priceAndCountEvent;
}
}
Presenter
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import model.Bean;
import view.CallBack;
import view.Iv;
/
* Created by HASEE on 2017/11/21.
*/
public class Presenter {
private Iv iv;
public Presenter(Iv iv) {
this.iv = iv;
}
public void get(int i){
Map map = new HashMap<String,String>();
map.put("key","2a0024d1f7f558e09936ff1643");
map.put("num","10");
HttpUtils.getInstance().get("http://api.tianapi.com/meinv/", map, new CallBack() {
@Override
public void onSuccess(Object o) {
Bean bean= (Bean) o;
List<Bean.NewslistBean> list=bean.getNewslist();
iv.onSuccess(list);
}
@Override
public void onFailed(Exception e) {
iv.onFailed(e);
}
},Bean.class);
}
public void DetchView(){
if (iv!=null){
iv=null;
}
}
}
public class public class PriceAndCountEvent {
private int price;
private int count;
public int getPrice() {
return price;
}
public int getCount() {
return count;
}
public void setPrice(int price) {
this.price = price;
}
public void setCount(int count) {
this.count = count;
}
} {
private int price;
private int count;
public int getPrice() {
return price;
}
public int getCount() {
return count;
}
public void setPrice(int price) {
this.price = price;
}
public void setCount(int count) {
this.count = count;
}
}
import java.util.List;
import java.util.Map;
import model.Bean;
import view.CallBack;
import view.Iv;
/
* Created by HASEE on 2017/11/21.
*/
public class Presenter {
private Iv iv;
public Presenter(Iv iv) {
this.iv = iv;
}
public void get(int i){
Map map = new HashMap<String,String>();
map.put("key","2a0024d1f7f558e09936ff1643");
map.put("num","10");
HttpUtils.getInstance().get("http://api.tianapi.com/meinv/", map, new CallBack() {
@Override
public void onSuccess(Object o) {
Bean bean= (Bean) o;
List<Bean.NewslistBean> list=bean.getNewslist();
iv.onSuccess(list);
}
@Override
public void onFailed(Exception e) {
iv.onFailed(e);
}
},Bean.class);
}
public void DetchView(){
if (iv!=null){
iv=null;
}
}
}
PriceAndCountEvent
public class public class PriceAndCountEvent {
private int price;
private int count;
public int getPrice() {
return price;
}
public int getCount() {
return count;
}
public void setPrice(int price) {
this.price = price;
}
public void setCount(int count) {
this.count = count;
}
} {
private int price;
private int count;
public int getPrice() {
return price;
}
public int getCount() {
return count;
}
public void setPrice(int price) {
this.price = price;
}
public void setCount(int count) {
this.count = count;
}
}
View接口
public interface CallBack {
void onSuccess(Object o);
void onFailed(Exception e);
void onSuccess(Object o);
void onFailed(Exception e);
}
public interface Iv {
void onSuccess(List<Bean.NewslistBean> list);
void onFailed(Exception e);
}
void onSuccess(List<Bean.NewslistBean> list);
void onFailed(Exception e);
}
public interface Iview {
void Success(ElvDataBean elvDataBean);
void Failed(Exception e);
}
void Success(ElvDataBean elvDataBean);
void Failed(Exception e);
}
版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/androidbc/10450.html