Retrofit3-程序员宅基地

apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.example.lianxi"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    greendao {
        schemaVersion 1
        daoPackage 'com.example.lianxi.dao'
        targetGenDir 'src/main/java'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    compile 'com.facebook.fresco:fresco:1.5.0'
    compile 'org.greenrobot:eventbus:3.1.1'
    compile 'com.jakewharton:butterknife:8.8.1'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    compile 'org.greenrobot:greendao:3.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'

}

///

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.lianxi">

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name=".MYAppliction"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
///

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.lianxi.MainActivity">

    <RelativeLayout
        android:id="@+id/relat"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/radiogroup"
        />

    <RadioGroup
        android:id="@+id/radiogroup"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:gravity="center"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <RadioButton
            android:id="@+id/rb1"
            android:button="@null"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="首页"
            android:gravity="center_horizontal"/>

        <RadioButton
            android:button="@null"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="想法"
            android:gravity="center_horizontal"/>

        <RadioButton
            android:button="@null"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="市场"
            android:gravity="center_horizontal"/>

        <RadioButton
            android:button="@null"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="通知"
            android:gravity="center_horizontal"/>

        <RadioButton
            android:button="@null"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="更多"
            android:gravity="center_horizontal"/>
    </RadioGroup>
</RelativeLayout>
//

<?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.support.v7.widget.RecyclerView
        android:id="@+id/recycle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</LinearLayout>
//

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/sim"
        android:layout_width="100dp"
        android:layout_height="100dp"
        />

    <TextView
        android:id="@+id/text"
        android:text="1111"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>
///

package com.example.lianxi;

import android.app.Application;

import com.example.lianxi.dao.DaoMaster;
import com.example.lianxi.dao.DaoSession;
import com.facebook.drawee.backends.pipeline.Fresco;

import org.greenrobot.greendao.database.Database;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by HP on 2017/12/3.
 */

public class MYAppliction extends Application {
    public static TiGetData tiGetData;
    public static DaoSession session;
    @Override
    public void onCreate() {
        super.onCreate();

        Fresco.initialize(this);

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://120.27.23.105")
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        tiGetData = retrofit.create(TiGetData.class);

        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "dididi");
        Database database = helper.getWritableDb();
        session = new DaoMaster(database).newSession();

    }
}
///

package com.example.lianxi;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;

/**
 * Created by HP on 2017/12/3.
 */

public interface TiGetData {
    @GET("/product/getCarts")
    Call<GetBean> doget(@Query("uid") int uid, @Query("source") String source);
}

///

package com.example.lianxi;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;

/**
 * Created by HP on 2017/12/3.
 */
@Entity
public class ListBean {
    /**
     * 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=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 : 24
     * price : 288.0
     * pscid : 2
     * selected : 0
     * sellerid : 1
     * subhead : 三只松鼠零食特惠,专区满9950,满199100,火速抢购》
     * title : 三只松鼠 坚果炒货 零食奶油味 碧根果225g/     */
    @Id(autoincrement = true)
    private Long id;
    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;
    @Generated(hash = 1127836302)
    public ListBean(Long id, double bargainPrice, String createtime, String detailUrl, String images, int num, int pid, double price, int pscid, int selected, int sellerid, String subhead, String title) {
        this.id = id;
        this.bargainPrice = bargainPrice;
        this.createtime = createtime;
        this.detailUrl = detailUrl;
        this.images = images;
        this.num = num;
        this.pid = pid;
        this.price = price;
        this.pscid = pscid;
        this.selected = selected;
        this.sellerid = sellerid;
        this.subhead = subhead;
        this.title = title;
    }
    @Generated(hash = 777734033)
    public ListBean() {
    }
    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public double getBargainPrice() {
        return this.bargainPrice;
    }
    public void setBargainPrice(double bargainPrice) {
        this.bargainPrice = bargainPrice;
    }
    public String getCreatetime() {
        return this.createtime;
    }
    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }
    public String getDetailUrl() {
        return this.detailUrl;
    }
    public void setDetailUrl(String detailUrl) {
        this.detailUrl = detailUrl;
    }
    public String getImages() {
        return this.images;
    }
    public void setImages(String images) {
        this.images = images;
    }
    public int getNum() {
        return this.num;
    }
    public void setNum(int num) {
        this.num = num;
    }
    public int getPid() {
        return this.pid;
    }
    public void setPid(int pid) {
        this.pid = pid;
    }
    public double getPrice() {
        return this.price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public int getPscid() {
        return this.pscid;
    }
    public void setPscid(int pscid) {
        this.pscid = pscid;
    }
    public int getSelected() {
        return this.selected;
    }
    public void setSelected(int selected) {
        this.selected = selected;
    }
    public int getSellerid() {
        return this.sellerid;
    }
    public void setSellerid(int sellerid) {
        this.sellerid = sellerid;
    }
    public String getSubhead() {
        return this.subhead;
    }
    public void setSubhead(String subhead) {
        this.subhead = subhead;
    }
    public String getTitle() {
        return this.title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
}
//
package com.example.lianxi;

import java.util.List;

/**
 * Created by HP on 2017/12/3.
 */

public class GetBean {
    /**
     * 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=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":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满9950,满199100,火速抢购》","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=QQfriends","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=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":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=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":106,"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 苹果笔记本电脑 银色VP213英寸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=QQfriends","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":2,"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 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"}],"sellerName":"商家13","sellerid":"13"},{"list":[{"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","num":1,"pid":71,"price":32999,"pscid":40,"selected":0,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP213英寸Bar i5/8G/256G"}],"sellerName":"商家15","sellerid":"15"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:38:26","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":23,"price":188,"pscid":1,"selected":0,"sellerid":16,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家16","sellerid":"16"},{"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":35,"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=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":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 {
        /**
         * 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=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":24,"price":288,"pscid":2,"selected":0,"sellerid":1,"subhead":"三只松鼠零食特惠,专区满9950,满199100,火速抢购》","title":"三只松鼠 坚果炒货 零食奶油味 碧根果225g/"}]
         * 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;
        }


    }
}

//

package com.example.lianxi;

/**
 * Created by HP on 2017/12/3.
 */

public class EventBean {
    private String xiaoxi;

    public EventBean(String xiaoxi) {
        this.xiaoxi = xiaoxi;
    }

    public String getXiaoxi() {
        return xiaoxi;
    }
}
//

package com.example.lianxi;

import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;

/**
 * Created by HP on 2017/12/3.
 */

public class ConnectionUtil {
    public static void setNetworkMethod(final Context context) {
        //提示对话框
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("网络设置提示").setMessage("网络连接不可用,是否进行设置?").setPositiveButton("设置", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                Intent intent = null;
                //判断手机系统的版本  即API大于10 就是3.0或以上版本
                if (android.os.Build.VERSION.SDK_INT > 10) {
                    intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
                } else {
                    intent = new Intent();
                    ComponentName component = new ComponentName("com.android.settings", "com.android.settings.WirelessSettings");
                    intent.setComponent(component);
                    intent.setAction("android.intent.action.VIEW");
                }
                context.startActivity(intent);
            }
        }).setNegativeButton("取消", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                dialog.dismiss();
            }
        }).show();

    }
}

///

package com.example.lianxi.M;

import com.example.lianxi.GetBean;
import com.example.lianxi.ListBean;
import com.example.lianxi.MYAppliction;

import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by HP on 2017/12/3.
 */

public class MyModel {

    public void getData(final ModelCallBack callBack){
        Call<GetBean> call = MYAppliction.tiGetData.doget(100, "android");
        call.enqueue(new Callback<GetBean>() {
            @Override
            public void onResponse(Call<GetBean> call, Response<GetBean> response) {
                GetBean body = response.body();
                callBack.success(body);
                List<GetBean.DataBean> data = body.getData();
                List<ListBean> list=new ArrayList<>();
                for (GetBean.DataBean haha:data){
                    List<ListBean> list1 = haha.getList();
                    list.addAll(list1);
                }
                MYAppliction.session.getListBeanDao().insertInTx(list);
            }

            @Override
            public void onFailure(Call<GetBean> call, Throwable t) {
                callBack.failure(new Exception(""));
            }
        });
    }

    public interface ModelCallBack{
        public void success(GetBean getBean);
        public void failure(Exception e);
    }
}

//

package com.example.lianxi.P;

import com.example.lianxi.GetBean;
import com.example.lianxi.M.MyModel;

/**
 * Created by HP on 2017/12/3.
 */

public class MyPresenter {
    ViewCallBack callBack;
    public MyPresenter(ViewCallBack callBack){
        this.callBack = callBack;
    }
    MyModel myModel = new MyModel();
    public void getdata(){
        myModel.getData(new MyModel.ModelCallBack() {
            @Override
            public void success(GetBean getBean) {
                callBack.success(getBean);
            }

            @Override
            public void failure(Exception e) {
                callBack.failure(e);
            }
        });
    }

    public interface ViewCallBack{
        public void success(GetBean getBean);
        public void failure(Exception e);
    }
}
///

package com.example.lianxi;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import org.greenrobot.eventbus.EventBus;

public class MainActivity extends AppCompatActivity {
    private RadioGroup radioGroup;
    private RadioButton radioButton;
    private boolean fail = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        radioGroup = (RadioGroup) findViewById(R.id.radiogroup);
        radioButton = (RadioButton) findViewById(R.id.rb1);
        //getSupportFragmentManager().beginTransaction().replace(R.id.relat,new fragment()).commit();
        if(!isConn(getApplicationContext())){
            ConnectionUtil.setNetworkMethod(MainActivity.this);
            EventBus.getDefault().postSticky(new EventBean("没网了"));
            fail = false;

        }

        if(fail){
            EventBus.getDefault().postSticky(new EventBean("咱有网"));
        }


        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                switch (i)
                {
                    case R.id.rb1:
                        getSupportFragmentManager().beginTransaction().replace(R.id.relat,new fragment()).commit();
                        break;
                }
            }
        });

    }
    public static boolean isConn(Context context){
        boolean bisConnFlag=false;
        ConnectivityManager conManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo network = conManager.getActiveNetworkInfo();
        if(network!=null){
            bisConnFlag=conManager.getActiveNetworkInfo().isAvailable();
        }
        return bisConnFlag;
    }
}
*//*/*/*/*/*

package com.example.lianxi;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.lianxi.P.MyPresenter;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.util.List;

/**
 * Created by HP on 2017/12/3.
 */

public class fragment extends Fragment {
    private RecyclerView recyclerView;
    private MyPresenter myPresenter;
    private MyAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.layout_frag,container,false);
        recyclerView = (RecyclerView) view.findViewById(R.id.recycle);
        return view;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        EventBus.getDefault().register(this);

        myPresenter = new MyPresenter(new MyPresenter.ViewCallBack() {
            @Override
            public void success(GetBean getBean) {
                /*List<GetBean.DataBean> data = getBean.getData();
                List<ListBean> list=new ArrayList<>();
                for (GetBean.DataBean haha:data){
                    List<ListBean> list1 = haha.getList();
                    list.addAll(list1);
                }
                adapter.add(list);*/
            }

            @Override
            public void failure(Exception e) {

            }
        });

        myPresenter.getdata();

        adapter = new MyAdapter(getActivity());

        List<ListBean> list = MYAppliction.session.getListBeanDao().loadAll();

        adapter.add(list);

        LinearLayoutManager manager = new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false);
        recyclerView.setLayoutManager(manager);
        recyclerView.setAdapter(adapter);


    }
    @Subscribe(sticky = true)
    public void getEvent(EventBean eventBean){
        Toast.makeText(getActivity(),eventBean.getXiaoxi(),Toast.LENGTH_SHORT).show();
    }

}
/**//

package com.example.lianxi;

import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by HP on 2017/12/3.
 */


public class MyAdapter extends RecyclerView.Adapter<MyAdapter.IViewHolder>{

    FragmentActivity activity;
    List<ListBean> list = new ArrayList<>();
    List<String> listimage = new ArrayList<>();
    public MyAdapter(FragmentActivity activity) {
        this.activity = activity;
    }

    @Override
    public IViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(activity, R.layout.layout_adapter, null);
        return new IViewHolder(view);
    }

    @Override
    public void onBindViewHolder(IViewHolder holder, int position) {
        String images = this.list.get(position).getImages();
        String[] split = images.split("\\|");
        for(int i = 0; i<split.length;i++){
            listimage.add(split[i]);
        }
        holder.simpleDraweeView.setImageURI(listimage.get(position));
        holder.textView.setText(list.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return this.list==null ? 0 : this.list.size();
    }

    public void add(List<ListBean> list) {
        this.list.addAll(list);
        notifyDataSetChanged();
    }

    static class IViewHolder extends RecyclerView.ViewHolder{

        private final SimpleDraweeView simpleDraweeView;
        private final TextView textView;

        public IViewHolder(View itemView) {
            super(itemView);

            simpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.sim);
            textView = (TextView) itemView.findViewById(R.id.text);
        }
    }
}

package com.example.lianxi;

/**
 * Created by HP on 2017/12/3.
 */

public class EventBean {
    private String xiaoxi;

    public EventBean(String xiaoxi) {
        this.xiaoxi = xiaoxi;
    }

    public String getXiaoxi() {
        return xiaoxi;
    }
}

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/SLXNRZYL/article/details/78703477

智能推荐

php调用函数外的变量_php function 外部变量-程序员宅基地

文章浏览阅读992次。2.函数内global声明,函数内$GLOBALS数组或者直接引用。1.函数外global声明,函数内使用$GLOBALS数组引用。3.在调用函数的时候用一个参数传递。_php function 外部变量

封装_封装实现的必要性-程序员宅基地

文章浏览阅读2.8k次。介绍了Java面向对象之封装特性,以及代码块_封装实现的必要性

6月23日云栖精选夜读:重磅!阿里妈妈首次公开自研CTR预估核心算法MLR-程序员宅基地

文章浏览阅读132次。技术背景 CTR(Click-Through-Rate)即点击通过率,是互联网广告常用的术语,指网络广告(图片广告/文字广告/关键词广告/排名广告/视频广告等)的点击到达率,即该广告的实际点击次数除以广告的展现量。热点热议重磅!阿里妈妈首次公开自研CTR预估核心算法MLR作者:技术小能手 发表在:阿里技术基于数加,全民众筹平台开启大数据智能时..._ctr预估核心算法mlr)

lwip-1.4.1,上电ping通,一段时间后无法屏通_lwip运行一段时间后ping不通-程序员宅基地

文章浏览阅读872次。部分lwip版本可能有bug。在STM32F4使用lwip-14.1时,在LwIP_Periodic_Handle后面加多一个延时也可以解决问题。LwIP_Periodic_Handle(LocalTime);delay_ms(10);//LWIPЭÒé²»×ã_lwip运行一段时间后ping不通

Oracle EBS值集_flex_value setiame-程序员宅基地

文章浏览阅读5.4k次。1、从值集中取值SELECT ffv.flex_value, ffv.description FROM fnd_flex_values_vl ffv, fnd_flex_value_sets ffs WHERE ffv.flex_value_set_id = ffs.flex_value_set_id AND ffs.flex_value_set_name_flex_value setiame

基于UDP协议的实时影像传输程序_udp图像传输源码-程序员宅基地

文章浏览阅读600次,点赞3次,收藏4次。声明:本文仅作为个人创作成果过程备份,不具有专门的教育作用。程序还未完成,无法顺利运行是正常现象本人为非计算机相关专业大一学生,学习c语言仅为个人爱好,如有技术性错误请各位轻喷,欢迎大家提出任何具有建设意义的建议客户端(基于Linux平台):#include <stdio.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/socket._udp图像传输源码

随便推点

vue3快速入门-程序员宅基地

文章浏览阅读907次,点赞28次,收藏16次。Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境。Node.js 使用了一个事件驱动、非阻塞式 I/O 的模型,使其轻量又高效。Node 是一个让 JavaScript 运行在服务端的开发平台,它让 JavaScript 成为与 PHP、Python、Perl、Ruby 等服务端语言平起平坐的脚本语言。发布于 2009 年 5 月,由 Ryan Dahl 开发,实质是对 Chrome V8 引擎进行了封装。

关于少样本学习、零样本学习、单样本学习中的support set和query set的概念解析_support set和query set怎么取值-程序员宅基地

文章浏览阅读736次,点赞16次,收藏10次。梳理一下关于少样本学习(如few-shot learning)、零样本学习(zero-shot learning)、单样本学习(one-shot learning)中的support set和query set的概念,以及为何测试集中会涉及到“unseen”(未见过)的新类。_support set和query set怎么取值

STM32下推式磁悬浮装置(二)原理图设计思路_单片机磁悬浮-程序员宅基地

文章浏览阅读1.5w次,点赞36次,收藏168次。前言这是STM32下推式磁悬浮装置的第二篇文章,接下来将介绍磁悬浮装置的原理图、PCB、设计思路。_单片机磁悬浮

tf.nn.dropout和tf.keras.layers.Dropout的区别(TensorFlow2.3)与实验_tensorflow.keras.layers.dropout-程序员宅基地

文章浏览阅读4.4k次,点赞5次,收藏7次。这里写目录标题场景:dropout和Dropout区别问题描述:结论:深层次原因:dropout是底层API,Dropout是高层API场景:dropout和Dropout区别全网搜索tf.nn.dropout和tf.keras.layers.Dropout区别,发现好多都是错误的讲解,因此有必要进行一次实验和纠错。tf.nn.dropout和tf.keras.layers.Dropout的区别,看本文就足够了。问题描述:tf.nn.dropout和tf.keras.layers.Dropou_tensorflow.keras.layers.dropout

【组成原理-处理器】处理器的相关概念_平均指令周期计算公式-程序员宅基地

文章浏览阅读5.3k次,点赞22次,收藏137次。【组成原理-处理器】处理器的相关概念_平均指令周期计算公式

m基于BP神经网络的障碍物避障和路线规划matlab仿真_障碍物距离计算仿真-程序员宅基地

文章浏览阅读1k次。在BP神经网络中,隐含层数量对神经网络的性能有着至关重要的影响,如果隐含层数量过多,会大大增加BP神经网络的内部结构的复杂度,从而降低学习效率,增加训练时间;由于隐含层个数的设置没有明确的理论可以计算,通常情况下,采用逐次分析的方法获得,即通过对不同隐含层所对应的神经网络进行预测误差的仿真分析,选择误差最小情况下所对应的隐含层个数。BP神经网络的初始网络权值对网络训练的效率以及预测性能有着较大的影响,通常情况下,采用随机生成[-1,1]之间的随机数作为BP神经网络的初始权值。_障碍物距离计算仿真

推荐文章

热门文章

相关标签