(三) 技術選型 1.項目框架模式:MVP(得分點);注意:分包分層,避免內存泄漏; 2.圖片加載:Fresco圖片加載框架; 3.網絡加載框架:retrofit;使用Retrofit+RxJ

首先呢    先把業務邏輯需求講一下  大致思路都是根據自己所想的去做,下面是我個人做的一個小model,希望能幫到有需要的人


  1. 業務邏輯需求

1MVP分包分層:ModelViewPresenter三層,在合適的時候綁定,合適的時候取消綁定

2Retrofit訪問網絡接口獲取數據Rxjava異步處理數據;使用ButterKnife取控件

3、圖片展示使用Fresco圖片加載框架;初始化Fresco,配置Fresco使用磁盤緩存。 

首先呢  創建一個項目 啊哈哈  這都不需要說了 下面我們進入正題  主要使用的是七中方法 然後調用對象 對象調對象,接口調接口

佈局根文件activity.xml裏面的佈局如下:

<?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.activity.MainActivity">
    <LinearLayout
        android:layout_marginTop="10px"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="0px"
            android:layout_height="80px"
            android:layout_weight="4"
            android:textColor="#f28040"
            android:gravity="center"
            android:text="返回"/>
        <TextView
            android:textSize="30px"
            android:layout_width="0px"
            android:layout_height="80px"
            android:text="草稿箱"
            android:gravity="center"
            android:textColor="#333333"
            android:layout_weight="2"
            />
        <TextView
            android:id="@+id/clear"
            android:layout_width="0px"
            android:layout_height="80px"
            android:layout_weight="4"
            android:gravity="center"
            android:textColor="#f28040"
            android:text="清空"/>
    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="#6666"/>
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/rv"/>
</LinearLayout>

然後呢還需要一個佈局去寫另一個頁面沒有完成的二次跳轉:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/img"
        android:layout_width="190px"
        android:layout_height="160px"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="15dp"
        android:src="@mipmap/ic_launcher"
        />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/name1"
            android:textSize="15dp"
            android:layout_marginTop="15dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/name2"
            android:layout_marginTop="15dp"
            android:layout_width="wrap_content"
            android:text="未完成"
            android:textColor="#F57A54"
            android:layout_height="wrap_content" />
        <TextView
            android:id="@+id/name3"
            android:layout_marginTop="15dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>
</LinearLayout>

下面進入正題 首先呢 是我們的根類 Mainactivity.java

public class MainActivity extends AppCompatActivity {


    private RecyclerView rv;
    private ShowPresenter showPresenter;
    private List<ShowGoods.DataBean> data;
    private MyAdapter myAdapter;
    private UserDao userDao;
    private List<User> select;
    private MyAdapter1 myAdapter1;
    private TextView clear;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //獲取控件
        initView();
        showPresenter =new ShowPresenter();
        showPresenter.ShowCartDemo("72", "android", new ShowView() {
            @Override
            public void OnSuccess(ShowGoods showGoods) {
                data = showGoods.getData();
                Log.d("pppppppppppppp", MainActivity.this.data.size()+"");
                myAdapter =new MyAdapter(MainActivity.this.data,MainActivity.this);
                rv.setAdapter(myAdapter);


            }
        });


    }


    private void initView() {
        rv = (RecyclerView) findViewById(R.id.rv);
        //
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
        rv.setLayoutManager(linearLayoutManager);
        //清空
        clear = (TextView) findViewById(R.id.clear);
        clear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                select.clear();
                myAdapter1.notifyDataSetChanged();
                userDao.delete();
            }
        });
    }
    //再次啓動


    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d("qqqqqqqqqqqqqqqq","再次啓動");
        userDao =new UserDao(MainActivity.this);
        select = userDao.select();
        myAdapter1 =new MyAdapter1(MainActivity.this, select);
        rv.setAdapter(myAdapter1);
    }
}

然後會跟着實現方法  如上面所說   實現方法ShowPresenter

public class ShowPresenter {
private ShowModel showModel;
public void ShowCartDemo(String uid, String android, final ShowView showView){
showModel=new ShowModel();
showModel.ShowCartDemo(uid, android, new ShowModel.OnGetListener() {
@Override
public void OnGetSuccese(ShowGoods showGoods) {
if (showView!=null){
showView.OnSuccess(showGoods);
}
}


@Override
public void OnGetFail() {


}
});
}
}


接下來的  各種方法我就不一一跟大家介紹了  

model層

public class ShowModel {
    public void ShowCartDemo(String uid,String android,final OnGetListener onGetListener){
        Retrofit retrofit=new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl(Api.HOST)
                .build();
        ApiService apiService = retrofit.create(ApiService.class);
        Observable<ShowGoods> observable = apiService.getCart(uid, android);
        observable.subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<ShowGoods>() {
                    @Override
                    public void onCompleted() {


                    }


                    @Override
                    public void onError(Throwable e) {


                    }


                    @Override
                    public void onNext(ShowGoods showGoods) {
                        if (onGetListener!=null){
                            onGetListener.OnGetSuccese(showGoods);
                            Log.d("jjjjjjjjjjjj",showGoods.getMsg());
                        }
                    }
                });


    }
    public interface OnGetListener{
        void OnGetSuccese(ShowGoods showGoods);
        void OnGetFail();
    }
}

sqlite

public class Sqlite extends SQLiteOpenHelper {
    public Sqlite(Context context) {
        super(context, "Goods.db", null, 1);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table user(name1 text,name3 text,img text)");
    }


    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {


    }
}

showView裏面的代碼

public interface ShowView {
    void OnSuccess(ShowGoods showGoods);
}

RetrofitUtils裏面添加的代碼

public class RetrofitUtils {
    private static RetrofitUtils RETROFIT_UTILS = null;


    private RetrofitUtils() {}


    public static RetrofitUtils getInData() {
        if (RETROFIT_UTILS == null){
            synchronized (RetrofitUtils.class){
                if (RETROFIT_UTILS == null){
                    RETROFIT_UTILS = new RetrofitUtils();
                }
            }
        }
        return RETROFIT_UTILS;
    }


    public <T> T getRetrofit(String path,Class<T> cla){
        HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
            @Override
            public void log(String message) {
                Log.i("TAG",message);
            }
        });


        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);


        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new HttpUrlConnection())
                .addInterceptor(httpLoggingInterceptor)
                .build();


        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(path)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create(new Gson()))
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();


        T t = retrofit.create(cla);


        return t;
    }
}
HttpUrlConnection裏面的寫的代碼如下

public class HttpUrlConnection implements Interceptor {


    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        String method = request.method();
        Log.i("tag",method+"00000");
        if ("GET".equals(method)) {
            String oldUrl = request.url().toString();
            String newUrl = oldUrl + "&source=android";
            request = new Request.Builder()
                    .url(newUrl)
                    .build();
        }else if ("POST".equals(method)){
            String path = request.url().toString();
            FormBody oldBody = (FormBody) request.body();
            FormBody.Builder newBody = new FormBody.Builder();
            for (int i = 0; i < oldBody.size() ; i++){
                String name = oldBody.name(i);
                String value = oldBody.value(i);
                newBody.add(name,value);
            }
            newBody.add("source","android");
            request = new Request.Builder()
                    .post(newBody.build())
                    .url(path)
                    .build();
        }
        return chain.proceed(request);
    }
}

下面是封裝的類  我也寫好放下面了UserDao:

public class UserDao {
    private Sqlite sqlite;
    public UserDao(Context context){
        sqlite=new Sqlite(context);
    }
    //添加
    public void add(String name1,String name3,String img){
        SQLiteDatabase database = sqlite.getReadableDatabase();
        database.execSQL("insert into user(name1,name3,img) values(?,?,?)",
                new String[]{name1,name3,img});
        database.close();
    }
    //查詢
    public List<User> select(){
        List<User> list = new ArrayList<>();
        SQLiteDatabase database = sqlite.getReadableDatabase();
        Cursor cursor = database.rawQuery("select * from user",
                new String[]{});
        while(cursor.moveToNext()){
            String name1 = cursor.getString(cursor.getColumnIndex("name1"));
            String name3 = cursor.getString(cursor.getColumnIndex("name3"));
            String img = cursor.getString(cursor.getColumnIndex("img"));
            User user = new User(name1, name3, img);
            list.add(user);
        }
        return list;
    }
    public void delete(){
        SQLiteDatabase database = sqlite.getReadableDatabase();
        database.execSQL("delete from user", new String[]{});
        database.close();
    }
}

ShowGoods裏面放入的代碼:

這個裏面放入的東西都是自動生成,但是有些剛剛接觸的  不是很懂得  所以我就寫出來了

public class ShowGoods {


    /**
     * msg : 請求成功
     * code : 0
     * data : [{"list":[{"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","num":1,"pid":57,"price":5199,"pscid":40,"selected":1,"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"}],"sellerName":"商家1","sellerid":"1"},{"list":[{"bargainPrice":22.9,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","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":7,"pid":25,"price":399,"pscid":2,"selected":1,"sellerid":2,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"},{"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=QQfriends","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":5,"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":1599,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/1993026402.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5863/302/8961270302/97126/41feade1/5981c81cNc1b1fbef.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7003/250/1488538438/195825/53bf31ba/5981c57eN51e95176.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5665/100/8954482513/43454/418611a9/5981c57eNd5fc97ba.jpg!q70.jpg","num":1,"pid":47,"price":111,"pscid":39,"selected":1,"sellerid":3,"subhead":"碳黑色 32GB 全網通 官方標配   1件","title":"錘子 堅果Pro 特別版 巧克力色 酒紅色 全網通 移動聯通電信4G手機 雙卡雙待 碳黑色 32GB 全網通"}],"sellerName":"商家3","sellerid":"3"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","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":1,"pid":11,"price":8989,"pscid":1,"selected":1,"sellerid":4,"subhead":"每個中秋都不能簡單,無論身在何處,你總需要一塊餅讓生活更圓滿,京東月餅讓愛更圓滿京東自營,閃電配送,更多驚喜,快用手指戳一下","title":"北京稻香村 稻香村中秋節月餅 老北京月餅禮盒655g"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-03T23:43:53","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","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":1,"pid":12,"price":256,"pscid":1,"selected":1,"sellerid":5,"subhead":"每個中秋都不能簡單,無論身在何處,你總需要一塊餅讓生活更圓滿,京東月餅讓愛更圓滿京東自營,閃電配送,更多驚喜,快用手指戳一下","title":"北京稻香村 稻香村中秋節月餅 老北京月餅禮盒655g"}],"sellerName":"商家5","sellerid":"5"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","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":15,"price":233.99,"pscid":1,"selected":1,"sellerid":8,"subhead":"每個中秋都不能簡單,無論身在何處,你總需要一塊餅讓生活更圓滿,京東月餅讓愛更圓滿京東自營,閃電配送,更多驚喜,快用手指戳一下","title":"北京稻香村 稻香村中秋節月餅 老北京月餅禮盒655g"}],"sellerName":"商家8","sellerid":"8"},{"list":[{"bargainPrice":22.9,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/2542855.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","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":35,"price":10,"pscid":2,"selected":1,"sellerid":12,"subhead":"三隻松鼠零食特惠,專區滿99減50,滿199減100,火速搶購》","title":"三隻松鼠 堅果炒貨 零食奶油味 碧根果225g/袋"}],"sellerName":"商家12","sellerid":"12"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","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":1,"pid":22,"price":799,"pscid":1,"selected":1,"sellerid":15,"subhead":"每個中秋都不能簡單,無論身在何處,你總需要一塊餅讓生活更圓滿,京東月餅讓愛更圓滿京東自營,閃電配送,更多驚喜,快用手指戳一下","title":"北京稻香村 稻香村中秋節月餅 老北京月餅禮盒655g"}],"sellerName":"商家15","sellerid":"15"},{"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=QQfriends","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":1,"pid":2,"price":299,"pscid":1,"selected":1,"sellerid":18,"subhead":"每個中秋都不能簡單,無論身在何處,你總需要一塊餅讓生活更圓滿,京東月餅讓愛更圓滿京東自營,閃電配送,更多驚喜,快用手指戳一下","title":"北京稻香村 稻香村中秋節月餅 老北京月餅禮盒655g"}],"sellerName":"商家18","sellerid":"18"},{"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=QQfriends","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":1,"pid":5,"price":88.99,"pscid":1,"selected":1,"sellerid":21,"subhead":"每個中秋都不能簡單,無論身在何處,你總需要一塊餅讓生活更圓滿,京東月餅讓愛更圓滿京東自營,閃電配送,更多驚喜,快用手指戳一下","title":"北京稻香村 稻香村中秋節月餅 老北京月餅禮盒655g"}],"sellerName":"商家21","sellerid":"21"}]
     */


    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 {
        /**
         * list : [{"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","num":1,"pid":57,"price":5199,"pscid":40,"selected":1,"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"}]
         * sellerName : 商家1
         * sellerid : 1
         */


        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 {
            /**
             * bargainPrice : 11800.0
             * 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
             * num : 1
             * pid : 57
             * price : 5199.0
             * pscid : 40
             * selected : 1
             * sellerid : 1
             * subhead : 【i5 MX150 2G顯存】全高清窄邊框 8G內存 256固態硬盤 支持指紋識別 預裝WIN10系統
             * title : 小米(MI)Air 13.3英寸全金屬輕薄筆記本(i5-7200U 8G 256G PCle SSD MX150 2G獨顯 FHD 指紋識別 Win10)銀


             */


            private double bargainPrice;
            private String createtime;
            private String detailUrl;
            private String images;
            private int num;
            private int pid;
            private double 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 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 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;
            }
        }
    }
}


User類就相對比較簡單了 .封裝一些東西就好了 這裏我就不寫了     剛接觸過得人都知道   getter setter方法就可以了   

下面的是Api接口   我也就不寫了  根據自己需要的接口去套現就好   Apiservice裏面也是一樣的  

最後呢  代碼就成型了  最後需要加上網絡權限  這是不可以需要切記的  然後就是依賴了   

依賴如下::

 //
    compile 'com.jakewharton:butterknife:8.5.1'
    //
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    //
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    // recyclerview  下拉刷新 依賴
    compile 'com.android.support:recyclerview-v7:26.1.0'
    //
    compile 'com.github.bumptech.glide:glide:3.5.2'
    //okhttp依賴:
    compile 'com.squareup.okio:okio:1.5.0'
    //okhttp依賴:
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    //ConverterFactory的Gson依賴包
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    //ConverterFactory的String依賴包
    compile 'com.squareup.retrofit2:converter-scalars:2.0.0'
    //日誌攔截器
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    //
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
    //rxjava依賴:
    compile 'io.reactivex:rxjava:1.0.14'
    //rxandroid依賴
    compile 'io.reactivex:rxandroid:1.0.1'






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章