第5章 首页列表开发与测试-5-3 首页列表—上一小节回顾串讲

第5章 首页列表开发与测试-5-3 首页列表—上一小节回顾串讲_第1张图片

5-3 首页列表—上一小节回顾串讲

![QQ浏览器截屏未命名.png](http://upload-images.jianshu.io/upload_images/1428342-4ddb2c5dfd30eb5f.png?
imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

{
    "ecode": "0",
    "emsg": "",
    "data": {
        "head": {
            "ads": [
                "http://img.mukewang.com/54bf7e1f000109c506000338-590-330.jpg",
                "http://upload.techweb.com.cn/2015/0114/1421211858103.jpg",
                "http://img1.cache.netease.com/catchpic/A/A0/A0153E1AEDA115EAE7061A0C7EBB69D2.jpg",
                "http://image.tianjimedia.com/uploadImages/2015/202/27/57RF8ZHG8A4T_5020a2a4697650b89c394237ba9ffbb45fe8555a2cbec-6O6nmI_fw658.jpg"
            ],
            "middle": [
                "http://img.mukewang.com/54f55ee60001850f05000280.jpg",
                "http://img7.doubanio.com/view/note/large/public/p26832324.jpg",
                "http://img.mukewang.com/546570370001f8a906000338-590-330.jpg",
                "http://img.mukewang.com/55f93f980001f52125001408-590-330.jpg"
            ],
            "footer": [
                {
                    "title": "5个新ios课程",
                    "info": "jack大拿发布",
                    "from": "来自上海的讲师",
                    "imageOne": "http://i7.hexunimg.cn/2015-07-07/177346079.jpg",
                    "imageTwo": "http://imgsrc.baidu.com/forum/w%3D580/sign=2ca8123a261f95caa6f592bef9167fc5/bc1cae51f81986188dd8f8c049ed2e738ad4e6da.jpg",
                    "destationUrl": "http://www.imooc.com/learn/677"
                },
                {
                    "title": "3个新android课程",
                    "info": "herry-android高级开发",
                    "from": "来自北京的讲师",
                    "imageOne": "http://imgsrc.baidu.com/forum/w%3D580/sign=4e0ee1bcd2c8a786be2a4a065709c9c7/bc71953eb13533fae99ad268abd3fd1f40345bf5.jpg",
                    "imageTwo": "http://images.cnitblog.com/news/66372/201412/041520272014384.png",
                    "destationUrl": "http://www.imooc.com/learn/690"
                }
            ]
        },
        "list": [
            {
                "type": 2,
                "logo": "http://v1.qzone.cc/avatar/201305/17/22/06/519639762c4e6138.jpg%21200x200.jpg",
                "title": "tb73399384",
                "info": "1",
                "price": "$1200",
                "text": "还在手动写繁锁的页面吗?GRUT让你脱离苦海.",
                "from": " 来自北京|新中关",
                "zan": "5",
                "url": [
                    "http://img.mukewang.com/54f55ee60001850f05000280.jpg"
                ]
            },
            {
                "type": 3,
                "title": "7天搞定Node.js微信公众号@前端到后台ThinkPHP开发整站@组件方式开发WebAPP全站@飞速上手的跨平台App开始@Yii2.0全力出击打造完整电商",
                "price": "当前价格:128.00@当前价格:268.00@当前价格:78.00@当前价格:88.00@当前价格:168.00",
                "info": "【专治各种疑问】什么是收费课?@【专治各种疑问】为什么要收费?@【专治各种疑问】收费课程的核心价值?@【专治各种疑问】收费课与免费课的区别?@【专治各种疑问】如何购买课程?",
                "text": "842人在学@1353人在学@345人在学@1264人在学@737人在学",
                "url": [
                    "http://img.zcool.cn/community/01bba8564aefde32f87512f6a47ea3.jpg",
                    "http://i8.hexunimg.cn/2015-08-21/178515688.jpg",
                    "http://img.mukewang.com/54b619d70001294906000338-590-330.jpg",
                    "http://img.mukewang.com/539a5dac0001199007200404-500-284.jpg",
                    "http://img.mukewang.com/55657fa600015fe206000338-590-330.jpg",
                    "http://img.mukewang.com/5668dc790001aa2b06000338-590-330.jpg",
                    "http://img.mukewang.com/55f93f980001f52125001408-590-330.jpg",
                    "http://img0.imgtn.bdimg.com/it/u=2174499043,1857890027&fm=21&gp=0.jpg",
                    "http://img.mukewang.com/56556ecb00010b7806000338-590-330.jpg",
                    "http://img4.imgtn.bdimg.com/it/u=3072502270,3193310350&fm=21&gp=0.jpg",
                    "http://img.mukewang.com/56e617dd0001583d06000338-590-330.jpg",
                    "http://img.mukewang.com/5487a78e000105b606000338-590-330.jpg",
                    "http://img3.imgtn.bdimg.com/it/u=1105015795,3331123080&fm=21&gp=0.jpg",
                    "http://i0.hdslb.com/bfs/archive/cd265f24dae73ad0afaae638735b67749a8acfb5.jpg",
                    "http://i0.hdslb.com/bfs/archive/db522f316a9f555d8fa9bfe856c5a606612747d6.jpg"
                ]
            },
            {
                "type": 0,
                "logo": "http://b.hiphotos.baidu.com/zhidao/pic/item/d1a20cf431adcbefef0f982fabaf2edda3cc9fe4.jpg",
                "title": "今日必学",
                "info": "1",
                "text": "想成为全栈工程师吗,MogoDB你的不二法宝.",
                "site": "http://www.imooc.com/learn/595",
                "from": "来自南京",
                "zan": "10",
                "resource": "http://fairee.vicp.net:83/2016rm/0116/baishi160116.mp4",
                "adid": "00000001112",
                "clickUrl": "http://www.imooc.com/",
                "clickMonitor": [
                    {
                        "ver": "0",
                        "url": "http://imooc.com/click??click=1"
                    },
                    {
                        "ver": "0",
                        "url": "http://imooc.com/click?click=2"
                    }
                ],
                "startMonitor": [
                    {
                        "ver": "0",
                        "url": "http://imooc.com/show?impression=1"
                    },
                    {
                        "ver": "0",
                        "url": "http: //imooc.com/show?impression=2"
                    }
                ],
                "middleMonitor": [
                    {
                        "ver": "0",
                        "url": "http://imooc.com/show?SU=1",
                        "time": 5
                    },
                    {
                        "ver": "0",
                        "url": "http: //imooc.com/show?impression=2",
                        "time": 5
                    }
                ],
                "endMonitor": [
                    {
                        "ver": "0",
                        "url": "http://imooc.com/show?end=1",
                        "time": 5
                    },
                    {
                        "ver": "0",
                        "url": "http: //imooc.com/show?end=2",
                        "time": 5
                    }
                ]
            },
            {
                "type": 1,
                "logo": "http://img3.duitang.com/uploads/item/201407/01/20140701222607_AnKfj.thumb.224_0.jpeg",
                "title": "qndroid",
                "info": "2",
                "price": "$2400",
                "text": "来慕课网,你可以学到任何你想学的知识.看视频还不够?别担心,我们还有大神手把手教你。",
                "from": " 来自北京|德外大街",
                "zan": "5",
                "url": [
                    "http://img.mukewang.com/549bda090001c53e06000338-590-330.jpg",
                    "http://img.mukewang.com/5707604300018d0406000338-590-330.jpg",
                    "http://articles.csdn.net/uploads/allimg/150617/6_150617172820_1.png",
                    "http://f1.diyitui.com/b3/e1/db/5f/24/ea/d8/59/1e/ea/28/04/b3/57/d6/6f.jpg",
                    "http://upload1.techweb.com.cn/s/320/2015/0527/1432714922459.jpg"
                ]
            },
            {
                "type": 2,
                "logo": "http://img0.imgtn.bdimg.com/it/u=3266845821,3017593921&fm=21&gp=0.jpg",
                "title": "臭脚0000",
                "info": "1",
                "price": "$1199",
                "text": "还不会IM程序吗?找我就对了,5小时让你从IM小白到大神.",
                "from": "来自珠海",
                "zan": "2",
                "url": [
                    "http://it.enorth.com.cn/pic2014/002/000/092/00200009288_502cc21c.png"
                ]
            },
            {
                "type": 1,
                "logo": "http://minimg.hexun.com/i1.hexunimg.cn/2014-03-07/162829724_250x200.jpg",
                "title": "慕课风采",
                "info": "3",
                "price": "只求赞",
                "text": "慕课网,一家致力于为所有互联网学子提供帮助的情怀培训机构,还要犹豫什么,加入慕课网这个大家庭,一起和喜欢的人做喜欢的事儿.",
                "from": "来自北京",
                "zan": "1",
                "url": [
                    "http://img3.imgtn.bdimg.com/it/u=3328472612,2780698499&fm=15&gp=0.jpg",
                    "http://minimg.hexun.com/i1.hexunimg.cn/2014-03-07/162829724_250x200.jpg",
                    "http://www.tzkd.com/uploadfile/2015/0917/20150917114818920.jpg"
                ]
            },
            {
                "type": 2,
                "logo": "http://awb.img.xmtbang.com/img/uploadnew/201510/23/ccaeb2d2abe94fa6b3efe014e9146e94.jpg",
                "title": "xiaopangzi",
                "info": "3",
                "price": "$130",
                "text": "还在为面试而发愁吗,还在为BAT而日思夜想吗?来跟大神学面试技巧.",
                "from": "来自大连",
                "zan": "3",
                "url": [
                    "http://awb.img1.xmtbang.com/cover201510/20151023/thumb/abdaa24b3aa742e880c743e49a516b78.jpg"
                ]
            }
        ]
    }
}

ps:对json的学习还应该进一步强化,慕课网有相关json相关课程
以上是首页json的模拟数据,主要分为三部分。下面我们创建相应的实体对象

package com.youdu.module.recommand;

import com.youdu.module.BaseModel;

/**
 * Created by renzhiqiang on 16/8/28.
 */
public class BaseRecommandModel extends BaseModel {
    //一定要保证我们的变量名字与我们json中的key一致
    public String ecode;
    public String emsg;
    public RecommandModel data;
}

而data也是也是一个json对象,所以我们的实体也要声明一个实体对象


下面的类对应我们的data中的数据,一个是head,是一个jsonobject,另外一个是list,jsonarray

package com.youdu.module.recommand;

import com.youdu.module.BaseModel;

import java.util.ArrayList;

/**
package com.youdu.module.recommand;

import com.youdu.module.BaseModel;

import java.util.ArrayList;

/**
 * *******************************************************
 *
 * @文件名称:RecommandModel.java
 * @文件作者:renzhiqiang
 * @创建时间:2015年7月9日 上午9:24:04
 * @文件描述:产品实体
 * @修改历史:2015年7月9日创建初始版本 ********************************************************
 */
public class RecommandModel extends BaseModel {
    /**
     * 分别对应我们json中的两个数据部分
     * 我们的工具会将我们的jsonarray转换成ArrayList,jsonobject转化为我们的实体对象
     */
    public ArrayList list;
    public RecommandHeadValue head;

}

list当中的泛型实体:

package com.youdu.module.recommand;

import com.youdu.module.BaseModel;
import com.youdu.module.monitor.Monitor;
import com.youdu.module.monitor.emevent.EMEvent;

import java.util.ArrayList;

/**
 * *******************************************************
 *
 * @文件名称:RecommandValue.java
 * @文件作者:renzhiqiang
 * @创建时间:2015年7月9日 上午9:24:04
 * @文件描述:搜索实体
 * @修改历史:2015年7月9日创建初始版本 ********************************************************
 */
public class RecommandBodyValue extends BaseModel {

    public int type;
    public String logo;
    public String title;
    public String info;
    public String price;
    public String text;
    public String site;
    public String from;
    public String zan;
    public ArrayList url;

    //视频专用
    public String thumb;
    public String resource;
    public String resourceID;
    public String adid;
    public ArrayList startMonitor;
    public ArrayList middleMonitor;
    public ArrayList endMonitor;
    public String clickUrl;
    public ArrayList clickMonitor;
    public EMEvent event;

}

以上的源码就不贴了。主要就是将对象的json转化成相应的实体。

你可能感兴趣的:(第5章 首页列表开发与测试-5-3 首页列表—上一小节回顾串讲)