public class IOUtils {
	/**
	 * 读取资源文件，将js方法以字符串方法返回
	 *
	 * @return
	 */
	public static String readFromFile(String filename) {
		// "js.txt"
		InputStream inStream = null;
		ByteArrayOutputStream outStream =null;
		try {
			inStream = UIUtils.getContext().getAssets().open(filename);
			outStream = new ByteArrayOutputStream();
			byte[] bytes = new byte[1024];
			int len = 0;
			while ((len = inStream.read(bytes)) > 0) {
				outStream.write(bytes, 0, len);
			}
			return outStream.toString();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			close(inStream);
			close(outStream);
		}
		return null;
	}

	/** 关闭流 */
	public static boolean close(Closeable io) {
		if (io != null) {
			try {
				io.close();
			} catch (IOException e) {
				LogUtils.e("IOUtils", e);
			}
		}
		return true;
	}
} public class LogUtils {
    /**
     * 日志输出级别NONE
     */
    public static final int LEVEL_NONE = 0;
    /**
     * 日志输出级别E
     */
    public static final int LEVEL_ERROR = 1;
    /**
     * 日志输出级别W
     */
    public static final int LEVEL_WARN = 2;
    /**
     * 日志输出级别I
     */
    public static final int LEVEL_INFO = 3;
    /**
     * 日志输出级别D
     */
    public static final int LEVEL_DEBUG = 4;
    /**
     * 日志输出级别V
     */
    public static final int LEVEL_VERBOSE = 5;

    /** 日志输出时的TAG */
//	private static String mTag = "LogUtils";
    /**
     * 是否允许输出log
     */
    private static int mDebuggable = LEVEL_DEBUG;

    /**
     * 以级别为 d 的形式输出LOG
     */
    public static void v(String tag, String msg) {
        if (mDebuggable >= LEVEL_VERBOSE) {
            Log.v(tag, msg);
        }
    }

    /**
     * 以级别为 d 的形式输出LOG
     */
    public static void d(String tag, String msg) {
        if (mDebuggable >= LEVEL_DEBUG) {
            Log.d(tag, msg);
        }
    }

    /**
     * 以级别为 i 的形式输出LOG
     */
    public static void i(String tag, String msg) {
        if (mDebuggable >= LEVEL_INFO) {
            Log.i(tag, msg);
        }
    }

    /**
     * 以级别为 w 的形式输出LOG
     */
    public static void w(String tag, String msg) {
        if (mDebuggable >= LEVEL_WARN) {
            Log.w(tag, msg);
        }
    }

    /**
     * 以级别为 w 的形式输出Throwable
     */
    public static void w(String tag, Throwable tr) {
        if (mDebuggable >= LEVEL_WARN) {
            Log.w(tag, "", tr);
        }
    }

    /**
     * 以级别为 w 的形式输出LOG信息和Throwable
     */
    public static void w(String tag, String msg, Throwable tr) {
        if (mDebuggable >= LEVEL_WARN && null != msg) {
            Log.w(tag, msg, tr);
        }
    }

    /**
     * 以级别为 e 的形式输出LOG
     */
    public static void e(String tag, String msg) {
        if (mDebuggable >= LEVEL_ERROR) {
            Log.e(tag, msg);
        }
    }

    /**
     * 以级别为 e 的形式输出Throwable
     */
    public static void e(String tag, Throwable tr) {
        if (mDebuggable >= LEVEL_ERROR) {
            Log.e(tag, "", tr);
        }
    }

    /**
     * 以级别为 e 的形式输出LOG信息和Throwable
     */
    public static void e(String tag, String msg, Throwable tr) {
        if (mDebuggable >= LEVEL_ERROR && null != msg) {
            Log.e(tag, msg, tr);
        }
    }
} public class ThreadManager {

	private static ThreadPool mThreadPool;

	/**
	 *  创建线程池，使用单例模式，在Applicaiton中初始化
	 * @return	返回线程池
     */
	public static ThreadPool getThreadPool() {
		if (mThreadPool == null) {
			synchronized (ThreadManager.class) {
				if (mThreadPool == null) {
					int cpuCount = Runtime.getRuntime().availableProcessors();// 获取cpu数量
					System.out.println("cup个数:" + cpuCount);

					// int threadCount = cpuCount * 2 + 1;//线程个数
					int threadCount = 10;
					mThreadPool = new ThreadPool(threadCount, threadCount, 1L);
				}
			}
		}

		return mThreadPool;
	}

	// 线程池
	public static class ThreadPool {

		private int corePoolSize;// 核心线程数
		private int maximumPoolSize;// 最大线程数
		private long keepAliveTime;// 休息时间

		private ThreadPoolExecutor executor;

		private ThreadPool(int corePoolSize, int maximumPoolSize,
				long keepAliveTime) {
			this.corePoolSize = corePoolSize;
			this.maximumPoolSize = maximumPoolSize;
			this.keepAliveTime = keepAliveTime;
		}


		public void execute(Runnable r) {
			if (executor == null) {
				executor = new ThreadPoolExecutor(corePoolSize,
						maximumPoolSize, keepAliveTime, TimeUnit.SECONDS,
						new LinkedBlockingQueue<Runnable>(),
						Executors.defaultThreadFactory(), new AbortPolicy());
				// 参1:核心线程数;参2:最大线程数;参3:线程休眠时间;参4:时间单位;参5:线程队列;参6:生产线程的工厂;参7:线程异常处理策略
			}

			// 线程池执行一个Runnable对象, 具体运行时机线程池说了算
			executor.execute(r);
		}

		// 取消任务
		public void cancel(Runnable r) {
			if (executor != null) {
				// 从线程队列中移除对象
				executor.getQueue().remove(r);
			}
		}

	}
} public class NewsDetailBean {
        private String body;
        private int replyCount;
        private String shareLink;
        private String digest;

        private String docid;
        private boolean picnews;
        private String title;
        private String tid;
        private String template;


        private String source;

        private String voicecomment;
        private String ptime;
        private List<?> users;
        private List<?> ydbaike;
        private List<LinkBean> link;
        private List<ImgBean> img;
        private List<VotesBean> votes;
        private List<TopiclistNewsBean> topiclist_news;
        private List<?> topiclist;
        private List<VideoBean> video;
        private List<?> boboList;


        public String getBody() {
            return body;
        }

        public void setBody(String body) {
            this.body = body;
        }

        public int getReplyCount() {
            return replyCount;
        }

        public void setReplyCount(int replyCount) {
            this.replyCount = replyCount;
        }

        public String getShareLink() {
            return shareLink;
        }

        public void setShareLink(String shareLink) {
            this.shareLink = shareLink;
        }

        public String getDigest() {
            return digest;
        }

        public void setDigest(String digest) {
            this.digest = digest;
        }



        public String getDocid() {
            return docid;
        }

        public void setDocid(String docid) {
            this.docid = docid;
        }

        public boolean isPicnews() {
            return picnews;
        }

        public void setPicnews(boolean picnews) {
            this.picnews = picnews;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getTid() {
            return tid;
        }

        public void setTid(String tid) {
            this.tid = tid;
        }

        public String getTemplate() {
            return template;
        }

        public void setTemplate(String template) {
            this.template = template;
        }



        public String getSource() {
            return source;
        }

        public void setSource(String source) {
            this.source = source;
        }



        public String getVoicecomment() {
            return voicecomment;
        }

        public void setVoicecomment(String voicecomment) {
            this.voicecomment = voicecomment;
        }

        public String getPtime() {
            return ptime;
        }

        public void setPtime(String ptime) {
            this.ptime = ptime;
        }

        public List<?> getUsers() {
            return users;
        }

        public void setUsers(List<?> users) {
            this.users = users;
        }

        public List<?> getYdbaike() {
            return ydbaike;
        }

        public void setYdbaike(List<?> ydbaike) {
            this.ydbaike = ydbaike;
        }

        public List<LinkBean> getLink() {
            return link;
        }

        public void setLink(List<LinkBean> link) {
            this.link = link;
        }

        public List<ImgBean> getImg() {
            return img;
        }

        public void setImg(List<ImgBean> img) {
            this.img = img;
        }

        public List<VotesBean> getVotes() {
            return votes;
        }

        public void setVotes(List<VotesBean> votes) {
            this.votes = votes;
        }

        public List<TopiclistNewsBean> getTopiclist_news() {
            return topiclist_news;
        }

        public void setTopiclist_news(List<TopiclistNewsBean> topiclist_news) {
            this.topiclist_news = topiclist_news;
        }

        public List<?> getTopiclist() {
            return topiclist;
        }

        public void setTopiclist(List<?> topiclist) {
            this.topiclist = topiclist;
        }

        public List<VideoBean> getVideo() {
            return video;
        }

        public void setVideo(List<VideoBean> video) {
            this.video = video;
        }



        public List<?> getBoboList() {
            return boboList;
        }

        public void setBoboList(List<?> boboList) {
            this.boboList = boboList;
        }


        public static class LinkBean {
            /**
             * ref : <!--link0-->
             * title : 你的小目标达成了吗？
             * imgsrc : http://cms-bucket.nosdn.127.net/4bba72ca129c45b2bea3038fe450ef6420161223202339.jpeg
             * digest : 距存够2W的小目标还差3W
             * type : linkCard
             * href : http://3g.163.com/news/16/1223/20/C90EQK7D000181BT.html
             */

            private String ref;
            private String title;
            private String imgsrc;
            private String digest;
            private String type;
            private String href;

            public String getRef() {
                return ref;
            }

            public void setRef(String ref) {
                this.ref = ref;
            }

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }

            public String getImgsrc() {
                return imgsrc;
            }

            public void setImgsrc(String imgsrc) {
                this.imgsrc = imgsrc;
            }

            public String getDigest() {
                return digest;
            }

            public void setDigest(String digest) {
                this.digest = digest;
            }

            public String getType() {
                return type;
            }

            public void setType(String type) {
                this.type = type;
            }

            public String getHref() {
                return href;
            }

            public void setHref(String href) {
                this.href = href;
            }
        }

        public static class ImgBean {
            /**
             * ref : <!--IMG#0-->
             * pixel : 690*692
             * alt :
             * src : http://cms-bucket.nosdn.127.net/c85eed9a823043249c9eeb99bca7f69e20161226084157.jpeg
             */

            private String ref;
            private String pixel;
            private String alt;
            private String src;

            public String getRef() {
                return ref;
            }

            public void setRef(String ref) {
                this.ref = ref;
            }

            public String getPixel() {
                return pixel;
            }

            public void setPixel(String pixel) {
                this.pixel = pixel;
            }

            public String getAlt() {
                return alt;
            }

            public void setAlt(String alt) {
                this.alt = alt;
            }

            public String getSrc() {
                return src;
            }

            public void setSrc(String src) {
                this.src = src;
            }
        }

        public static class VotesBean {
            /**
             * digest : 你们考过研吗？
             * date : 2016-12-26
             * url :
             * option_type : 0
             * date_type : 0
             * sumnum : 1109
             * docid :
             * ref : <!--@@PKVOTEID=58378-->
             * voteid : 58378
             * voteitem : [{"id":"247999","num":451,"name":"考过研，我当时____。"},{"id":"248000","num":658,"name":"没考过，想想都挺累。"}]
             * imgsrc :
             * voteType : pkVote
             * question : 你们考过研吗？
             */

            private String digest;
            private String date;
            private String url;
            private int option_type;
            private int date_type;
            private int sumnum;
            private String docid;
            private String ref;
            private String voteid;
            private String imgsrc;
            private String voteType;
            private String question;
            private List<VoteitemBean> voteitem;

            public String getDigest() {
                return digest;
            }

            public void setDigest(String digest) {
                this.digest = digest;
            }

            public String getDate() {
                return date;
            }

            public void setDate(String date) {
                this.date = date;
            }

            public String getUrl() {
                return url;
            }

            public void setUrl(String url) {
                this.url = url;
            }

            public int getOption_type() {
                return option_type;
            }

            public void setOption_type(int option_type) {
                this.option_type = option_type;
            }

            public int getDate_type() {
                return date_type;
            }

            public void setDate_type(int date_type) {
                this.date_type = date_type;
            }

            public int getSumnum() {
                return sumnum;
            }

            public void setSumnum(int sumnum) {
                this.sumnum = sumnum;
            }

            public String getDocid() {
                return docid;
            }

            public void setDocid(String docid) {
                this.docid = docid;
            }

            public String getRef() {
                return ref;
            }

            public void setRef(String ref) {
                this.ref = ref;
            }

            public String getVoteid() {
                return voteid;
            }

            public void setVoteid(String voteid) {
                this.voteid = voteid;
            }

            public String getImgsrc() {
                return imgsrc;
            }

            public void setImgsrc(String imgsrc) {
                this.imgsrc = imgsrc;
            }

            public String getVoteType() {
                return voteType;
            }

            public void setVoteType(String voteType) {
                this.voteType = voteType;
            }

            public String getQuestion() {
                return question;
            }

            public void setQuestion(String question) {
                this.question = question;
            }

            public List<VoteitemBean> getVoteitem() {
                return voteitem;
            }

            public void setVoteitem(List<VoteitemBean> voteitem) {
                this.voteitem = voteitem;
            }

            public static class VoteitemBean {
                /**
                 * id : 247999
                 * num : 451
                 * name : 考过研，我当时____。
                 */

                private String id;
                private int num;
                private String name;

                public String getId() {
                    return id;
                }

                public void setId(String id) {
                    this.id = id;
                }

                public int getNum() {
                    return num;
                }

                public void setNum(int num) {
                    this.num = num;
                }

                public String getName() {
                    return name;
                }

                public void setName(String name) {
                    this.name = name;
                }
            }
        }

        public static class TopiclistNewsBean {
            /**
             * hasCover : true
             * subnum : 超过1000万
             * alias : FUNNY MOMENT
             * tname : 轻松一刻
             * ename : qingsongyike
             * tid : T1350383429665
             * cid : C1348654575297
             */

            private boolean hasCover;
            private String subnum;
            private String alias;
            private String tname;
            private String ename;
            private String tid;
            private String cid;

            public boolean isHasCover() {
                return hasCover;
            }

            public void setHasCover(boolean hasCover) {
                this.hasCover = hasCover;
            }

            public String getSubnum() {
                return subnum;
            }

            public void setSubnum(String subnum) {
                this.subnum = subnum;
            }

            public String getAlias() {
                return alias;
            }

            public void setAlias(String alias) {
                this.alias = alias;
            }

            public String getTname() {
                return tname;
            }

            public void setTname(String tname) {
                this.tname = tname;
            }

            public String getEname() {
                return ename;
            }

            public void setEname(String ename) {
                this.ename = ename;
            }

            public String getTid() {
                return tid;
            }

            public void setTid(String tid) {
                this.tid = tid;
            }

            public String getCid() {
                return cid;
            }

            public void setCid(String cid) {
                this.cid = cid;
            }
        }

        public static class VideoBean {
            /**
             * commentid : C84JV7AL00964ILB
             * topicid : 0096
             * broadcast : in
             * videosource : 其他
             * commentboard : mobile_bbs
             * appurl :
             * mp4Hd_url : http://flv2.bn.netease.com/videolib3/1612/24/rbPOL1739/HD/rbPOL1739-mobile.mp4
             * url_m3u8 : http://flv2.bn.netease.com/videolib3/1612/24/rbPOL1739/SD/rbPOL1739-mobile.mp4
             * size :
             * ref : <!--VIDEO#0-->
             * cover : http://vimg2.ws.126.net/image/snapshot/2016/12/S/T/VC84JV4ST.jpg
             * url_mp4 : http://flv2.bn.netease.com/videolib3/1612/24/rbPOL1739/SD/rbPOL1739-mobile.mp4
             * alt : 年终策划视频《小时代之狗血2017》
             * mp4_url : http://flv2.bn.netease.com/videolib3/1612/24/rbPOL1739/SD/rbPOL1739-mobile.mp4
             * m3u8Hd_url : http://flv2.bn.netease.com/videolib3/1612/24/rbPOL1739/HD/movie_index.m3u8
             * m3u8_url : http://flv2.bn.netease.com/videolib3/1612/24/rbPOL1739/SD/movie_index.m3u8
             * vid : VC84JV7AL
             */

            private String commentid;
            private String topicid;
            private String broadcast;
            private String videosource;
            private String commentboard;
            private String appurl;
            private String mp4Hd_url;
            private String url_m3u8;
            private String size;
            private String ref;
            private String cover;
            private String url_mp4;
            private String alt;
            private String mp4_url;
            private String m3u8Hd_url;
            private String m3u8_url;
            private String vid;

            public String getCommentid() {
                return commentid;
            }

            public void setCommentid(String commentid) {
                this.commentid = commentid;
            }

            public String getTopicid() {
                return topicid;
            }

            public void setTopicid(String topicid) {
                this.topicid = topicid;
            }

            public String getBroadcast() {
                return broadcast;
            }

            public void setBroadcast(String broadcast) {
                this.broadcast = broadcast;
            }

            public String getVideosource() {
                return videosource;
            }

            public void setVideosource(String videosource) {
                this.videosource = videosource;
            }

            public String getCommentboard() {
                return commentboard;
            }

            public void setCommentboard(String commentboard) {
                this.commentboard = commentboard;
            }

            public String getAppurl() {
                return appurl;
            }

            public void setAppurl(String appurl) {
                this.appurl = appurl;
            }

            public String getMp4Hd_url() {
                return mp4Hd_url;
            }

            public void setMp4Hd_url(String mp4Hd_url) {
                this.mp4Hd_url = mp4Hd_url;
            }

            public String getUrl_m3u8() {
                return url_m3u8;
            }

            public void setUrl_m3u8(String url_m3u8) {
                this.url_m3u8 = url_m3u8;
            }

            public String getSize() {
                return size;
            }

            public void setSize(String size) {
                this.size = size;
            }

            public String getRef() {
                return ref;
            }

            public void setRef(String ref) {
                this.ref = ref;
            }

            public String getCover() {
                return cover;
            }

            public void setCover(String cover) {
                this.cover = cover;
            }

            public String getUrl_mp4() {
                return url_mp4;
            }

            public void setUrl_mp4(String url_mp4) {
                this.url_mp4 = url_mp4;
            }

            public String getAlt() {
                return alt;
            }

            public void setAlt(String alt) {
                this.alt = alt;
            }

            public String getMp4_url() {
                return mp4_url;
            }

            public void setMp4_url(String mp4_url) {
                this.mp4_url = mp4_url;
            }

            public String getM3u8Hd_url() {
                return m3u8Hd_url;
            }

            public void setM3u8Hd_url(String m3u8Hd_url) {
                this.m3u8Hd_url = m3u8Hd_url;
            }

            public String getM3u8_url() {
                return m3u8_url;
            }

            public void setM3u8_url(String m3u8_url) {
                this.m3u8_url = m3u8_url;
            }

            public String getVid() {
                return vid;
            }

            public void setVid(String vid) {
                this.vid = vid;
            }
        }

    @Override
    public String toString() {
        return "NewsDetailBean{" +
                "body='" + body + '\'' +
                '}';
    }
} public class Api {



    public static final String host = "http://c.m.163.com/";

    // 普通栏目前缀, 示例： http://c.m.163.com/nc/article/list/T1467284926140/0-20.html
    public static final String CommonUrl = host + "nc/article/list/";

    // 图片栏目的前缀， 示例： http://pic.news.163.com/photocenter/api/list/0031/6LRK0031,6LRI0031/0/20.json
    // 推荐图片：0031， 新闻图片： 0001 ， 明星图片：0003
    public static final String PictureUrl = "http://pic.news.163.com/photocenter/api/list/";

    // 特殊频道前缀：热点、网易号适用
    public static final String SpecialColumn1 = "recommend/getSubDocPic?";

    // 特殊频道前缀:	视频/段子、美女、萌宠适用
    public static final String SpecialColumn2 = "recommend/getChanListNews?channel=";
    // 文章详情前缀
    public static final String DetailUrl = host + "nc/article/";

    // 普通新闻栏目的结尾，注意要在前面添加新闻从那一条开始获取
    // 如 ：http://c.m.163.com/nc/article/list/T1467284926140/0-20.html，获取最新的20条新闻
    // http://c.m.163.com/nc/article/list/T1467284926140/20-20.html，获取从第20条开始的后面20条新闻
    public static final String endUrl = "-20.html";

    // 所有特殊频道的结尾，如：热点、网易号、段子、美女、萌宠
    public static final String SpecialendUrl = "&size=10&offset=";

    /**
     * 新闻文章详情页链接尾部
     * 示例：http://c.m.163.com/nc/article/C8T2G5QL0511A99L/full.html
     * 其中postId ：C8T2G5QL0511A99L
     */
    public static final String endDetailUrl = "/full.html";

    /**
     * 图片新闻详情页连接
     * 链接示例： http://c.m.163.com/photo/api/set/0031/13897.json
     * 图片详情页：0031为图片频道（列表连接后面的0031），13897为图片新闻setid
     */
    public static final String PictureDetailUrl = host + "photo/api/set/";
    // 图片新闻详情页结尾
    public static final String endPictureDetailUrl = ".json";


    /**
     * 视频详情链接
     *  示例： http://c.m.163.com/nc/video/detail/VC5BA022H.html
     *  其中VC5BA022H是视频的vid
     */
    public static final String videoDetailUrl = host + "nc/video/detail/";
    // 视频详情链接尾部
    public static final String EndUrlVideoDetailUrl = ".html";


    // 独家
    public static final String zhenhuaId = "T1370583240249";

    // NBA
    public static final String NBAId = "T1348649145984";

    // 头条
    public static final String toutiaoId = "T1348647909107";

    // 社会
    public static final String shehuiId = "T1348648037603";

    // 历史
    public static final String lishiId = "T1368497029546";

    // 军事
    public static final String junshiId = "T1348648141035";

    // 哒哒趣闻
    public static final String dadaId = "T1444289532601";

    // 航空
    public static final String aviationId = "T1474271789612";

    // 要闻
    public static final String yaowenspecialId = "T1467284926140";

    // 娱乐
    public static final String yuleId = "T1348648517839";

    // 影视歌
    public static final String dianyingId = "T1348648650048";

    // 财经
    public static final String caijingId = "T1348648756099";

    // 股票
    public static final String stockId = "T1473054348939";

    // 彩票
    public static final String caipiaoId = "T1356600029035";

    // 体育
    public static final String tiyuId = "T1348649079062";

    // 中国足球
    public static final String zhongchaoId = "T1348649503389";

    // 国际足球
    public static final String zuqiuId = "T1348649176279";

    // CBA
    public static final String CBAId = "T1348649475931";

    // 跑步
    public static final String paobuId = "T1411113472760";

    // 科技
    public static final String kejiId = "T1348649580692";

    // 手机
    public static final String shoujiId = "T1348649654285";

    // 数码
    public static final String shumaId = "T1348649776727";

    // 智能
    public static final String zhinengId = "T1351233117091";

    // 轻松一刻
    public static final String qingsongyikeId = "T1350383429665";

    // 云课堂
    public static final String gongkaikeId = "T1421997195219";

    // 态度公开课
    public static final String attitudeopenId = "T1456394562871";

    // 汽车
    public static final String qicheId = "T1348654060988";

    // 房产
    public static final String fangchanId = "T1348654085632";

    // 家居
    public static final String jiajuId = "T1348654105308";

    // 游戏
    public static final String youxiId = "T1348654151579";

    // 旅游
    public static final String lvyouId = "T1348654204705";

    // 健康
    public static final String jiankangId = "T1414389941036";

    // 读书
    public static final String dushuId = "T1401272877187";

    // 酒香
    public static final String jiuxiangId = "T1385429690972";

    // 教育
    public static final String jiaoyuId = "T1348654225495";

    // 亲子
    public static final String qinziId = "T1397116135282";

    // 暴雪游戏
    public static final String baoxueId = "T1397016069906";

    // 漫画
    public static final String manhuaId = "T1444270454635";

    // 二次元
    public static final String erciyuanlanmuId = "T1481105123675";

    // 态度营销
    public static final String taiduyingxiaoId = "T1464592736048";

    // 时尚
    public static final String nvrenId = "T1348650593803";

    // 情感
    public static final String qingganId = "T1348650839000";

    // 政务
    public static final String zhengwuId = "T1414142214384";

    // 艺术
    public static final String ArtId = "T1441074311424";

    // 阳光法院
    public static final String yangguangfayuanId = "T1482470888760";

    // 跟贴
    public static final String specialCommentId = "T1419315959525";

    // 海外
    public static final String zongheId = "T1462426218632";


    // 本地   暂不使用
    public static final String specialLocalId = "T1419316531256";

    // 博客
    public static final String specialBlogId = "T1419386532423";

    // 论坛
    public static final String specialBBSId = "T1419386592923";


    // 直播
    public static final String specialLiveId = "T1433137697241";


    // 图片新闻尾部，需要在签名添加参数，可获得从某条新闻之后的20条新闻
    // 示例 ： http://pic.news.163.com/photocenter/api/list/0001/00AN0001,00AO0001/0/20.json
    public static final String endPicture = "/20.json";
    // 图片
    public static final String specialPictureId = "T1419316384474";

    // 推荐图片：0031/6LRK0031,6LRI0031/    应使用瀑布流
    public static final String RecommendPictureId = "0031";
    public static final String RecommendPicture = "/6LRK0031,6LRI0031/";

    // 新闻图片：0001/00AP0001,3R710001,4T8E0001/    横向排版
    public static final String NewsPictureId = "0001";
    public static final String NewsPicture = "/00AP0001,3R710001,4T8E0001/";
    // 热点图片：0001/00AN0001,00AO0001/     横向排版
    public static final String HotPicture = "/00AN0001,00AO0001/";

    // 明星图片：0003/00AJ0003,0AJQ0003,3LF60003,00B70003,00B50003/      瀑布流排版
    public static final String StarPictureId = "0003";
    public static final String StarPicture = "/00AJ0003,0AJQ0003,3LF60003,00B70003,00B50003/";



    /**
     *   特殊格式新闻：
     *   下面几类连接基本一致：
     *   热点、网易号类的新闻连接形式差不多，但是网易号多了from参数
     *   使用getSubDocPic
     *
     *   段子、美女、萌宠连接基本一致
     *   使用	getChanListNews
     **/
    // 热点
    public static final String specialRedianId = "T1427878984398";
    // 热点url
    public static final String RedianUrl = host + SpecialColumn1 + SpecialendUrl;

    // 网易号
    public static final String specialSubId = "T1449126525962";
    // 网易号url
    public static final String WangYiHaoUrl = host + SpecialColumn1 + "from=netease_h" +SpecialendUrl;

    // 下列为特殊频道URL， 统一连接形式为：
    // http://c.m.163.com/recommend/getChanListNews?channel=T1419316284722&size=10&offset=
    public static final String specialURL = host + SpecialColumn2;

    // 视频
    // http://c.m.163.com/recommend/getChanListNews?channel=T1457068979049&offset=0&size=20&devId=44t6%2B5mG3ACAOlQOCLuIHg%3D%3D
    public static final String specialVideoId = "T1457068979049";
    // 手机开发id号，任意手机的开发Id号都可以
    public static final String devId = "&devId=44t6%2B5mG3ACAOlQOCLuIHg%3D%3D";

    // 段子
    public static final String specialJokeId = "T1419316284722";

    // 美女
    public static final String specialGirlId = "T1456112189138";

    // 萌宠
    public static final String specialAnimalId = "T1456112438822";

    // 热点视频 http://c.m.163.com/nc/video/list/V9LG4B3A0/n/10-10.html
    public static final String Video = host + "nc/video/list/";
    public static final String VideoCenter = "/n/";
    public static final String videoEndUrl = "-20.html";
    // 热点视频
    public static final String VideoReDianId = "V9LG4B3A0";
    // 推荐视频
    // http://c.m.163.com/recommend/getChanListNews?channel=T1457068979049&offset=0&size=20&devId=44t6%2B5mG3ACAOlQOCLuIHg%3D%3D
    public static final String VideorecommendId = "T1457068979049";
    // 搞笑视屏 http://c.m.163.com/nc/video/list/VAP4BFE3U/y/10-10.html
    // 美女视频 http://c.m.163.com/nc/video/list/VAP4BG6DL/y/0-10.html
    // 新闻现场 http://c.m.163.com/nc/video/list/VAV3H6JSN/y/0-10.html
    // 萌物 http://c.m.163.com/nc/video/list/VAP4BFR16/y/0-10.html
    // 黑科技  http://c.m.163.com/nc/video/list/VBF8F2PKF/y/0-10.html
    // 二次元 http://c.m.163.com/nc/video/list/VBF8F1PSA/y/0-10.html
    // 涨姿势  http://c.m.163.com/nc/video/list/VBF8F3SGL/y/0-10.html
    //直播视
    public static final String VideoLive = "http://data.live.126.net/livechannel/previewlist.json";



} public interface DefineView {
	
   public void initView();  //初始化界面元素
   public void initValidata();  //初始化变量
   public void initListener();  //初始化监听器
   public void bindData();       //绑定数据
   
//   public void getPageData();// show page
//   public void getDataOk();  // data ok
//   public void getDataError();// data error
//   public void getDataRefresh();// data refresh
   
} public class DataParse {

    // 新闻列表解析
    public static ArrayList<NewsListNormalBean> NewsList(String json, String id) {
        // Gson, JsonObject
        // 使用JsonObject解析方式: 如果遇到{},就是JsonObject;如果遇到[], 就是JsonArray
        if (json != null) {
            JSONObject jsonObject = null;
            ArrayList<NewsListNormalBean> newsListNormalBeans = new ArrayList<>();
            try {
                jsonObject = new JSONObject(json);
                JSONArray array = jsonObject.getJSONArray(id);
                Gson gson = new Gson();
                for (int i = 0; i < array.length(); i++) {
                    String js = array.get(i).toString();
                    NewsListNormalBean newsListNormalBean = gson.fromJson(js, NewsListNormalBean.class);
                    newsListNormalBeans.add(newsListNormalBean);
                }
                return newsListNormalBeans;
            } catch (JSONException e) {
                e.printStackTrace();
                LogUtils.d(TAG, "parseJson: 数据解析错误");
            }
        } else {
            LogUtils.d(TAG, "parseData: 没有数据");
        }
        return null;
    }


    /**
     *  新闻详情页解析
     * @param result
     * @param tid
     * @return
     */
    public static NewsDetailBean NewsDetail(String result, String tid) {
        if (result != null) {
            JSONObject jsonObject = null;
            NewsDetailBean newsDetailBean;
            try {
                jsonObject = new JSONObject(result);
                String detail = jsonObject.getJSONObject(tid).toString();
                Gson gson = new Gson();
                newsDetailBean = gson.fromJson(detail, NewsDetailBean.class);
                return newsDetailBean;
            } catch (JSONException e) {
                e.printStackTrace();
                LogUtils.d(TAG, "parseJson: 数据解析错误");
            }
        } else {
            LogUtils.d(TAG, "parseData: 没有数据");
        }
        return null;
    }

    /**
     * 图片列表解析
     * @param result
     * @return
     */
    public static ArrayList<PicListBean> PicList(String result) {
        LogUtils.d("图片返回的数据", "parseData: " + result);
        ArrayList<PicListBean> PicListBeans = new ArrayList<>();
        Gson gson = new Gson();
        try {
            JSONArray jsonArray = new JSONArray(result);
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                PicListBean picListbean = gson.fromJson(jsonObject.toString(), PicListBean.class);
                PicListBeans.add(picListbean);
            }
            return PicListBeans;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     * 图片新闻详情页解析
     * @param result
     * @return
     */
    public static ImageDetailBean ImageDetail(String result) {
        ImageDetailBean imageDetailBean = null;
        if (result != null) {
            Gson gson = new Gson();
            imageDetailBean = gson.fromJson(result, ImageDetailBean.class);
            LogUtils.d(TAG, "parseJson: 数据解析成功");
        } else {
            LogUtils.d(TAG, "parseData: 没有数据");
        }
        return imageDetailBean;
    }

    /**
     * 视频列表解析
     * @param result
     * @return
     */
    public static ArrayList<VideoBean> VideoList(String result) {
        if (result != null) {
            JSONObject jsonObject = null;
            ArrayList<VideoBean> videoBeen = new ArrayList<>();
            try {
                jsonObject = new JSONObject(result);
                JSONArray array = jsonObject.getJSONArray("视频");
                Gson gson = new Gson();
                for (int i = 0; i < array.length(); i++) {
                    String js = array.get(i).toString();
                    VideoBean vieoBean = gson.fromJson(js, VideoBean.class);
                    videoBeen.add(vieoBean);
                }
                return videoBeen;
            } catch (JSONException e) {
                e.printStackTrace();
                LogUtils.d(TAG, "parseJson: 数据解析错误");
            }
        } else {
            LogUtils.d(TAG, "parseData: 没有数据");
        }
        return null;
    }

    /**
     * 视频详情页解析
     * @param result
     * @return
     */
    public static VideoBean VideoDetail(String result) {
        VideoBean bean = null;
        if (result != null) {
            Gson gson = new Gson();
            bean = gson.fromJson(result, VideoBean.class);
            LogUtils.d(TAG, "parseData: " + bean);
        }
        return bean;
    }
} public interface HttpCallbackListener {
    void onSuccess(String result);
    void onError(Exception e);
} @SuppressWarnings("deprecated")
public class HttpHelper {

    private static final String TAG = HttpHelper.class.getSimpleName();

    /**
     * get请求，获取返回字符串内容
     */
    public static void get(String url, HttpCallbackListener httpCallbackListener) {
        HttpGet httpGet = new HttpGet(url);
        execute(url, httpGet, httpCallbackListener);
    }

    /**
     * post请求，获取返回字符串内容
     */
    public static void post(String url, byte[] bytes, HttpCallbackListener httpCallbackListener) {
        HttpPost httpPost = new HttpPost(url);
        ByteArrayEntity byteArrayEntity = new ByteArrayEntity(bytes);
        httpPost.setEntity(byteArrayEntity);
        execute(url, httpPost, httpCallbackListener);
    }

    /**
     * 下载
     */
    public static void download(String url, HttpCallbackListener httpCallbackListener) {
        HttpGet httpGet = new HttpGet(url);
        execute(url, httpGet, httpCallbackListener);
    }

    /**
     * 执行网络访问
     */
    private static void execute(String url, HttpRequestBase requestBase, HttpCallbackListener httpCallbackListener) {
        boolean isHttps = url.startsWith("https://");//判断是否需要采用https
        AbstractHttpClient httpClient = HttpClientFactory.create(isHttps);
        HttpContext httpContext = new SyncBasicHttpContext(new BasicHttpContext());
        HttpRequestRetryHandler retryHandler = httpClient.getHttpRequestRetryHandler();//获取重试机制
        int retryCount = 0;
        boolean retry = true;
        while (retry) {
            try {
                HttpResponse response = httpClient.execute(requestBase, httpContext);//访问网络
                int stateCode  = response.getStatusLine().getStatusCode();
//                LogUtils.e(TAG, "http状态码：" + stateCode);
                if (response != null) {
                    if (stateCode == HttpURLConnection.HTTP_OK){
                        HttpResult httpResult = new HttpResult(response, httpClient, requestBase);
                        String result = httpResult.getString();
                        if (!TextUtils.isEmpty(result)){
                            httpCallbackListener.onSuccess(result);
                            return;
                        } else {
                            throw new RuntimeException("数据为空");
                        }
                    } else {
                        throw new RuntimeException(HttpRequestCode.ReturnCode(stateCode));
                    }
                }
            } catch (Exception e) {
                IOException ioException = new IOException(e.getMessage());
                retry = retryHandler.retryRequest(ioException, ++retryCount, httpContext);//把错误异常交给重试机制，以判断是否需要采取从事
                LogUtils.e(TAG, "重复次数：" + retryCount + "   :"+ e);
                if (!retry){
                    httpCallbackListener.onError(e);
                }
            }
        }
    }

    /**
     * http的返回结果的封装，可以直接从中获取返回的字符串或者流
     */
    public static class HttpResult {
        private HttpResponse mResponse;
        private InputStream mIn;
        private String mStr;
        private HttpClient mHttpClient;
        private HttpRequestBase mRequestBase;

        public HttpResult(HttpResponse response, HttpClient httpClient, HttpRequestBase requestBase) {
            mResponse = response;
            mHttpClient = httpClient;
            mRequestBase = requestBase;
        }

        public int getCode() {
            StatusLine status = mResponse.getStatusLine();
            return status.getStatusCode();
        }


        /**
         * 从结果中获取字符串，一旦获取，会自动关流，并且把字符串保存，方便下次获取
         */
        public String getString() {
            if (!StringUtils.isEmpty(mStr)) {
                return mStr;
            }
            InputStream inputStream = getInputStream();
            ByteArrayOutputStream out = null;
            if (inputStream != null) {
                try {
                    out = new ByteArrayOutputStream();
                    byte[] buffer = new byte[1024 * 4];
                    int len = -1;
                    while ((len = inputStream.read(buffer)) != -1) {
                        out.write(buffer, 0, len);
                    }
                    byte[] data = out.toByteArray();
                    mStr = new String(data, "utf-8");
                } catch (Exception e) {
                    LogUtils.e(TAG, e);
                } finally {
                    IOUtils.close(out);
                    close();
                }
            }
            return mStr;
        }

        /**
         * 获取流，需要使用完毕后调用close方法关闭网络连接
         */
        public InputStream getInputStream() {
            if (mIn == null && getCode() < 300) {
                HttpEntity entity = mResponse.getEntity();
                try {
                    mIn = entity.getContent();
                } catch (Exception e) {
                    LogUtils.e(TAG, e);
                }
            }
            return mIn;
        }

        /**
         * 关闭网络连接
         */
        public void close() {
            if (mRequestBase != null) {
                mRequestBase.abort();
            }
            IOUtils.close(mIn);
            if (mHttpClient != null) {
                mHttpClient.getConnectionManager().closeExpiredConnections();
            }
        }
    }
} public class LoadingPage extends FrameLayout {

    private final String TAG = LoadingPage.class.getSimpleName();

    private ResultState mCurrentState = ResultState.STATE_UNLOAD;// 当前状态

    private View mLoadingView;
    private View mErrorView;
    private View mEmptyView;
    private View mSuccessView;

    private Context mContext;
    private LoadingClickListener loadingClickListener;

    public LoadingPage(Context context) {
        this(context, null);
    }

    public LoadingPage(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public LoadingPage(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    /**
     * 初始化布局
     */
    private void initView() {
        // 正在加载
        if (mLoadingView == null) {
            mLoadingView = onCreateLoadingView();
            addView(mLoadingView);
        }

        // 加载失败
        if (mErrorView == null) {
            mErrorView = onCreateErrorView();
            // 点击重试
            mErrorView.findViewById(R.id.btn_retry).setOnClickListener(
                    new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            if (loadingClickListener != null) {
                                loadingClickListener.clickListener();
                            }
                        }
                    });
            addView(mErrorView);
        }

        // 数据为空
        if (mEmptyView == null) {
            mEmptyView = onCreateEmptyView();
            addView(mEmptyView);
        }

        showRightPage();
    }

    /**
     * 根据当前状态,展示正确页面
     */
    private void showRightPage() {
        if (mLoadingView != null) {
            mLoadingView
                    .setVisibility((mCurrentState == ResultState.STATE_LOADING || mCurrentState == ResultState.STATE_UNLOAD) ? View.VISIBLE
                            : View.GONE);
        }

        if (mEmptyView != null) {
            mEmptyView
                    .setVisibility(mCurrentState == ResultState.STATE_EMPTY ? View.VISIBLE
                            : View.GONE);
        }

        if (mErrorView != null) {
            mErrorView
                    .setVisibility(mCurrentState == ResultState.STATE_ERROR ? View.VISIBLE
                            : View.GONE);
        }

    }

    /**
     * 初始化正在加载布局
     */
    private View onCreateLoadingView() {

        return LayoutInflater.from(mContext).inflate(R.layout.page_loading, null);
    }

    /**
     * 初始化加载失败布局
     */
    private View onCreateErrorView() {
        return LayoutInflater.from(mContext).inflate(R.layout.page_error, null);
    }

    /**
     * 初始化数据为空布局
     */
    private View onCreateEmptyView() {
        return LayoutInflater.from(mContext).inflate(R.layout.page_empty, null);
    }

    public void setLoadingView(){
        setCurrentState(ResultState.STATE_LOADING);
        refreshView();
    }

    public void setErrorView(){
        setCurrentState(ResultState.STATE_ERROR);
        refreshView();
    }

    public void setEmptyView(){
        setCurrentState(ResultState.STATE_EMPTY);
        refreshView();
    }

    public void setSuccessView(){
        setCurrentState(ResultState.STATE_SUCCESS);
        refreshView();
    }

    public void setLoadingClickListener(LoadingClickListener buttonClickListener) {
        this.loadingClickListener = buttonClickListener;
    }

    public void setCurrentState(ResultState currentState) {
        this.mCurrentState = currentState;
    }

    public ResultState getCurrentState() {
        return mCurrentState;
    }

    public void refreshView() {
        mCurrentState = getCurrentState();
        showRightPage();
    }

    /**
     * 使用枚举表示访问网络的几种状态
     */
    public enum ResultState {
        STATE_UNLOAD,    // 尚未开始加载数据的时候
        STATE_LOADING,    // 正在加载数据
        STATE_SUCCESS, // 访问成功
        STATE_EMPTY, // 数据为空
        STATE_ERROR;// 访问失败
    }

    public interface LoadingClickListener {
        void clickListener();
    }

}
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.text.TextPaint;
import android.util.Log;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.List;
import cn.bproject.neteasynews.R;
import cn.bproject.neteasynews.Utils.IOUtils;
import cn.bproject.neteasynews.Utils.LogUtils;
import cn.bproject.neteasynews.Utils.ThreadManager;
import cn.bproject.neteasynews.bean.NewsDetailBean;
import cn.bproject.neteasynews.common.Api;
import cn.bproject.neteasynews.common.DefineView;
import cn.bproject.neteasynews.http.DataParse;
import cn.bproject.neteasynews.http.HttpCallbackListener;
import cn.bproject.neteasynews.http.HttpHelper;
import cn.bproject.neteasynews.widget.LoadingPage;
import static cn.bproject.neteasynews.R.id.details_content;
package cn.bproject.neteasynews.activity;





/**
 * Created by liaozhoubei on 2016/12/28.
 */

public class NewsDetailActivity extends BaseActivity implements DefineView {
    private final String TAG = NewsDetailActivity.class.getSimpleName();
    private TextView details_title, details_name, details_time;
    private Context mContext;
    private WebView mWebView;
    private ThreadManager.ThreadPool mThreadPool;   // 线程池

    private WebSettings mWebSettings;

    private SharedPreferences sharedPreferences;

    private String mDocid;
    private NewsDetailBean mNewsDetailBeen;
    private LinearLayout mPage_content;
    private LoadingPage mLoadingPage;