商品列表(MVp)

来源:互联网 发布:雪梨开的淘宝店店名 编辑:程序博客网 时间:2024/05/16 06:10


//清单文件

<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
name=".App"

//依赖

compile 'com.android.support:recyclerview-v7:26.1.0'compile 'com.squareup.okhttp3:okhttp:3.9.1'compile 'org.xutils:xutils:3.1.24'implementation files('libs/universal-image-loader-1.9.3-with-sources.jar')implementation 'com.google.code.gson:gson:2.2.4'
//activity_main

<?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"    android:orientation="vertical"    tools:context="com.example.shuju.MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:layout_marginTop="10dp"        android:text="商品列表" />    <android.support.v4.widget.SwipeRefreshLayout        android:id="@+id/sprefresh"        android:layout_width="match_parent"        android:layout_height="match_parent">        <android.support.v7.widget.RecyclerView            android:id="@+id/rv"            android:layout_width="match_parent"            android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>    </android.support.v4.widget.SwipeRefreshLayout></LinearLayout>
//item

<?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="match_parent">    <ImageView        android:id="@+id/book_img"        android:layout_width="100dp"        android:layout_height="100dp"        android:layout_marginLeft="10dp"        android:layout_marginTop="20dp"        android:src="@mipmap/ic_launcher" />    <TextView        android:id="@+id/book_text"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="120dp"        android:layout_marginTop="20dp"        android:text="123" />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="120dp"        android:layout_marginTop="60dp"        android:text="原价:" />    <TextView        android:id="@+id/text_oldprice"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="150dp"        android:layout_marginTop="60dp"        android:text="456" />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="120dp"        android:layout_marginTop="100dp"        android:text="优惠价:"        android:textColor="#F23707" />    <TextView        android:id="@+id/text_newprice"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="170dp"        android:layout_marginTop="100dp"        android:text="234555"        android:textColor="#F23707" /></RelativeLayout>
//item2

<?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">    <ImageView        android:id="@+id/book_img"        android:layout_width="200dp"        android:layout_height="200dp"        android:layout_gravity="center" />    <TextView        android:id="@+id/book_text"        android:layout_width="match_parent"        android:layout_height="wrap_content" />    <LinearLayout        android:layout_width="match_parent"        android:layout_height="20dp">        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="原价:" />        <TextView            android:id="@+id/text_oldprice"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginLeft="10dp"            android:text="456" />    </LinearLayout>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="20dp">        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="优惠价:"            android:textColor="#F23707" />        <TextView            android:id="@+id/text_newprice"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginLeft="10dp"            android:text="234555"            android:textColor="#F23707" />    </LinearLayout></LinearLayout>
//App

package com.example.shuju;import android.app.Application;import org.xutils.x;public class App extends Application {    public void onCreate() {        super.onCreate();        x.Ext.init(this);        x.Ext.setDebug(BuildConfig.DEBUG);        ImageloaderUtil.initConfig(this);    }}
//ImageloaderUtil
package com.example.shuju;import android.content.Context;import android.graphics.Bitmap;import android.os.Environment;import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;import com.nostra13.universalimageloader.core.DisplayImageOptions;import com.nostra13.universalimageloader.core.ImageLoader;import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;import java.io.File;public class ImageloaderUtil {    /**     * ImageLoader的配置     *     * @param context     */    public static void initConfig(Context context) {        //配置//        File cacheFile=context.getExternalCacheDir();        File cacheFile = new File(Environment.getExternalStorageDirectory() + "/" + "imgages");        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)                .memoryCacheExtraOptions(480, 800)//缓存图片最大的长和宽                .threadPoolSize(2)//线程池的数量                .threadPriority(4)                .memoryCacheSize(2 * 1024 * 1024)//设置内存缓存区大小                .diskCacheSize(20 * 1024 * 1024)//设置sd卡缓存区大小                .diskCache(new UnlimitedDiscCache(cacheFile))//自定义缓存目录                .writeDebugLogs()//打印日志内容                .diskCacheFileNameGenerator(new Md5FileNameGenerator())//给缓存的文件名进行md5加密处理                .build();        ImageLoader.getInstance().init(config);    }    /**     * 获取图片设置类     *     * @return     */    public static DisplayImageOptions getImageOptions() {        DisplayImageOptions optionsoptions = new DisplayImageOptions.Builder()                .cacheInMemory(true)//使用内存缓存                .cacheOnDisk(true)//使用磁盘缓存                .bitmapConfig(Bitmap.Config.RGB_565)//设置图片格式                .build();        return optionsoptions;    }}

//MainActivity

package com.example.shuju;import android.content.Context;import android.os.Bundle;import android.os.Handler;import android.support.v4.widget.SwipeRefreshLayout;import android.support.v7.app.AppCompatActivity;import android.support.v7.widget.GridLayoutManager;import android.support.v7.widget.LinearLayoutManager;import android.support.v7.widget.RecyclerView;import android.widget.Toast;import com.example.shuju.adapter.MyAdapter;import com.example.shuju.bean.Bijiben;import com.example.shuju.presenter.BookPre;import com.example.shuju.view.BView;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Random;public class MainActivity extends AppCompatActivity implements BView {    private RecyclerView rv;    private int q = 1;    private boolean flag = true;    private MyAdapter adapter;    private Context mContext;    private SwipeRefreshLayout sprefresh;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        rv = findViewById(R.id.rv);        BookPre bookPre = new BookPre(this);        bookPre.getBijiuben();        sprefresh = findViewById(R.id.sprefresh);        // 下拉时触发SwipeRefreshLayout的下拉动画,动画完毕之后就会回调这个方法        sprefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {            @Override            public void onRefresh() {                // 开始刷新,设置当前为刷新状态                //swipeRefreshLayout.setRefreshing(true);                // 这里是主线程                // 一些比较耗时的操作,比如联网获取数据,需要放到子线程去执行                //获取数据                final Random random = new Random();                new Handler().postDelayed(new Runnable() {                    @Override                    public void run() {                        // mList.add(0, "我是天才" + random.nextInt(100) + "");                        //mAdapter.notifyDataSetChanged();                        Toast.makeText(MainActivity.this, "刷新了数据", Toast.LENGTH_SHORT).show();                        Map<String, String> map = new HashMap<>();                        // 加载完数据设置为不刷新状态,将下拉进度收起来                        sprefresh.setRefreshing(false);                    }                }, 1200);                // System.out.println(Thread.currentThread().getName());                // 这个不能写在外边,不然会直接收起来                //swipeRefreshLayout.setRefreshing(false);            }        });    }    @Override    public void onSuccess(final List<Bijiben> list) {        //Log.i("111",list.toString()+"");        //LinearLayout        //LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);        //GridLayoutL        //LinearLayoutManager.VERTICAL LinearLayoutManager.HORIZONTAL横向        GridLayoutManager manager = new GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false);        rv.setLayoutManager(manager);        adapter = new MyAdapter(this, list, 2);        rv.setAdapter(adapter);        flag = false;    }    @Override    public void onFailed() {    }}
//BView

package com.example.shuju.view;import com.example.shuju.bean.Bijiben;import java.util.List;public interface BView {    void onSuccess(List<Bijiben> list);    void onFailed();}
//adapter

//MyAdapter

package com.example.shuju.adapter;import android.content.Context;import android.support.v7.widget.RecyclerView;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.TextView;import com.example.shuju.R;import com.example.shuju.bean.Bijiben;import com.nostra13.universalimageloader.core.ImageLoader;import java.util.List;/** * Created by 哥哥 on 2017/12/14 0014. */public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {    private Context context;    private List<Bijiben> list;    private int q;    public MyAdapter(Context context, List<Bijiben> list, int q) {        this.context = context;        this.list = list;        this.q = q;    }    @Override    public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {        View view = LayoutInflater.from(context).inflate(R.layout.item2, null);        ViewHolder viewHolder = new ViewHolder(view);        return viewHolder;    }    @Override    public void onBindViewHolder(MyAdapter.ViewHolder holder, int position) {        holder.text.setText(list.get(position).getTitle());        holder.newprice.setText(list.get(position).getNewprice() + "");        holder.oldprice.setText(list.get(position).getOldprice() + "");        String img = list.get(position).getImg();        String[] split = img.split("\\|");        ImageLoader.getInstance().displayImage(split[0], holder.img);    }    @Override    public int getItemCount() {        if (list != null) {            return list.size();        } else {            Log.i("12", list.size() + "放松放松");        }        return 0;    }    class ViewHolder extends RecyclerView.ViewHolder {        ImageView img;        TextView text;        TextView oldprice;        TextView newprice;        public ViewHolder(View itemView) {            super(itemView);            img = (ImageView) itemView.findViewById(R.id.book_img);            text = (TextView) itemView.findViewById(R.id.book_text);            oldprice = (TextView) itemView.findViewById(R.id.text_oldprice);            newprice = (TextView) itemView.findViewById(R.id.text_newprice);        }    }}
//model

//BookModel

package com.example.shuju.model;import android.os.Handler;import com.example.shuju.bean.Bijiben;import com.example.shuju.bean.Books;import com.example.shuju.presenter.BookPresenter;import com.google.gson.Gson;import java.io.IOException;import java.util.ArrayList;import java.util.List;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.Response;/** * Created by 哥哥 on 2017/12/14 0014. */public class BookModel {    //定义一个数据集合    private static List<Bijiben> list = new ArrayList<>();    //定义一个handler    private static Handler handler = new Handler();    //请求数据的方法    public void getBijiuben(final BookPresenter bookPresenter) {        new Thread() {            @Override            public void run() {                super.run();                try {                    //OK请求数据                    OkHttpClient okHttpClient = new OkHttpClient();                    Request request = new Request.Builder()                            .get()                            .url("http://120.27.23.105/product/searchProducts?source=android&keywords=笔记本&page=1")                            .build();                    //准备发送网络请求                    okhttp3.Call call = okHttpClient.newCall(request);                    //执行请求                    Response response = call.execute();                    //得到请求的结果                    String result = response.body().string();                    //然后解析数据                    Gson gson = new Gson();                    Books books = gson.fromJson(result.toString(), Books.class);                    List<Books.DataBean> data = books.getData();                    for (int i = 0; i < data.size(); i++) {                        String title = data.get(i).getTitle();                        double newprice = data.get(i).getPrice();                        double bargainPrice = data.get(i).getBargainPrice();                        String images = data.get(i).getImages();                        list.add(new Bijiben(images, title, bargainPrice, newprice));                    }                    handler.post(new Runnable() {                        @Override                        public void run() {                            bookPresenter.onSuccess(list);                        }                    });                } catch (IOException e) {                    e.printStackTrace();                }            }        }.start();    }}
//BookPre

package com.example.shuju.presenter;import com.example.shuju.bean.Bijiben;import com.example.shuju.model.BookModel;import com.example.shuju.view.BView;import java.util.List;public class BookPre implements BookPresenter {    private BView bView;    private BookModel bookModel;    public BookPre(BView bView) {        this.bView = bView;        bookModel = new BookModel();    }    public void getBijiuben() {        bookModel.getBijiuben(this);    }    @Override    public void onSuccess(List<Bijiben> list) {        bView.onSuccess(list);    }    @Override    public void onFailed() {    }}
//BookPresenter

package com.example.shuju.presenter;import com.example.shuju.bean.Bijiben;import java.util.List;public interface BookPresenter {    void onSuccess(List<Bijiben> list);    void onFailed();}
//Bijiben

package com.example.shuju.bean;public class Bijiben {    private String img;    private String title;    private double oldprice;    private double newprice;    public String getImg() {        return img;    }    public void setImg(String img) {        this.img = img;    }    public String getTitle() {        return title;    }    public void setTitle(String title) {        this.title = title;    }    public double getOldprice() {        return oldprice;    }    public void setOldprice(double oldprice) {        this.oldprice = oldprice;    }    public double getNewprice() {        return newprice;    }    public void setNewprice(double newprice) {        this.newprice = newprice;    }    @Override    public String toString() {        return "Bijiben{" +                "img='" + img + '\'' +                ", title='" + title + '\'' +                ", oldprice=" + oldprice +                ", newprice=" + newprice +                '}';    }    public Bijiben(String img, String title, double oldprice, double newprice) {        this.img = img;        this.title = title;        this.oldprice = oldprice;        this.newprice = newprice;    }}
//Books

package com.example.shuju.bean;import java.util.List;/** * Created by 哥哥 on 2017/12/14 0014. */public class Books {    /**     * msg : 查询成功     * code : 0     * data : [{"bargainPrice":11800,"createtime":"2017-10-14T21:48:08","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","itemtype":2,"pid":77,"price":38999.99,"pscid":40,"salenum":7757,"sellerid":21,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"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","itemtype":1,"pid":66,"price":13000,"pscid":40,"salenum":7676,"sellerid":10,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","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","itemtype":0,"pid":76,"price":37999.99,"pscid":40,"salenum":6868,"sellerid":20,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"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","itemtype":1,"pid":69,"price":16999,"pscid":40,"salenum":6645,"sellerid":13,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"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","itemtype":1,"pid":61,"price":14999,"pscid":40,"salenum":5535,"sellerid":5,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"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","itemtype":1,"pid":75,"price":36999,"pscid":40,"salenum":5454,"sellerid":19,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","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","itemtype":0,"pid":79,"price":888,"pscid":40,"salenum":5454,"sellerid":23,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"bargainPrice":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg","itemtype":0,"pid":57,"price":5199,"pscid":40,"salenum":4343,"sellerid":1,"subhead":"i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统","title":"小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银\r\n"},{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","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","itemtype":0,"pid":71,"price":32999,"pscid":40,"salenum":4242,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"},{"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","itemtype":1,"pid":63,"price":10000,"pscid":40,"salenum":3232,"sellerid":7,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"}]     * page : 1     */    private String msg;    private String code;    private String page;    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 String getPage() {        return page;    }    public void setPage(String page) {        this.page = page;    }    public List<DataBean> getData() {        return data;    }    public void setData(List<DataBean> data) {        this.data = data;    }    public static class DataBean {        /**         * bargainPrice : 11800.0         * createtime : 2017-10-14T21:48:08         * 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         * itemtype : 2         * pid : 77         * price : 38999.99         * pscid : 40         * salenum : 7757         * sellerid : 21         * subhead : 购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)         * title : 全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G         */        private double bargainPrice;        private String createtime;        private String detailUrl;        private String images;        private int itemtype;        private int pid;        private double price;        private int pscid;        private int salenum;        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 getItemtype() {            return itemtype;        }        public void setItemtype(int itemtype) {            this.itemtype = itemtype;        }        public int getPid() {            return pid;        }        public void setPid(int pid) {            this.pid = pid;        }        public double getPrice() {            return price;        }        public void setPrice(double price) {            this.price = price;        }        public int getPscid() {            return pscid;        }        public void setPscid(int pscid) {            this.pscid = pscid;        }        public int getSalenum() {            return salenum;        }        public void setSalenum(int salenum) {            this.salenum = salenum;        }        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;        }    }}

//清单文件

<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
name=".App"

//依赖

compile 'com.android.support:recyclerview-v7:26.1.0'compile 'com.squareup.okhttp3:okhttp:3.9.1'compile 'org.xutils:xutils:3.1.24'implementation files('libs/universal-image-loader-1.9.3-with-sources.jar')implementation 'com.google.code.gson:gson:2.2.4'
//activity_main

<?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"    android:orientation="vertical"    tools:context="com.example.shuju.MainActivity">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center"        android:layout_marginTop="10dp"        android:text="商品列表" />    <android.support.v4.widget.SwipeRefreshLayout        android:id="@+id/sprefresh"        android:layout_width="match_parent"        android:layout_height="match_parent">        <android.support.v7.widget.RecyclerView            android:id="@+id/rv"            android:layout_width="match_parent"            android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>    </android.support.v4.widget.SwipeRefreshLayout></LinearLayout>
//item

<?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="match_parent">    <ImageView        android:id="@+id/book_img"        android:layout_width="100dp"        android:layout_height="100dp"        android:layout_marginLeft="10dp"        android:layout_marginTop="20dp"        android:src="@mipmap/ic_launcher" />    <TextView        android:id="@+id/book_text"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="120dp"        android:layout_marginTop="20dp"        android:text="123" />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="120dp"        android:layout_marginTop="60dp"        android:text="原价:" />    <TextView        android:id="@+id/text_oldprice"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="150dp"        android:layout_marginTop="60dp"        android:text="456" />    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="120dp"        android:layout_marginTop="100dp"        android:text="优惠价:"        android:textColor="#F23707" />    <TextView        android:id="@+id/text_newprice"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="170dp"        android:layout_marginTop="100dp"        android:text="234555"        android:textColor="#F23707" /></RelativeLayout>
//item2

<?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">    <ImageView        android:id="@+id/book_img"        android:layout_width="200dp"        android:layout_height="200dp"        android:layout_gravity="center" />    <TextView        android:id="@+id/book_text"        android:layout_width="match_parent"        android:layout_height="wrap_content" />    <LinearLayout        android:layout_width="match_parent"        android:layout_height="20dp">        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="原价:" />        <TextView            android:id="@+id/text_oldprice"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginLeft="10dp"            android:text="456" />    </LinearLayout>    <LinearLayout        android:layout_width="match_parent"        android:layout_height="20dp">        <TextView            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:text="优惠价:"            android:textColor="#F23707" />        <TextView            android:id="@+id/text_newprice"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginLeft="10dp"            android:text="234555"            android:textColor="#F23707" />    </LinearLayout></LinearLayout>
//App

package com.example.shuju;import android.app.Application;import org.xutils.x;public class App extends Application {    public void onCreate() {        super.onCreate();        x.Ext.init(this);        x.Ext.setDebug(BuildConfig.DEBUG);        ImageloaderUtil.initConfig(this);    }}
//ImageloaderUtil
package com.example.shuju;import android.content.Context;import android.graphics.Bitmap;import android.os.Environment;import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;import com.nostra13.universalimageloader.core.DisplayImageOptions;import com.nostra13.universalimageloader.core.ImageLoader;import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;import java.io.File;public class ImageloaderUtil {    /**     * ImageLoader的配置     *     * @param context     */    public static void initConfig(Context context) {        //配置//        File cacheFile=context.getExternalCacheDir();        File cacheFile = new File(Environment.getExternalStorageDirectory() + "/" + "imgages");        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)                .memoryCacheExtraOptions(480, 800)//缓存图片最大的长和宽                .threadPoolSize(2)//线程池的数量                .threadPriority(4)                .memoryCacheSize(2 * 1024 * 1024)//设置内存缓存区大小                .diskCacheSize(20 * 1024 * 1024)//设置sd卡缓存区大小                .diskCache(new UnlimitedDiscCache(cacheFile))//自定义缓存目录                .writeDebugLogs()//打印日志内容                .diskCacheFileNameGenerator(new Md5FileNameGenerator())//给缓存的文件名进行md5加密处理                .build();        ImageLoader.getInstance().init(config);    }    /**     * 获取图片设置类     *     * @return     */    public static DisplayImageOptions getImageOptions() {        DisplayImageOptions optionsoptions = new DisplayImageOptions.Builder()                .cacheInMemory(true)//使用内存缓存                .cacheOnDisk(true)//使用磁盘缓存                .bitmapConfig(Bitmap.Config.RGB_565)//设置图片格式                .build();        return optionsoptions;    }}

//MainActivity

package com.example.shuju;import android.content.Context;import android.os.Bundle;import android.os.Handler;import android.support.v4.widget.SwipeRefreshLayout;import android.support.v7.app.AppCompatActivity;import android.support.v7.widget.GridLayoutManager;import android.support.v7.widget.LinearLayoutManager;import android.support.v7.widget.RecyclerView;import android.widget.Toast;import com.example.shuju.adapter.MyAdapter;import com.example.shuju.bean.Bijiben;import com.example.shuju.presenter.BookPre;import com.example.shuju.view.BView;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Random;public class MainActivity extends AppCompatActivity implements BView {    private RecyclerView rv;    private int q = 1;    private boolean flag = true;    private MyAdapter adapter;    private Context mContext;    private SwipeRefreshLayout sprefresh;    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        rv = findViewById(R.id.rv);        BookPre bookPre = new BookPre(this);        bookPre.getBijiuben();        sprefresh = findViewById(R.id.sprefresh);        // 下拉时触发SwipeRefreshLayout的下拉动画,动画完毕之后就会回调这个方法        sprefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {            @Override            public void onRefresh() {                // 开始刷新,设置当前为刷新状态                //swipeRefreshLayout.setRefreshing(true);                // 这里是主线程                // 一些比较耗时的操作,比如联网获取数据,需要放到子线程去执行                //获取数据                final Random random = new Random();                new Handler().postDelayed(new Runnable() {                    @Override                    public void run() {                        // mList.add(0, "我是天才" + random.nextInt(100) + "");                        //mAdapter.notifyDataSetChanged();                        Toast.makeText(MainActivity.this, "刷新了数据", Toast.LENGTH_SHORT).show();                        Map<String, String> map = new HashMap<>();                        // 加载完数据设置为不刷新状态,将下拉进度收起来                        sprefresh.setRefreshing(false);                    }                }, 1200);                // System.out.println(Thread.currentThread().getName());                // 这个不能写在外边,不然会直接收起来                //swipeRefreshLayout.setRefreshing(false);            }        });    }    @Override    public void onSuccess(final List<Bijiben> list) {        //Log.i("111",list.toString()+"");        //LinearLayout        //LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);        //GridLayoutL        //LinearLayoutManager.VERTICAL LinearLayoutManager.HORIZONTAL横向        GridLayoutManager manager = new GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false);        rv.setLayoutManager(manager);        adapter = new MyAdapter(this, list, 2);        rv.setAdapter(adapter);        flag = false;    }    @Override    public void onFailed() {    }}
//BView

package com.example.shuju.view;import com.example.shuju.bean.Bijiben;import java.util.List;public interface BView {    void onSuccess(List<Bijiben> list);    void onFailed();}
//adapter

//MyAdapter

package com.example.shuju.adapter;import android.content.Context;import android.support.v7.widget.RecyclerView;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.TextView;import com.example.shuju.R;import com.example.shuju.bean.Bijiben;import com.nostra13.universalimageloader.core.ImageLoader;import java.util.List;/** * Created by 哥哥 on 2017/12/14 0014. */public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {    private Context context;    private List<Bijiben> list;    private int q;    public MyAdapter(Context context, List<Bijiben> list, int q) {        this.context = context;        this.list = list;        this.q = q;    }    @Override    public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {        View view = LayoutInflater.from(context).inflate(R.layout.item2, null);        ViewHolder viewHolder = new ViewHolder(view);        return viewHolder;    }    @Override    public void onBindViewHolder(MyAdapter.ViewHolder holder, int position) {        holder.text.setText(list.get(position).getTitle());        holder.newprice.setText(list.get(position).getNewprice() + "");        holder.oldprice.setText(list.get(position).getOldprice() + "");        String img = list.get(position).getImg();        String[] split = img.split("\\|");        ImageLoader.getInstance().displayImage(split[0], holder.img);    }    @Override    public int getItemCount() {        if (list != null) {            return list.size();        } else {            Log.i("12", list.size() + "放松放松");        }        return 0;    }    class ViewHolder extends RecyclerView.ViewHolder {        ImageView img;        TextView text;        TextView oldprice;        TextView newprice;        public ViewHolder(View itemView) {            super(itemView);            img = (ImageView) itemView.findViewById(R.id.book_img);            text = (TextView) itemView.findViewById(R.id.book_text);            oldprice = (TextView) itemView.findViewById(R.id.text_oldprice);            newprice = (TextView) itemView.findViewById(R.id.text_newprice);        }    }}
//model

//BookModel

package com.example.shuju.model;import android.os.Handler;import com.example.shuju.bean.Bijiben;import com.example.shuju.bean.Books;import com.example.shuju.presenter.BookPresenter;import com.google.gson.Gson;import java.io.IOException;import java.util.ArrayList;import java.util.List;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.Response;/** * Created by 哥哥 on 2017/12/14 0014. */public class BookModel {    //定义一个数据集合    private static List<Bijiben> list = new ArrayList<>();    //定义一个handler    private static Handler handler = new Handler();    //请求数据的方法    public void getBijiuben(final BookPresenter bookPresenter) {        new Thread() {            @Override            public void run() {                super.run();                try {                    //OK请求数据                    OkHttpClient okHttpClient = new OkHttpClient();                    Request request = new Request.Builder()                            .get()                            .url("http://120.27.23.105/product/searchProducts?source=android&keywords=笔记本&page=1")                            .build();                    //准备发送网络请求                    okhttp3.Call call = okHttpClient.newCall(request);                    //执行请求                    Response response = call.execute();                    //得到请求的结果                    String result = response.body().string();                    //然后解析数据                    Gson gson = new Gson();                    Books books = gson.fromJson(result.toString(), Books.class);                    List<Books.DataBean> data = books.getData();                    for (int i = 0; i < data.size(); i++) {                        String title = data.get(i).getTitle();                        double newprice = data.get(i).getPrice();                        double bargainPrice = data.get(i).getBargainPrice();                        String images = data.get(i).getImages();                        list.add(new Bijiben(images, title, bargainPrice, newprice));                    }                    handler.post(new Runnable() {                        @Override                        public void run() {                            bookPresenter.onSuccess(list);                        }                    });                } catch (IOException e) {                    e.printStackTrace();                }            }        }.start();    }}
//BookPre

package com.example.shuju.presenter;import com.example.shuju.bean.Bijiben;import com.example.shuju.model.BookModel;import com.example.shuju.view.BView;import java.util.List;public class BookPre implements BookPresenter {    private BView bView;    private BookModel bookModel;    public BookPre(BView bView) {        this.bView = bView;        bookModel = new BookModel();    }    public void getBijiuben() {        bookModel.getBijiuben(this);    }    @Override    public void onSuccess(List<Bijiben> list) {        bView.onSuccess(list);    }    @Override    public void onFailed() {    }}
//BookPresenter

package com.example.shuju.presenter;import com.example.shuju.bean.Bijiben;import java.util.List;public interface BookPresenter {    void onSuccess(List<Bijiben> list);    void onFailed();}
//Bijiben

package com.example.shuju.bean;public class Bijiben {    private String img;    private String title;    private double oldprice;    private double newprice;    public String getImg() {        return img;    }    public void setImg(String img) {        this.img = img;    }    public String getTitle() {        return title;    }    public void setTitle(String title) {        this.title = title;    }    public double getOldprice() {        return oldprice;    }    public void setOldprice(double oldprice) {        this.oldprice = oldprice;    }    public double getNewprice() {        return newprice;    }    public void setNewprice(double newprice) {        this.newprice = newprice;    }    @Override    public String toString() {        return "Bijiben{" +                "img='" + img + '\'' +                ", title='" + title + '\'' +                ", oldprice=" + oldprice +                ", newprice=" + newprice +                '}';    }    public Bijiben(String img, String title, double oldprice, double newprice) {        this.img = img;        this.title = title;        this.oldprice = oldprice;        this.newprice = newprice;    }}
//Books

package com.example.shuju.bean;import java.util.List;/** * Created by 哥哥 on 2017/12/14 0014. */public class Books {        private String msg;    private String code;    private String page;    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 String getPage() {        return page;    }    public void setPage(String page) {        this.page = page;    }    public List<DataBean> getData() {        return data;    }    public void setData(List<DataBean> data) {        this.data = data;    }    public static class DataBean {        /**         * bargainPrice : 11800.0         * createtime : 2017-10-14T21:48:08         * 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         * itemtype : 2         * pid : 77         * price : 38999.99         * pscid : 40         * salenum : 7757         * sellerid : 21         * subhead : 购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)         * title : 全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G         */        private double bargainPrice;        private String createtime;        private String detailUrl;        private String images;        private int itemtype;        private int pid;        private double price;        private int pscid;        private int salenum;        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 getItemtype() {            return itemtype;        }        public void setItemtype(int itemtype) {            this.itemtype = itemtype;        }        public int getPid() {            return pid;        }        public void setPid(int pid) {            this.pid = pid;        }        public double getPrice() {            return price;        }        public void setPrice(double price) {            this.price = price;        }        public int getPscid() {            return pscid;        }        public void setPscid(int pscid) {            this.pscid = pscid;        }        public int getSalenum() {            return salenum;        }        public void setSalenum(int salenum) {            this.salenum = salenum;        }        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;        }    }}