public class NewsDALManager {

    // 资讯列表回调接口
    public static interface NewsListCallback {
        // 成功加载到数据
        public abstract void onSuccess(JSONArray jsonArray);

        // 加载数据失败
        public abstract void onError(String tipString);
    }

    // 资讯详情回调接口
    public static interface NewsContentCallback {
        // 成功加载到数据
        public abstract void onSuccess(JSONObject jsonObject);

        // 加载数据失败
        public abstract void onError(String tipString);
    }

    private static final String TAG = "NewsDALManager";

    // 单例对象
    public static final NewsDALManager shared = new NewsDALManager();

    private NewsDALManager() {
    }

    /**
     * 清除所有缓存
     */
    public void clearCache() {
        DataSupport.deleteAll(NewsListHomeCache.class);
        DataSupport.deleteAll(NewsListOtherCache.class);
        DataSupport.deleteAll(NewsContentCache.class);
    }

    /**
     * 移除指定分类的列表数据
     * 今日头条的数据和其他分类的数据不是存在一张表里的，需要判断下哦
     * 资讯内容数据基本固定，可以根据需求写个过期清理
     *
     * @param classid 分类id
     */
    public void removeNewsList(String classid) {
        if (classid.equals("0")) {
            // 今日头条
            int deleteCount = DataSupport.deleteAll(NewsListHomeCache.class);
            LogUtils.d(TAG, "删除了今日头条分类下 " + deleteCount + " 条记录");
        } else {
            // 其他分类
            int deleteCount = DataSupport.deleteAll(NewsListOtherCache.class);
            LogUtils.d(TAG, "删除了其他分类下 " + deleteCount + " 条记录");
        }
    }

    /**
     * 加载资讯列表数据
     *
     * @param table            数据表 news photo
     * @param classid          分类id
     * @param pageIndex        分页页码
     * @param newsListCallback 资讯列表回调
     */
    public void loadNewsList(final String table, final String classid, final int pageIndex, final NewsListCallback newsListCallback) {

        // 先从本地加载数据
        loadNewsListFromLocal(classid, pageIndex, new NewsListCallback() {

            // 数据加载成功
            @Override
            public void onSuccess(JSONArray jsonArray) {
                // 本地加载数据成功，就直接返回数据
                newsListCallback.onSuccess(jsonArray);
            }

            // 数据加载失败
            @Override
            public void onError(String tipString) {
                LogUtils.d(TAG, "加载本地列表数据失败 = " + tipString);
                // 从本地加载数据失败，就去网络加载
                loadNewsListFromNetwork(table, classid, pageIndex, new NewsListCallback() {
                    @Override
                    public void onSuccess(JSONArray jsonArray) {
                        // 返回给调用者
                        newsListCallback.onSuccess(jsonArray);

                        // 并缓存到本地
                        saveNewsList(classid, jsonArray);
                    }

                    @Override
                    public void onError(String tipString) {
                        newsListCallback.onError(tipString);
                    }
                });
            }
        });

    }

    /**
     * 加载资讯内容数据
     *
     * @param classid             分类id
     * @param id                  文章id
     * @param newsContentCallback 资讯内容回调
     */
    public void loadNewsContent(final String classid, final String id, final NewsContentCallback newsContentCallback) {

        loadNewsContentFromLocal(classid, id, new NewsContentCallback() {
            @Override
            public void onSuccess(JSONObject jsonObject) {
                newsContentCallback.onSuccess(jsonObject);
            }

            @Override
            public void onError(String tipString) {
                LogUtils.d(TAG, "加载本地内容数据失败 = " + tipString);
                loadNewsContentFromNetwork(classid, id, new NewsContentCallback() {
                    @Override
                    public void onSuccess(JSONObject jsonObject) {

                        // 返回给调用者
                        newsContentCallback.onSuccess(jsonObject);

                        // 并缓存到本地
                        saveNewsContent(classid, id, jsonObject);
                    }

                    @Override
                    public void onError(String tipString) {
                        newsContentCallback.onError(tipString);
                    }
                });
            }
        });

    }

    /**
     * 缓存资讯列表数据到本地数据库
     *
     * @param classid   分类id
     * @param jsonArray 资讯json数据
     */
    private void saveNewsList(String classid, JSONArray jsonArray) {

        for (int i = 0; i < jsonArray.length(); i++) {
            try {
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                if (classid.equals("0")) {
                    // 今日头条 分类
                    NewsListHomeCache homeCache = new NewsListHomeCache();
                    homeCache.setClassid(jsonObject.getString("classid"));
                    homeCache.setNews(jsonObject.toString());
                    homeCache.save();
                } else {
                    NewsListOtherCache otherCache = new NewsListOtherCache();
                    otherCache.setClassid(jsonObject.getString("classid"));
                    otherCache.setNews(jsonObject.toString());
                    otherCache.save();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        LogUtils.d(TAG, "缓存资讯列表数据成功" + jsonArray.toString());
    }

    /**
     * 从本地缓存加载资讯数据列表
     *
     * @param classid          分类id
     * @param pageIndex        分页页码
     * @param newsListCallback 资讯列表回调
     */
    private void loadNewsListFromLocal(String classid, int pageIndex, final NewsListCallback newsListCallback) {

        int preCount = (pageIndex - 1) * 20;
        int oneCount = 20;

        LogUtils.d(TAG, "当前分页 = " + pageIndex);

        JSONArray jsonArray = new JSONArray();

        if (classid.equals("0")) {
            // 今日头条 分类
            List<NewsListHomeCache> homeCaches = DataSupport.order("id asc").limit(oneCount).offset(preCount).find(NewsListHomeCache.class);
            for (NewsListHomeCache homeCache :
                    homeCaches) {
                try {
                    JSONObject jsonObject = new JSONObject(homeCache.getNews());
                    jsonArray.put(jsonObject);
                } catch (JSONException e) {
                    e.printStackTrace();
                    newsListCallback.onError("数据解析失败");
                    break;
                }
            }
            if (jsonArray.length() > 0) {
                newsListCallback.onSuccess(jsonArray);
                LogUtils.d(TAG, "加载到缓存今日头条数据 = " + jsonArray.toString());
            } else {
                newsListCallback.onError("没有缓存数据");
            }
        } else {
            // 其他分类
            List<NewsListOtherCache> otherCaches = DataSupport.order("id asc").where("classid = ?", classid).limit(oneCount).offset(preCount).find(NewsListOtherCache.class);
            for (NewsListOtherCache otherCache :
                    otherCaches) {
                try {
                    JSONObject jsonObject = new JSONObject(otherCache.getNews());
                    jsonArray.put(jsonObject);
                } catch (JSONException e) {
                    e.printStackTrace();
                    newsListCallback.onError("数据解析失败");
                    break;
                }
            }
            if (jsonArray.length() > 0) {
                newsListCallback.onSuccess(jsonArray);
                LogUtils.d(TAG, "加载到缓存其他分类数据 = " + jsonArray.toString());
            } else {
                newsListCallback.onError("没有本地数据");
            }

        }

    }

    /**
     * 从网络加载资讯列表数据
     *
     * @param table            数据表
     * @param classid          分类id
     * @param pageIndex        分页页码
     * @param newsListCallback 资讯列表回调
     */
    private void loadNewsListFromNetwork(String table, String classid, int pageIndex, final NewsListCallback newsListCallback) {

        HashMap<String, String> parameters = new HashMap<>();
        parameters.put("table", table);
        parameters.put("classid", classid);
        parameters.put("pageIndex", String.valueOf(pageIndex));
        parameters.put("pageSize", String.valueOf(20));

        NetworkUtils.shared.get(APIs.ARTICLE_LIST, parameters, new NetworkUtils.StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                newsListCallback.onError("您的网络不给力哦");
            }

            @Override
            public void onResponse(String response, int id) {
                try {
                    // 如果所有接口响应格式是统一的，这些判断是可以封装在网络请求工具类里的哦
                    if (new JSONObject(response).getString("err_msg").equals("success")) {
                        JSONObject jsonObject = new JSONObject(response);
                        if (jsonObject.getString("data").equals("null")) {
                            newsListCallback.onError("没有更多数据了");
                        } else {
                            JSONArray jsonArray = jsonObject.getJSONArray("data");
                            LogUtils.d(TAG, "从网络请求资讯列表数据成功 " + jsonArray.toString());
                            newsListCallback.onSuccess(jsonArray);
                        }
                    } else {
                        String errorInfo = new JSONObject(response).getString("info");
                        newsListCallback.onError(errorInfo);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                    newsListCallback.onError("数据解析异常");
                }

            }
        });

    }

    /**
     * 缓存资讯内容数据到本地数据库
     *
     * @param classid    分类id
     * @param id         文章id
     * @param jsonObject 资讯内容json数据
     */
    private void saveNewsContent(String classid, String id, JSONObject jsonObject) {

        // 如果没有被缓存，则去缓存
        NewsContentCache newsContentCache = new NewsContentCache();
        newsContentCache.setClassid(classid);
        newsContentCache.setArticleid(id);
        newsContentCache.setNews(jsonObject.toString());
        newsContentCache.save();
        LogUtils.d(TAG, "缓存资讯内容数据成功" + jsonObject.toString());
    }

    /**
     * 从本地加载资讯内容数据
     *
     * @param classid             分类id
     * @param id                  文章id
     * @param newsContentCallback 资讯内容回调
     */
    private void loadNewsContentFromLocal(String classid, String id, NewsContentCallback newsContentCallback) {
        NewsContentCache contentCache = DataSupport.where("classid = ? and articleid = ?", classid, id).findFirst(NewsContentCache.class);
        if (contentCache != null) {
            try {
                JSONObject jsonObject = new JSONObject(contentCache.getNews());
                newsContentCallback.onSuccess(jsonObject);
                LogUtils.d(TAG, "加载到缓存资讯内容数据 = " + jsonObject.toString());
            } catch (JSONException e) {
                e.printStackTrace();
                newsContentCallback.onError("数据解析异常");
            }
        } else {
            newsContentCallback.onError("没有缓存数据");
        }
    }

    /**
     * 从网络加载资讯内容数据
     *
     * @param classid             分类id
     * @param id                  文章id
     * @param newsContentCallback 资讯内容回调
     */
    private void loadNewsContentFromNetwork(String classid, String id, final NewsContentCallback newsContentCallback) {

        HashMap<String, String> parameters = new HashMap<>();
        parameters.put("classid", classid);
        parameters.put("id", id);
        if (UserBean.isLogin()) {
            parameters.put("username", UserBean.shared().getUsername());
            parameters.put("userid", UserBean.shared().getUserid());
            parameters.put("token", UserBean.shared().getToken());
        }

        NetworkUtils.shared.get(APIs.ARTICLE_DETAIL, parameters, new NetworkUtils.StringCallback() {
            @Override
            public void onError(Call call, Exception e, int id) {
                newsContentCallback.onError("您的网络不给力哦");
            }

            @Override
            public void onResponse(String response, int id) {
                try {
                    JSONObject jsonObject = new JSONObject(response).getJSONObject("data");
                    LogUtils.d(TAG, "从网络请求资讯内容数据成功 " + jsonObject.toString());
                    newsContentCallback.onSuccess(jsonObject);
                } catch (JSONException e) {
                    e.printStackTrace();
                    newsContentCallback.onError("数据解析异常");
                }
            }
        });

    }

} public class ArticleDetailBean {

    // 顶贴数
    private String top;

    // 踩帖数
    private String down;

    // 文章标题
    private String title;

    // 发布时间戳
    private String newstime;

    // 文章内容
    private String newstext;

    // 文章url
    private String titleurl;

    // 文章id
    private String id;

    // 分类id
    private String classid;

    // 评论数量
    private String plnum;

    // 是否已经收藏 1收藏  0未收藏
    private String havefava;

    // 文章简介
    private String smalltext;

    // 标题图片
    private String titlepic;

    // 文章来源
    private String befrom;

    // 所有图片数组
    private List<InsetPhotoBean> allPhotoList;

    // 相关连接
    private List<ArticleDetailLinkBean> otherLinks;

    // 更多图片 - 图库
    private List<ArticleDetailPhotoBean> morePicsList;

    public ArticleDetailBean(JSONObject article) {
        try {
            top = article.getString("top");
            down = article.getString("down");
            title = article.getString("title");
            newstime = article.getString("newstime");
            newstext = article.getString("newstext");
            titleurl = article.getString("titleurl");
            id = article.getString("id");
            classid = article.getString("classid");
            plnum = article.getString("plnum");
            havefava = article.getString("havefava");
            smalltext = article.getString("smalltext");
            titlepic = article.getString("titlepic");
            befrom = article.getString("befrom");

            // 正文插图
            allPhotoList = new ArrayList<>();
            JSONArray allPhotoJsonArray = article.getJSONArray("allphoto");
            for (int i = 0; i < allPhotoJsonArray.length(); i++) {
                allPhotoList.add(new InsetPhotoBean(allPhotoJsonArray.getJSONObject(i)));
            }

            // 相关链接
            otherLinks = new ArrayList<>();
            JSONArray otherLinksJsonArray = article.getJSONArray("otherLink");
            for (int i = 0; i < otherLinksJsonArray.length(); i++) {
                otherLinks.add(new ArticleDetailLinkBean(otherLinksJsonArray.getJSONObject(i)));
            }

            // 图库图片
            morePicsList = new ArrayList<>();
            JSONArray morePicsListJsonArray = article.getJSONArray("morepic");
            for (int i = 0; i < morePicsListJsonArray.length(); i++) {
                morePicsList.add(new ArticleDetailPhotoBean(morePicsListJsonArray.getJSONObject(i)));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return "ArticleDetailBean{" +
                "top='" + top + '\'' +
                ", down='" + down + '\'' +
                ", title='" + title + '\'' +
                ", newstime='" + newstime + '\'' +
                ", titleurl='" + titleurl + '\'' +
                ", id='" + id + '\'' +
                ", classid='" + classid + '\'' +
                ", plnum='" + plnum + '\'' +
                ", havefava='" + havefava + '\'' +
                ", smalltext='" + smalltext + '\'' +
                ", titlepic='" + titlepic + '\'' +
                ", befrom='" + befrom + '\'' +
                ", allPhotoList=" + allPhotoList +
                ", otherLinks=" + otherLinks +
                ", morePicsList=" + morePicsList +
                ", newstext='" + newstext + '\'' +
                '}';
    }

    public void setPlnum(String plnum) {
        this.plnum = plnum;
    }

    public String getTop() {
        return top;
    }

    public String getDown() {
        return down;
    }

    public String getTitle() {
        return title;
    }

    public String getNewstime() {
        return newstime;
    }

    public String getNewstext() {
        return newstext;
    }

    public String getTitleurl() {
        return titleurl;
    }

    public String getId() {
        return id;
    }

    public String getClassid() {
        return classid;
    }

    public String getPlnum() {
        return plnum;
    }

    public String getHavefava() {
        return havefava;
    }

    public String getSmalltext() {
        return smalltext;
    }

    public String getTitlepic() {
        return titlepic;
    }

    public String getBefrom() {
        return befrom;
    }

    public List<InsetPhotoBean> getAllPhotoList() {
        return allPhotoList;
    }

    public List<ArticleDetailLinkBean> getOtherLinks() {
        return otherLinks;
    }

    public List<ArticleDetailPhotoBean> getMorePicsList() {
        return morePicsList;
    }

    // 正文插图
    public static class InsetPhotoBean implements Serializable {

        // 图片占位字符
        private String ref;

        // 图片描述
        private String caption;

        // 图片url
        private String url;

        // 宽度 - 这里的单位可以看成dip
        private int widthDip;

        // 高度 - 这里的单位可以看成dip
        private int heightDip;

        InsetPhotoBean(JSONObject photo) {
            try {
                ref = photo.getString("ref");
                caption = photo.getString("caption");
                url = photo.getString("url");
                widthDip = photo.getJSONObject("pixel").getInt("width");
                heightDip = photo.getJSONObject("pixel").getInt("height");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        public String getRef() {
            return ref;
        }

        public String getCaption() {
            return caption;
        }

        public String getUrl() {
            return url;
        }

        public int getWidthDip() {
            return widthDip;
        }

        public int getHeightDip() {
            return heightDip;
        }
    }

    public static class ArticleDetailPhotoBean {

        // 图片标题
        private String title;

        // 图片描述
        private String caption;

        // 小图url
        private String smallpic;

        // 图片url
        private String bigpic;

        ArticleDetailPhotoBean(JSONObject photo) {
            try {
                title = photo.getString("title");
                caption = photo.getString("caption");
                smallpic = photo.getString("smallpic");
                bigpic = photo.getString("bigpic");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        public String getTitle() {
            return title;
        }

        public String getCaption() {
            return caption;
        }

        public String getBigpic() {
            return bigpic;
        }

        public String getSmallpic() {
            return smallpic;
        }
    }

    public static class ArticleDetailLinkBean {

        // 分类id
        private String classid;

        // 文章id
        private String id;

        // 点击量
        private String onclick;

        // 标题
        private String title;

        private String titlepic;

        // 分类名称
        private String classname;

        ArticleDetailLinkBean(JSONObject linkArticle) {
            try {
                classid = linkArticle.getString("classid");
                id = linkArticle.getString("id");
                onclick = linkArticle.getString("onclick");
                title = linkArticle.getString("title");
                titlepic = linkArticle.getString("titlepic");
                classname = linkArticle.getString("classname");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        public String getClassid() {
            return classid;
        }

        public String getId() {
            return id;
        }

        public String getOnclick() {
            return onclick;
        }

        public String getTitle() {
            return title;
        }

        public String getTitlepic() {
            return titlepic;
        }

        public String getClassname() {
            return classname;
        }
    }

} public class CommentBean implements Serializable {

    // 楼层
    private String plstep;

    // 评论id
    private String plid;

    // 评论用户名
    private String plusername;

    // 评论昵称
    private String plnickname;

    // 评论id
    private String id;

    // 栏目id
    private String classid;

    // 赞数量
    private String zcnum;

    // 评论内容
    private String saytext;

    // 评论时间
    private String saytime;

    // 用户头像 需要拼接
    private String userpic;

    // 是否被赞过 - 默认没有
    private boolean isStar = false;

    public CommentBean(JSONObject jsonObject) {
        try {
            plstep = jsonObject.getString("plstep");
            plid = jsonObject.getString("plid");
            plusername = jsonObject.getString("plusername");
            plnickname = jsonObject.getString("plnickname");
            id = jsonObject.getString("id");
            classid = jsonObject.getString("classid");
            zcnum = jsonObject.getString("zcnum");
            saytext = jsonObject.getString("saytext");
            saytime = jsonObject.getString("saytime");
            userpic = jsonObject.getString("userpic");
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return "CommentBean{" +
                "plstep='" + plstep + '\'' +
                ", plid='" + plid + '\'' +
                ", plusername='" + plusername + '\'' +
                ", plnickname='" + plnickname + '\'' +
                ", id='" + id + '\'' +
                ", classid='" + classid + '\'' +
                ", zcnum='" + zcnum + '\'' +
                ", saytext='" + saytext + '\'' +
                ", saytime='" + saytime + '\'' +
                ", userpic='" + userpic + '\'' +
                '}';
    }

    public String getPlstep() {
        return plstep;
    }

    public String getPlid() {
        return plid;
    }

    public String getPlusername() {
        return plusername;
    }

    public String getPlnickname() {
        return plnickname;
    }

    public String getId() {
        return id;
    }

    public String getClassid() {
        return classid;
    }

    public String getZcnum() {
        return zcnum;
    }

    public String getSaytext() {
        return saytext;
    }

    public String getSaytime() {
        return saytime;
    }

    public String getUserpic() {
        return userpic;
    }

    public void setZcnum(String zcnum) {
        this.zcnum = zcnum;
    }

    public boolean isStar() {
        return isStar;
    }

    public void setStar(boolean star) {
        isStar = star;
    }
} public class UserBean {

    private static final String TAG = "UserBean";

    // 用户id
    private String userid;

    // token
    private String token;

    // 用户名
    private String username;

    // 昵称
    private String nickname;

    // email
    private String email;

    // 用户组
    private String groupName;

    // 注册时间
    private String registerTime;

    // 头像
    private String avatarUrl;

    // qq
    private String qq;

    // 电话号码
    private String phone;

    // 个性签名
    private String saytext;

    // 积分
    private String points;

    // 防止外界构建默认对象
    private UserBean() {
    }

    public UserBean(JSONObject jsonObject) {
        try {
            userid = jsonObject.getString("id");
            token = jsonObject.getString("token");
            username = jsonObject.getString("username");
            nickname = jsonObject.getString("nickname");
            email = jsonObject.getString("email");
            groupName = jsonObject.getString("groupName");
            registerTime = jsonObject.getString("registerTime");
            avatarUrl = jsonObject.getString("avatarUrl");
            qq = jsonObject.getString("qq");
            phone = jsonObject.getString("phone");
            saytext = jsonObject.getString("saytext");
            points = jsonObject.getString("points");
        } catch (JSONException e) {
            e.printStackTrace();
            LogUtils.d(TAG, "数据解析异常");
        }
    }

    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getRegisterTime() {
        return registerTime;
    }

    public void setRegisterTime(String registerTime) {
        this.registerTime = registerTime;
    }

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getSaytext() {
        return saytext;
    }

    public void setSaytext(String saytext) {
        this.saytext = saytext;
    }

    public String getPoints() {
        return points;
    }

    public void setPoints(String points) {
        this.points = points;
    }

    public static UserBean getUserAccount() {
        return userAccount;
    }

    public static void setUserAccount(UserBean userAccount) {
        UserBean.userAccount = userAccount;
    }

    // 防止重复去操作sp 把对象缓存到内存中
    private static UserBean userAccount = null;

    /**
     * 获取缓存的对象
     *
     * @return 用户信息模型
     */
    public static UserBean shared() {
        if (userAccount == null) {
            userAccount = new UserBean();
            userAccount.decode();
        }
        return userAccount;
    }

    /**
     * 是否已经登录
     *
     * @return true登录
     */
    public static boolean isLogin() {
        return !TextUtils.isEmpty(shared().token);
    }

    /**
     * 退出登录
     */
    public void logout() {
        UserBean.userAccount = null;
        SharedPreferences sp = BaoKanApp.getContext().getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        sp.edit().clear().apply();
    }

    /**
     * 从本地更新用户信息 - 登录成功后保存到偏好设置
     */
    public void updateUserInfoFromLocal() {

        // 移除第三方授权
        Platform weibo = ShareSDK.getPlatform(SinaWeibo.NAME);
        if (weibo.isAuthValid()) {
            weibo.removeAccount(true);
        }
        Platform qq = ShareSDK.getPlatform(QQ.NAME);
        if (qq.isAuthValid()) {
            qq.removeAccount(true);
        }

        // 内存缓存
        UserBean.userAccount = this;
        // 磁盘缓存
        encode();
    }

    // 更新用户信息状态监听
    public static class OnUpdatedUserInfoListener {
        public void onError(String tipString) {
        }

        public void onSuccess(UserBean userBean) {
        }
    }

    /**
     * 从网络更新用户信息
     */
    public static void updateUserInfoFromNetwork(final OnUpdatedUserInfoListener userInfoListener) {
        if (isLogin()) {
            HashMap<String, String> parameters = new HashMap<>();
            parameters.put("username", shared().username);
            parameters.put("userid", shared().userid);
            parameters.put("token", shared().token);
            NetworkUtils.shared.get(APIs.GET_USERINFO, parameters, new NetworkUtils.StringCallback() {
                @Override
                public void onError(Call call, Exception e, int id) {
                    userInfoListener.onError("您的网络不给力哦");
                }

                @Override
                public void onResponse(String response, int id) {
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        if (jsonObject.getString("err_msg").equals("success")) {
                            UserBean userBean = new UserBean(jsonObject.getJSONObject("data"));
                            // 将登录信息保存到数据库
                            userBean.updateUserInfoFromLocal();
                            userInfoListener.onSuccess(userBean);
                        } else {
                            String info = jsonObject.getString("info");
                            LogUtils.d(TAG, "更新用户信息失败" + info);
                            UserBean.shared().logout();
                            userInfoListener.onError(info);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                        userInfoListener.onError("数据解析异常");
                    }
                }
            });
        } else {
            userInfoListener.onError("未登录");
        }
    }

    /**
     * 编码
     */
    private void encode() {
        LogUtils.d(TAG, this.toString());
        SharedPreferences sp = BaoKanApp.getContext().getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("userid", userid);
        editor.putString("token", token);
        editor.putString("username", username);
        editor.putString("nickname", nickname);
        editor.putString("email", email);
        editor.putString("groupName", groupName);
        editor.putString("registerTime", registerTime);
        editor.putString("avatarUrl", avatarUrl);
        editor.putString("qq", qq);
        editor.putString("phone", phone);
        editor.putString("saytext", saytext);
        editor.putString("points", points);
        editor.apply();
    }

    /**
     * 解码
     */
    private void decode() {
        SharedPreferences sp = BaoKanApp.getContext().getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        userid = sp.getString("userid", "0");
        token = sp.getString("token", "");
        username = sp.getString("username", "");
        nickname = sp.getString("nickname", "");
        email = sp.getString("email", "");
        groupName = sp.getString("groupName", "");
        registerTime = sp.getString("registerTime", "");
        avatarUrl = sp.getString("avatarUrl", "");
        qq = sp.getString("qq", "");
        phone = sp.getString("phone", "");
        saytext = sp.getString("saytext", "");
        points = sp.getString("points", "");
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "userid='" + userid + '\'' +
                ", token='" + token + '\'' +
                ", username='" + username + '\'' +
                ", nickname='" + nickname + '\'' +
                ", email='" + email + '\'' +
                ", groupName='" + groupName + '\'' +
                ", registerTime='" + registerTime + '\'' +
                ", avatarUrl='" + avatarUrl + '\'' +
                ", qq='" + qq + '\'' +
                ", phone='" + phone + '\'' +
                ", saytext='" + saytext + '\'' +
                ", points='" + points + '\'' +
                '}';
    }
} public class CommentRecyclerViewAdapter extends RecyclerView.Adapter<CommentRecyclerViewAdapter.ViewHolder> {

    private static final String TAG = "CommentRecyclerViewAdap";

    public static interface OnCommentTapListener {
        // 点赞
        public abstract void onStarTap(CommentBean commentBean, int position);
    }

    private List<CommentBean> commentBeanList = new ArrayList<>();
    private Context mContext;
    private OnCommentTapListener commentTapListener;

    public CommentRecyclerViewAdapter(Context mContext) {
        this.mContext = mContext;
    }

    /**
     * 设置评论点击监听器
     *
     * @param commentTapListener 监听器
     */
    public void setOnCommentTapListener(OnCommentTapListener commentTapListener) {
        this.commentTapListener = commentTapListener;
    }

    /**
     * 更新数据
     *
     * @param newCommentBeanList 新数据
     * @param method             0下拉刷新 1上拉加载更多
     */
    public void updateData(List<CommentBean> newCommentBeanList, int method) {

        String maxId = "0";
        String minId = "0";
        if (commentBeanList != null && commentBeanList.size() > 0) {
            maxId = commentBeanList.get(0).getPlid();
            minId = commentBeanList.get(commentBeanList.size() - 1).getPlid();
        }

        if (method == 0) { // 下拉刷新
            if (maxId.compareTo(newCommentBeanList.get(0).getPlid()) <= -1) {
                // 替换数据
                commentBeanList.clear();
                commentBeanList.addAll(newCommentBeanList);

                // 刷新列表数据
                notifyDataSetChanged();
            }

        } else { // 上拉加载

            if (minId.compareTo(newCommentBeanList.get(0).getPlid()) >= 1) {
                // 拼接数据
                commentBeanList.addAll(newCommentBeanList);
                // 刷新列表数据
                notifyDataSetChanged();
            }
        }
    }

    @Override
    public int getItemCount() {
        return commentBeanList.size();
    }

    @Override
    public CommentRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.cell_news_detail_comment, parent, false);
        final CommentRecyclerViewAdapter.ViewHolder holder = new CommentRecyclerViewAdapter.ViewHolder(view);
        holder.starLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (commentTapListener != null) {
                    commentTapListener.onStarTap(commentBeanList.get(holder.getAdapterPosition()), holder.getAdapterPosition());
                }
            }
        });
        return holder;
    }

    @Override
    public void onBindViewHolder(CommentRecyclerViewAdapter.ViewHolder holder, int position) {
        CommentBean commentBean = commentBeanList.get(position);
        holder.portraitView.setImageURI(commentBean.getUserpic());
        holder.nicknameTextView.setText(commentBean.getPlnickname());
        holder.commentContentTextView.setText(commentBean.getSaytext());
        holder.timeTextView.setText(commentBean.getSaytime());
        holder.starNumTextView.setText(commentBean.getZcnum());
        holder.commentNumTextView.setText(commentBean.getPlstep());
        // 最后一个分割线隐藏
        if (position == commentBeanList.size() - 1 && commentBeanList.size() < 10) {
            holder.lineView.setVisibility(View.INVISIBLE);
        } else {
            holder.lineView.setVisibility(View.VISIBLE);
        }
        if (commentBean.isStar()) {
            holder.starImageView.setImageResource(R.drawable.comment_support_highlighted);
            holder.starNumTextView.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
        } else {
            holder.starImageView.setImageResource(R.drawable.comment_support);
            holder.starNumTextView.setTextColor(mContext.getResources().getColor(R.color.colorCommentGray));
        }

    }

    // 相关链接item基类
    class ViewHolder extends RecyclerView.ViewHolder {

        SimpleDraweeView portraitView;// 头像
        TextView nicknameTextView;    // 昵称
        TextView timeTextView;        // 时间
        TextView starNumTextView;     // 点赞数
        ImageView starImageView;      // 点赞图标
        TextView commentNumTextView;  // 楼层
        TextView commentContentTextView; // 评论内容
        LinearLayout starLayout;      // 赞
        View lineView;                // 分割线

        ViewHolder(View itemView) {
            super(itemView);
            portraitView = (SimpleDraweeView) itemView.findViewById(R.id.sdv_cell_news_detail_comment_portrait);
            nicknameTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_comment_name);
            timeTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_comment_time);
            starNumTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_comment_star_num);
            starImageView = (ImageView) itemView.findViewById(R.id.iv_cell_news_comment_star_image);
            commentNumTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_comment_num);
            commentContentTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_comment_content);
            lineView = itemView.findViewById(R.id.v_cell_news_detail_comment_line);
            starLayout = (LinearLayout) itemView.findViewById(R.id.ll_news_detail_comment_star);
        }
    }

} public class LinkRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private static final String TAG = "LinkRecyclerViewAdapter";

    // 相关链接item类型枚举
    private enum LINK_ITEM_TYPE {
        NO_TITLE_PIC, // 无图
        TITLE_PIC     // 有图
    }

    private List<ArticleDetailBean.ArticleDetailLinkBean> mLinkBeanList;
    private Context mContext;

    public LinkRecyclerViewAdapter(Context context, List<ArticleDetailBean.ArticleDetailLinkBean> linkBeanList) {
        this.mLinkBeanList = linkBeanList;
        this.mContext = context;
    }

    @Override
    public int getItemViewType(int position) {
        if (TextUtils.isEmpty(mLinkBeanList.get(position).getTitlepic()) || mLinkBeanList.get(position).getTitlepic().equals("null")) {
            LogUtils.d(TAG, "titlePic = " + mLinkBeanList.get(position).getTitlepic());
            return LINK_ITEM_TYPE.NO_TITLE_PIC.ordinal();
        } else {
            return LINK_ITEM_TYPE.TITLE_PIC.ordinal();
        }
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        final RecyclerView.ViewHolder holder;
        View view;
        if (viewType == LINK_ITEM_TYPE.NO_TITLE_PIC.ordinal()) {
            view = LayoutInflater.from(mContext).inflate(R.layout.cell_news_detail_link_notitlepic, parent, false);
            holder = new NoTitlePicViewHolder(view);
        } else {
            view = LayoutInflater.from(mContext).inflate(R.layout.cell_news_detail_link_titlepic, parent, false);
            holder = new TitlePicViewHolder(view);
        }
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int position = holder.getAdapterPosition();
                // 进入相关链接的正文页面
                NewsDetailActivity.start((NewsDetailActivity) mContext, mLinkBeanList.get(position).getClassid(), mLinkBeanList.get(position).getId());
            }
        });
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ArticleDetailBean.ArticleDetailLinkBean linkBean = mLinkBeanList.get(position);
        LinkBaseViewHolder baseViewHolder = (LinkBaseViewHolder) holder;
        baseViewHolder.titleTextView.setText(linkBean.getTitle());
        baseViewHolder.classNameTextView.setText(linkBean.getClassname());
        baseViewHolder.onclickTextView.setText(linkBean.getOnclick());
        if (holder instanceof TitlePicViewHolder) {
            TitlePicViewHolder titlePicViewHolder = (TitlePicViewHolder) holder;
            titlePicViewHolder.titlePicView.setImageURI(linkBean.getTitlepic());
        }
        // 最后一个分割线隐藏
        if (position == mLinkBeanList.size() - 1) {
            baseViewHolder.lineView.setVisibility(View.INVISIBLE);
        } else {
            baseViewHolder.lineView.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public int getItemCount() {
        return mLinkBeanList.size();
    }

    // 相关链接item基类
    class LinkBaseViewHolder extends RecyclerView.ViewHolder {

        TextView titleTextView;
        TextView classNameTextView;
        TextView onclickTextView;
        View lineView;
        View itemView;

        LinkBaseViewHolder(View itemView) {
            super(itemView);
            this.itemView = itemView;
            titleTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_link_title);
            classNameTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_link_classname);
            onclickTextView = (TextView) itemView.findViewById(R.id.tv_cell_news_detail_link_onclick);
            lineView = itemView.findViewById(R.id.v_cell_news_detail_link_line);
        }
    }

    // 无图的item
    private class NoTitlePicViewHolder extends LinkBaseViewHolder {

        NoTitlePicViewHolder(View itemView) {
            super(itemView);
        }
    }

    // 有图的item
    private class TitlePicViewHolder extends LinkBaseViewHolder {

        SimpleDraweeView titlePicView;

        TitlePicViewHolder(View itemView) {
            super(itemView);
            titlePicView = (SimpleDraweeView) itemView.findViewById(R.id.sdv_cell_news_detail_link_pic);
        }
    }

} public class APIs {

    // 基础url
    public static final String BASE_URL = "http://www.baokan.tv/";

    // 基础url
    public static final String API_URL = BASE_URL + "e/bpi/";

    // 版本更新
    public static final String UPDATE =  API_URL + "update.php";

    // 分类
    public static final String GET_CLASS = API_URL + "getNewsClass.php";

    // 文章列表
    public static final String ARTICLE_LIST = API_URL + "getNewsList.php";

    // 文章详情
    public static final String ARTICLE_DETAIL = API_URL + "getNewsContent.php";

    // 获取评论信息
    public static final String GET_COMMENT = API_URL + "getNewsComment.php";

    // 提交评论
    public static final String SUBMIT_COMMENT = API_URL + "subPlPost.php";

    // 顶贴踩贴
    public static final String TOP_DOWN = API_URL + "DoForPl.php";

    // 注册
    public static final String REGISTER = API_URL + "Register.php";

    // 登录
    public static final String LOGIN = API_URL + "loginReq.php";

    // 获取用户信息
    public static final String GET_USERINFO = API_URL + "checkLoginStamp.php";

    // 获取用户收藏夹
    public static final String GET_USER_FAVA = API_URL + "getUserFava.php";

    // 删除好友、收藏夹
    public static final String DEL_ACTIONS = API_URL + "dellActions.php";

    // 增加删除收藏
    public static final String ADD_DEL_FAVA = API_URL + "addFava.php";

    // 修改账号资料/找回密码
    public static final String MODIFY_ACCOUNT_INFO = API_URL + "publicActions.php";

    // 获取用户评论列表
    public static final String GET_USER_COMMENT = API_URL + "getUserComment.php";

    // 搜索
    public static final String SEARCH = API_URL + "search.php";

    // 搜索关键词列表
    public static final String SEARCH_KEY_LIST = API_URL + "searchKeyboard.php";

    // 更新搜索关键词列表的开关
    public static final String UPDATE_SEARCH_KEY_LIST = API_URL + "updateKeyboard.php";

} public class DateUtils {

    /**
     * 将时间戳转换为固定格式的日期字符串
     * @param timestamp 时间戳
     * @return 日期字符串
     */
    public static String timestampToDateString(String timestamp) throws ParseException {
        String res;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
        Date date = simpleDateFormat.parse(timestamp);
        long ts = date.getTime() / 1000;
        res = String.valueOf(ts);
        return res;
    }

    // 将时间戳转为字符串
    public static String getStringTime(String cc_time) {
        String re_StrTime = null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
        long lcc_time = Long.valueOf(cc_time);
        re_StrTime = sdf.format(new Date(lcc_time * 1000L));
        return re_StrTime;
    }
} public class FileCacheUtils {

    private static final String TAG = "FileCacheUtils";

    // 检查文件缓存监听接口
    public interface OnCheckCacheInDiskListener {
        /**
         * 检查文件是否缓存到磁盘，如果有则回调文件路径
         *
         * @param isExist  是否存在
         * @param filePath 文件路径，没有则为null
         */
        public abstract void checkCacheInDisk(boolean isExist, String filePath);
    }

    // 下载图片到磁盘监听接口
    public interface OnDownloadImageToDiskListener {
        /**
         * 下载图片完成后回调
         *
         * @param success  是否下载成功
         * @param filePath 文件路径，没有则为null
         */
        public abstract void downloadFinished(boolean success, String filePath);
    }

    /**
     * 检查是否有缓存，子主线程操作
     *
     * @param url 文件url
     */
    public static void checkCacheInDisk(final String url, final OnCheckCacheInDiskListener cacheInDiskListener) {

        final DataSource<Boolean> dataSource = Fresco.getImagePipeline().isInDiskCache(Uri.parse(url));
        DataSubscriber<Boolean> subscriber = new BaseDataSubscriber<Boolean>() {
            @Override
            protected void onNewResultImpl(final DataSource<Boolean> dataSource) {
                LogUtils.d(TAG, "检查文件是否存在成功");
            }

            @Override
            protected void onFailureImpl(DataSource<Boolean> dataSource) {
                LogUtils.d(TAG, "检查文件是否存在失败");
            }
        };
        dataSource.subscribe(subscriber, new Executor() {
            @Override
            public void execute(@NonNull Runnable command) {
                String filePath = null;
                if (dataSource.getResult()) {
                    filePath = getDiskCacheFilePath(url);
                    // 防止获取磁盘文件失败
                    if (TextUtils.isEmpty(filePath)) {
                        cacheInDiskListener.checkCacheInDisk(false, filePath);
                        return;
                    }
                }
                cacheInDiskListener.checkCacheInDisk(dataSource.getResult(), filePath);
            }
        });

    }

    /**
     * 获取磁盘缓存的文件路径
     *
     * @param url 文件url
     * @return 文件路径
     */
    private static String getDiskCacheFilePath(String url) {
        FileBinaryResource resource = (FileBinaryResource) Fresco.getImagePipelineFactory()
                .getMainFileCache()
                .getResource(new SimpleCacheKey(url));
        // 防止中途清除磁盘缓存 导致获取不到
        if (resource == null) {
            return "";
        }
        File file = resource.getFile();
        return file.getAbsolutePath();
    }

    /**
     * 下载图片到磁盘 并回调下载结果
     *
     * @param context                     上下文
     * @param url                         文件url
     * @param downloadImageToDiskListener 回调接口
     */
    public static void downloadImage(Context context, final String url, final OnDownloadImageToDiskListener downloadImageToDiskListener) {
        LogUtils.d(TAG, "start download image, url =  " + url);

        FrescoBitmapUtils frescoBitmapUtils = new FrescoBitmapUtils(context, 1, new FrescoBitmapUtils.OnFrescoBmpDownloadStateChangedListener() {
            @Override
            public void onReferenceRelease(CloseableReference<CloseableImage> reference) {
                LogUtils.d(TAG, "onReferenceRelease, url =  " + url);
            }

            @Override
            public void onBitmapDownloadSuccess(Bitmap bitmap, String key) {
                LogUtils.d(TAG, "onBitmapDownloadSuccess, url =  " + url);

                // 下载完成后为了防止意外，再去检查一下文件是否存在
                checkCacheInDisk(url, new OnCheckCacheInDiskListener() {
                    @Override
                    public void checkCacheInDisk(boolean isExist, String filePath) {
                        downloadImageToDiskListener.downloadFinished(isExist, filePath);
                    }
                });

            }

            @Override
            public void onBitmapDownloadFail() {
                LogUtils.d(TAG, "onBitmapDownloadFail, url =  " + url);
            }

            @Override
            public void onRelaseAllReference() {
                LogUtils.d(TAG, "onRelaseAllReference, url =  " + url);
            }

            @Override
            public void onEmptyKey(String key) {
                LogUtils.d(TAG, "onEmptyKey, url =  " + url);
            }
        });

        // 下载图片
        frescoBitmapUtils.downloadBitmap(url);

    }

    /**
     * 获取缓存总大小
     *
     * @param context 上下文
     * @return 格式化后的缓存大小
     */
    public static String getTotalCacheSize(Context context) {
        long cacheSize = 0;
        try {
            cacheSize = getFolderSize(context.getCacheDir());
            if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                cacheSize += getFolderSize(context.getExternalCacheDir());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return getFormatSize(cacheSize);
    }

    /**
     * 清理所有缓存
     *
     * @param context 上下文
     */
    public static void clearAllCache(Context context) {
        deleteDir(context.getCacheDir());
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
            deleteDir(context.getExternalCacheDir());
        }
    }

    /**
     * 删除目录
     *
     * @param dir 目录
     * @return 是否删除成功
     */
    private static boolean deleteDir(File dir) {
        if (dir != null && dir.isDirectory()) {
            String[] children = dir.list();
            for (String aChildren : children) {
                boolean success = deleteDir(new File(dir, aChildren));
                if (!success) {
                    return false;
                }
            }
        }
        return dir != null && dir.delete();
    }

    // 获取文件
    //Context.getExternalFilesDir() --> SDCard/Android/data/你的应用的包名/files/ 目录，一般放一些长时间保存的数据
    //Context.getExternalCacheDir() --> SDCard/Android/data/你的应用包名/cache/目录，一般存放临时缓存数据
    private static long getFolderSize(File file) throws Exception {
        long size = 0;
        try {
            File[] fileList = file.listFiles();
            for (File aFileList : fileList) {
                // 如果下面还有文件
                if (aFileList.isDirectory()) {
                    size = size + getFolderSize(aFileList);
                } else {
                    size = size + aFileList.length();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return size;
    }

    /**
     * 格式化单位
     *
     * @param size
     * @return
     */
    private static String getFormatSize(double size) {
        double kiloByte = size / 1024L;
        if (kiloByte < 1) {
            return "0KB";
        }

        double megaByte = kiloByte / 1024L;
        if (megaByte < 1) {
            BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
            return result1.setScale(2, BigDecimal.ROUND_HALF_UP)
                    .toPlainString() + "KB";
        }

        double gigaByte = megaByte / 1024L;
        if (gigaByte < 1) {
            BigDecimal result2 = new BigDecimal(Double.toString(megaByte));
            return result2.setScale(2, BigDecimal.ROUND_HALF_UP)
                    .toPlainString() + "MB";
        }

        double teraBytes = gigaByte / 1024L;
        if (teraBytes < 1) {
            BigDecimal result3 = new BigDecimal(Double.toString(gigaByte));
            return result3.setScale(2, BigDecimal.ROUND_HALF_UP)
                    .toPlainString() + "GB";
        }
        BigDecimal result4 = new BigDecimal(teraBytes);
        return result4.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()
                + "TB";
    }

} public class LogUtils {

    private static final int VERBOSE = 1;
    private static final int DEBUG = 2;
    private static final int INFO = 3;
    private static final int WARN = 4;
    private static final int ERROR = 5;
    private static final int NOTHING = 6;
    public static int level = VERBOSE;

    /**
     * 最低级的日志
     *
     * @param tag tag标签
     * @param msg 日志信息
     */
    public static void v(String tag, String msg) {
        if (level <= VERBOSE) {
            Log.v(tag, msg);
        }
    }

    /**
     * debug级别日志，调试用
     *
     * @param tag tag标签
     * @param msg 日志信息
     */
    public static void d(String tag, String msg) {
        if (level <= DEBUG) {
            Log.v(tag, msg);
        }
    }

    /**
     * info级别日志，重要信息
     *
     * @param tag tag标签
     * @param msg 日志信息
     */
    public static void i(String tag, String msg) {
        if (level <= INFO) {
            Log.v(tag, msg);
        }
    }

    /**
     * warn级别日志，特别需要注意的提示
     *
     * @param tag tag标签
     * @param msg 日志信息
     */
    public static void w(String tag, String msg) {
        if (level <= WARN) {
            Log.v(tag, msg);
        }
    }

    /**
     * error级别日志，这个一般在catch块里用
     *
     * @param tag tag标签
     * @param msg 日志信息
     */
    public static void e(String tag, String msg) {
        if (level <= ERROR) {
            Log.v(tag, msg);
        }
    }

} public class NetworkUtils {

    private static final String TAG = "NetworkUtils";

    public static final NetworkUtils shared = new NetworkUtils();

    private NetworkUtils() {
    }

    public static abstract class StringCallback {
        public abstract void onError(Call call, Exception e, int id);

        public abstract void onResponse(String response, int id);
    }

    /**
     * get请求
     *
     * @param api        api接口
     * @param parameters 参数
     * @param callback   监听接口
     */
    public void get(String api, HashMap<String, String> parameters, final StringCallback callback) {

        LogUtils.d(TAG, "api = " + api);
        OkHttpUtils
                .get()
                .url(api)
                .params(parameters)
                .build()
                .execute(new com.zhy.http.okhttp.callback.StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        callback.onError(call, e, id);
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        callback.onResponse(response, id);
                    }
                });

    }

    /**
     * post请求
     *
     * @param api        api接口
     * @param parameters 参数
     * @param callback   监听接口
     */
    public void post(String api, HashMap<String, String> parameters, final StringCallback callback) {

        LogUtils.d(TAG, "api = " + api);
        OkHttpUtils
                .post()
                .url(api)
                .params(parameters)
                .build()
                .execute(new com.zhy.http.okhttp.callback.StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        callback.onError(call, e, id);
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        callback.onResponse(response, id);
                    }
                });

    }

    /**
     * 是否有网络连接
     *
     * @param context 上下文
     * @return true有网络
     */
    public boolean isNetworkConnected(Context context) {
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
            if (mNetworkInfo != null) {
                return mNetworkInfo.isAvailable();
            }
        }
        return false;
    }

    /**
     * 判断WiFi是否可用
     *
     * @param context 上下文
     * @return true可用
     */
    public boolean isWifiConnected(Context context) {
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo mWiFiNetworkInfo = mConnectivityManager
                    .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
            if (mWiFiNetworkInfo != null) {
                return mWiFiNetworkInfo.isAvailable();
            }
        }
        return false;
    }

    /**
     * 判断MOBILE网络是否可用
     *
     * @param context 上下文
     * @return true可用
     */
    public boolean isMobileConnected(Context context) {
        if (context != null) {
            ConnectivityManager mConnectivityManager = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            NetworkInfo mMobileNetworkInfo = mConnectivityManager
                    .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
            if (mMobileNetworkInfo != null) {
                return mMobileNetworkInfo.isAvailable();
            }
        }
        return false;
    }

    /**
     * 判断网络类型
     *
     * @param context 上下文
     * @return -1：没有网络  1：WIFI网络  2：wap网络  3：net网络
     */
    public static int getNetworkType(Context context) {
        int netType = -1;
        ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
        if (networkInfo == null) {
            return netType;
        }
        int nType = networkInfo.getType();
        if (nType == ConnectivityManager.TYPE_MOBILE) {
            if (networkInfo.getExtraInfo().toLowerCase().equals("cmnet")) {
                netType = 3;
            } else {
                netType = 2;
            }
        } else if (nType == ConnectivityManager.TYPE_WIFI) {
            netType = 1;
        }
        return netType;
    }

} public class ProgressHUD {

    /**
     * 显示加载HUD 需要手动取消
     *
     * @param context 上下文
     * @return KProgressHUD
     */
    public static KProgressHUD show(Context context) {
        return KProgressHUD.create(context)
                .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
                .setCancellable(true)
                .setDimAmount(0.5f)
                .show();
    }

    /**
     * 显示带文字的加载HUD 需要手动取消
     *
     * @param context   上下文
     * @param tipString 提示文字
     * @return KProgressHUD
     */
    public static KProgressHUD show(Context context, String tipString) {
        return KProgressHUD.create(context)
                .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
                .setLabel(tipString)
                .setCancellable(true)
                .setDimAmount(0.5f)
                .show();
    }

    /**
     * 显示带文字的加载HUD 不需要手动取消
     *
     * @param context   上下文
     * @param tipString 提示文字
     * @return KProgressHUD
     */
    public static void showInfo(Context context, String tipString) {
        Toast.makeText(context, tipString, Toast.LENGTH_SHORT).show();
    }

} public class SharedPreferencesUtils {

    // 新闻详情字体
    public static final String DETAIL_FONT = "font_key";

    // 配置文件名称
    private static final String CONFIG_FILE_NAME = "config";

    /**
     * 设置一个boolean类型配置
     *
     * @param context context
     * @param key     键
     * @param value   值
     */
    public static void setBoolean(Context context, String key, boolean value) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
        sp.edit().putBoolean(key, value).apply();
    }

    /**
     * 获取一个boolean类型配置
     *
     * @param context  context
     * @param key      键
     * @param defValue 缺省值
     * @return 根据key查找到value
     */
    public static boolean getBoolean(Context context, String key, boolean defValue) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
        return sp.getBoolean(key, defValue);
    }

    /**
     * 设置一个String类型配置
     *
     * @param context context
     * @param key     键
     * @param value   值
     */
    public static void setString(Context context, String key, String value) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
        sp.edit().putString(key, value).apply();
    }

    /**
     * 获取一个String类型配置
     *
     * @param context  context
     * @param key      键
     * @param defValue 缺省值
     * @return 根据key查找到value
     */
    public static String getString(Context context, String key, String defValue) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
        return sp.getString(key, defValue);
    }

    /**
     * 设置一个int类型配置
     *
     * @param context context
     * @param key     键
     * @param value   值
     */
    public static void setInt(Context context, String key, int value) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
        sp.edit().putInt(key, value).apply();
    }

    /**
     * 获取一个int类型配置
     *
     * @param context  context
     * @param key      键
     * @param defValue 缺省值
     * @return 根据key查找到value
     */
    public static int getInt(Context context, String key, int defValue) {
        SharedPreferences sp = context.getSharedPreferences(CONFIG_FILE_NAME, Context.MODE_PRIVATE);
        return sp.getInt(key, defValue);
    }

} public class SizeUtils {

    /**
     * dip单位转px单位
     *
     * @param context  上下文
     * @param dipValue dip数值
     * @return px数值
     */
    public static int dip2px(Context context, float dipValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dipValue * scale + 0.5f);
    }

    /**
     * px单位转dip单位
     *
     * @param context 上下文
     * @param pxValue px数值
     * @return dip数值
     */
    public static int px2dip(Context context, float pxValue) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5f);
    }

    /**
     * 获取屏幕宽度 dip
     *
     * @param context 上下文
     * @return 宽度
     */
    public static int getScreenWidthDip(Context context) {
        return px2dip(context, context.getResources().getDisplayMetrics().widthPixels);
    }

    /**
     * 获取屏幕高度 dip
     *
     * @param context 上下文
     * @return 高度
     */
    public static int getScreenHeightDip(Context context) {
        return px2dip(context, context.getResources().getDisplayMetrics().heightPixels);
    }

    /**
     * 获取屏幕宽度 px
     *
     * @param context 上下文
     * @return 宽度
     */
    public static int getScreenWidthPx(Context context) {
        return context.getResources().getDisplayMetrics().widthPixels;
    }

    /**
     * 获取屏幕高度 px
     *
     * @param context 上下文
     * @return 高度
     */
    public static int getScreenHeightPx(Context context) {
        return context.getResources().getDisplayMetrics().heightPixels;
    }

} public class StatusUtils {

    /**
     * 设置MIUI状态栏模式
     *
     * @param activity activity
     * @param darkmode 是否是黑暗系
     * @return 是否设置成功
     */
    public static boolean setMiuiStatusBarDarkMode(Activity activity, boolean darkmode) {
        Class<? extends Window> clazz = activity.getWindow().getClass();
        try {
            int darkModeFlag = 0;
            Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
            Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
            darkModeFlag = field.getInt(layoutParams);
            Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
            extraFlagField.invoke(activity.getWindow(), darkmode ? darkModeFlag : 0, darkModeFlag);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    /**
     * 设置魅族状态栏模式
     *
     * @param activity activity
     * @param darkmode 是否是黑暗系
     * @return 是否设置成功
     */
    public static boolean setMeizuStatusBarDarkMode(Activity activity, boolean darkmode) {
        boolean result = false;
        if (activity != null) {
            try {
                WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
                Field darkFlag = WindowManager.LayoutParams.class
                        .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
                Field meizuFlags = WindowManager.LayoutParams.class
                        .getDeclaredField("meizuFlags");
                darkFlag.setAccessible(true);
                meizuFlags.setAccessible(true);
                int bit = darkFlag.getInt(null);
                int value = meizuFlags.getInt(lp);
                if (darkmode) {
                    value |= bit;
                } else {
                    value &= ~bit;
                }
                meizuFlags.setInt(lp, value);
                activity.getWindow().setAttributes(lp);
                result = true;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return result;
    }

} public class StreamUtils {

    private static final String TAG = "StreamUtils";

    /**
     * inputStrean转String
     *
     * @param in     InputStream
     * @param encode 编码
     * @return 转换后的字符串
     */
    public static String InputStreanToString(InputStream in, String encode) {

        String str = "";
        try {
            if (encode == null || encode.equals("")) {
                // 默认以utf-8形式
                encode = "utf-8";
            }
            BufferedReader reader = new BufferedReader(new InputStreamReader(in, encode));
            StringBuffer sb = new StringBuffer();

            while ((str = reader.readLine()) != null) {
                sb.append(str).append("\n");
            }
            return sb.toString();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return str;
    }

    /**
     * 读取Assets下的文本文件
     *
     * @param context  上下文
     * @param fileName 文件名
     * @return 读取到的字符串
     */
    public static String readAssetsFile(Context context, String fileName) {

        StringBuilder stringBuffer = new StringBuilder();
        AssetManager assetManager = context.getAssets();
        try {
            InputStream is = assetManager.open(fileName);
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String str = null;
            while ((str = br.readLine()) != null) {
                stringBuffer.append(str);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuffer.toString();
    }

    /**
     * 写入字符串到手机存储卡内
     *
     * @param fileName 文件名
     * @param string   要存储的字符串
     */
    public static void writeStringToFile(String fileName, String string) {
        FileOutputStream out = null;
        BufferedWriter writer = null;
        try {
            out = BaoKanApp.getContext().openFileOutput(fileName, Context.MODE_PRIVATE);
            writer = new BufferedWriter(new OutputStreamWriter(out));
            writer.write(string);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (writer != null) {
                    writer.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 从手机存储卡读取字符串数据
     *
     * @param fileName 文件名
     * @return 读取到的字符串
     */
    public static String readStringFromFile(String fileName) {
        FileInputStream in = null;
        BufferedReader reader = null;
        StringBuilder content = new StringBuilder();
        try {
            in = BaoKanApp.getContext().openFileInput(fileName);
            reader = new BufferedReader(new InputStreamReader(in));
            String line = "";
            while ((line = reader.readLine()) != null) {
                content.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return content.toString();
    }

    /**
     * 判断文件是否存在
     *
     * @param filePath 文件绝对路径
     * @return 是否存在
     */
    public static boolean fileIsExists(String filePath) {
        try {
            File f = new File(filePath);
            if (!f.exists()) {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }

    /**
     * 保存远程图片到相册 - 会保存到2个目录
     */
    public static void saveImageToAlbum(final Context context, final String imageUrl) {
        Picasso.with(context).load(imageUrl).into(new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                // 创建目录
                File appDir = new File(Environment.getExternalStorageDirectory(), "BaoKanImage");
                if (!appDir.exists()) {
                    appDir.mkdir();
                }

                // 获取图片类型
                String[] imageTypes = new String[]{".jpg", ".png", ".jpeg", "webp"};
                String imageType = "";
                if (imageUrl.endsWith(imageTypes[0])) {
                    imageType = "jpg";
                } else if (imageUrl.endsWith(imageTypes[1])) {
                    imageType = "png";
                } else {
                    imageType = "jpeg";
                }
                String fileName = System.currentTimeMillis() + "." + imageType;
                File file = new File(appDir, fileName);
                // 保存图片
                try {
                    FileOutputStream fos = new FileOutputStream(file);
                    if (TextUtils.equals(imageType, "jpg")) imageType = "jpeg";
                    imageType = imageType.toUpperCase();
                    bitmap.compress(Bitmap.CompressFormat.valueOf(imageType), 100, fos);
                    fos.flush();
                    fos.close();
                    Toast.makeText(context, "保存成功", Toast.LENGTH_SHORT).show();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                // 其次把文件插入到系统图库
                try {
                    MediaStore.Images.Media.insertImage(context.getContentResolver(), file.getAbsolutePath(), fileName, null);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                }
                // 最后通知图库更新
                context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + file.getPath())));
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {

            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {

            }
        });
    }

    /**
     * 保存图片到sd卡
     *
     * @param photoBitmap
     * @param photoName
     * @param path
     */
    public static String savePhoto(Bitmap photoBitmap, String path, String photoName) {
        String localPath = null;
        if (android.os.Environment.getExternalStorageState().equals(
                android.os.Environment.MEDIA_MOUNTED)) {
            File dir = new File(path);
            if (!dir.exists()) {
                dir.mkdirs();
            }

            File photoFile = new File(path, photoName + ".png");
            FileOutputStream fileOutputStream = null;
            try {
                fileOutputStream = new FileOutputStream(photoFile);
                if (photoBitmap != null) {
                    if (photoBitmap.compress(Bitmap.CompressFormat.PNG, 100,
                            fileOutputStream)) { // 转换完成
                        localPath = photoFile.getPath();
                        fileOutputStream.flush();
                    }
                }
            } catch (IOException e) {
                photoFile.delete();
                localPath = null;
                e.printStackTrace();
            } finally {
                try {
                    if (fileOutputStream != null) {
                        fileOutputStream.close();
                        fileOutputStream = null;
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return localPath;
    }

}
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Toast;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.rebound.SimpleSpringListener;
import com.facebook.rebound.Spring;
import com.facebook.rebound.SpringSystem;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.onekeyshare.OnekeyShare;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;
import okhttp3.Call;
import tv.baokan.baokanandroid.R;
import tv.baokan.baokanandroid.cache.NewsDALManager;
import tv.baokan.baokanandroid.model.ArticleDetailBean;
import tv.baokan.baokanandroid.model.CommentBean;
import tv.baokan.baokanandroid.model.UserBean;
import tv.baokan.baokanandroid.adapter.CommentRecyclerViewAdapter;
import tv.baokan.baokanandroid.adapter.LinkRecyclerViewAdapter;
import tv.baokan.baokanandroid.utils.APIs;
import tv.baokan.baokanandroid.utils.DateUtils;
import tv.baokan.baokanandroid.utils.FileCacheUtils;
import tv.baokan.baokanandroid.utils.LogUtils;
import tv.baokan.baokanandroid.utils.NetworkUtils;
import tv.baokan.baokanandroid.utils.ProgressHUD;
import tv.baokan.baokanandroid.utils.SharedPreferencesUtils;
import tv.baokan.baokanandroid.utils.SizeUtils;
import tv.baokan.baokanandroid.utils.StatusUtils;
import tv.baokan.baokanandroid.utils.StreamUtils;
                oks.setTitleUrl("http://www.baokan.tv/wapapp/index.html");
                // text是分享文本，所有平台都需要这个字段
                oks.setText("爆侃网文精心打造网络文学互动平台，专注最新文学市场动态，聚焦第一手网文圈资讯！");
                //分享网络图片，新浪微博分享网络图片需要通过审核后申请高级写入接口，否则请注释掉测试新浪微博
                oks.setImageUrl("http://www.baokan.tv/fx.png");
                // url仅在微信（包括好友和朋友圈）中使用
                oks.setUrl("http://www.baokan.tv/wapapp/index.html");
                // site是分享此内容的网站名称，仅在QQ空间使用
                oks.setSite("爆侃网文");
                // siteUrl是分享此内容的网站地址，仅在QQ空间使用
                oks.setSiteUrl("http://www.baokan.tv/wapapp/index.html");
                // 启动分享GUI
                oks.show(mContext);
                return true;
            }
        });

    }

    /**
     * 准备数据
     */
    private void prepareData() {

        // 取出启动activity时传递的数据
        Intent intent = getIntent();
        classid = intent.getStringExtra("classid_key");
        id = intent.getStringExtra("id_key");

        // 加载网络数据
        loadNewsDetailFromNetwork();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ib_news_detail_bottom_bar_back:
                finish();
                break;
            case R.id.ib_news_detail_bottom_bar_edit:
                showCommentDialog();
                break;
            case R.id.ib_news_detail_bottom_bar_font:
                showSetFontDialog();
                break;
            case R.id.ib_news_detail_bottom_bar_collection:
                collectArticle();
                break;
            case R.id.ib_news_detail_bottom_bar_share:
                // 弹出分享ui
                showShare(null);
                break;
            case R.id.ll_article_content_share_qq:
                // qq分享
                showShare(ShareSDK.getPlatform(QQ.NAME).getName());
                break;
            case R.id.ll_article_content_share_weixin:
                // 微信分享
                showShare(ShareSDK.getPlatform(Wechat.NAME).getName());
                break;
            case R.id.ll_article_content_share_pyq:
                // 朋友圈分享
                showShare(ShareSDK.getPlatform(WechatMoments.NAME).getName());
                break;
        }
    }

    /**
     * 分享
     */
    private void showShare(String platform) {
        OnekeyShare oks = new OnekeyShare();
        //指定分享的平台，如果为空，还是会调用九宫格的平台列表界面
        if (platform != null) {
            oks.setPlatform(platform);
        }
        // 关闭sso授权
        oks.disableSSOWhenAuthorize();
        // title标题，印象笔记、邮箱、信息、微信、人人网、QQ和QQ空间使用
        oks.setTitle(detailBean.getTitle());
        // titleUrl是标题的网络链接，仅在Linked-in,QQ和QQ空间使用
        oks.setTitleUrl(detailBean.getTitleurl());
        // text是分享文本，所有平台都需要这个字段
        oks.setText(detailBean.getSmalltext());
        //分享网络图片，新浪微博分享网络图片需要通过审核后申请高级写入接口，否则请注释掉测试新浪微博
        if (!TextUtils.isEmpty(detailBean.getTitlepic())) {
            oks.setImageUrl(detailBean.getTitlepic());
        } else {
            // 默认图片，放服务器
            oks.setImageUrl("http://www.baokan.tv/d/file/p/2017-01-05/8c81061deb5b31ce6fb8e3a018afe8e5.jpg");
        }
        // url仅在微信（包括好友和朋友圈）中使用
        oks.setUrl(detailBean.getTitleurl());
        // site是分享此内容的网站名称，仅在QQ空间使用
        oks.setSite("爆侃网文");
        // siteUrl是分享此内容的网站地址，仅在QQ空间使用
        oks.setSiteUrl(detailBean.getTitleurl());
        // 启动分享GUI
        oks.show(mContext);
    }

    /**
     * 收藏文章
     */
    private void collectArticle() {
        if (UserBean.isLogin()) {
            HashMap<String, String> parameters = new HashMap<>();
            parameters.put("username", UserBean.shared().getUsername());
            parameters.put("userid", UserBean.shared().getUserid());
            parameters.put("token", UserBean.shared().getToken());
            parameters.put("classid", classid);
            parameters.put("id", id);
            NetworkUtils.shared.post(APIs.ADD_DEL_FAVA, parameters, new NetworkUtils.StringCallback() {
                @Override
                public void onError(Call call, Exception e, int id) {
                    ProgressHUD.showInfo(NewsDetailActivity.this, "您的网络不给力哦");
                }

                @Override
                public void onResponse(String response, int id) {
                    LogUtils.d(TAG, response);