public class CommentRemindAdapter extends LoadMoreAdapter<RemindComment> {

    private Context context;

    @Override
    public RecyclerView.ViewHolder createCustomViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View view = LayoutInflater.from(context).inflate(R.layout.weibo_comment, null);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void bindCustomViewHolder(RecyclerView.ViewHolder holder, int position) {
        final RemindComment remindComment = list.get(position);
        ViewHolder viewHolder = (ViewHolder) holder;
        //设置名字
        if (SharePrefUtil.getBoolean(context, "user_remark", true)) {
            viewHolder.tv_screen_name.setText(remindComment.getUser().getName());
        } else {
            viewHolder.tv_screen_name.setText(remindComment.getUser().getScreen_name());
        }
        //设置评论时间
        viewHolder.tv_time.setText(DateUtils.getWeiboDate(remindComment.getCreated_at()));
        //设置来源
        viewHolder.tv_device.setText(Html.fromHtml(remindComment.getSource()));
        //设置认证图标
        switch (remindComment.getUser().getVerified_type()) {
            case 0:
                viewHolder.iv_verified.setImageResource(R.drawable.avatar_vip);
                break;
            case -1:
                viewHolder.iv_verified.setImageResource(android.R.color.transparent);
                break;
            case 220:
                viewHolder.iv_verified.setImageResource(R.drawable.avatar_grassroot);
                break;
            default:
                viewHolder.iv_verified.setImageResource(R.drawable.avatar_enterprise_vip);
                break;
        }
        //评论
        SpannableString text = StringUtils.getWeiBoContent(context,
                remindComment.getText(), viewHolder.tv_text);
        viewHolder.tv_text.setText(text);
        //被回复的评论
        if (remindComment.getReply_comment() != null) {
            if (!TextUtils.isEmpty(remindComment.getReply_comment().getText())) {
                viewHolder.tv_reply_text.setVisibility(View.VISIBLE);
                SpannableString replyContent = StringUtils.getWeiBoContent(context,
                        remindComment.getReply_comment().getText(), viewHolder.tv_reply_text);
                viewHolder.tv_reply_text.setText(replyContent);
            }
        } else {
            viewHolder.tv_reply_text.setVisibility(View.GONE);
        }
        //微博的原博主
        viewHolder.iv_weibo_name.setText(remindComment.getStatus().getUser().getScreen_name());
        //微博的内容
        SpannableString weiBoContent = StringUtils.getWeiBoContent(context,
                remindComment.getStatus().getText(), viewHolder.iv_weibo_text);
        viewHolder.iv_weibo_text.setText(weiBoContent);

        Glide.with(context).load(remindComment.getUser().getProfile_image_url())
                .centerCrop()
                .placeholder(R.drawable.img_empty_avatar)
                .crossFade()
                .into(viewHolder.iv_avatar);

        Glide.with(context).load(remindComment.getStatus().getUser().getAvatar_large())
                .centerCrop()
                .placeholder(R.drawable.img_empty_avatar)
                .crossFade()
                .into(viewHolder.iv_weibo_avatar);

        viewHolder.tv_comment.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(v.getContext(), PublishActivity.class);
                intent.putExtra("type", PublishActivity.REPLY_COMMENT);
                intent.putExtra("cid", remindComment.getIdstr());
                intent.putExtra("idstr", remindComment.getStatus().getIdstr());
                context.startActivity(intent);
            }
        });

    }

//    View.OnClickListener listener = new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//            switch (v.getId()) {
//                case R.id.tv_comment:
//                    Intent intent = new Intent();
//                    intent.setClass(context, PublishActivity.class);
//                    intent.putExtra("type", PublishActivity.SEND_COMMENT);
//                    intent.putExtra("idstr", .idstr);
//                    context.startActivity(intent);
//                    break;
//                break;
//            }
//        }
//    };

    static class ViewHolder extends RecyclerView.ViewHolder {

        public ImageView iv_avatar;
        public TextView tv_screen_name;
        public ImageView iv_verified;
        public TextView tv_time;
        public TextView tv_device;
        public TextView tv_comment;
        public TextView tv_text;
        public TextView tv_reply_text;
        public ImageView iv_weibo_avatar;
        public TextView iv_weibo_name;
        public TextView iv_weibo_text;

        public ViewHolder(View itemView) {
            super(itemView);
            iv_avatar = (ImageView) itemView.findViewById(R.id.iv_avatar);
            tv_screen_name = (TextView) itemView.findViewById(R.id.tv_screen_name);
            iv_verified = (ImageView) itemView.findViewById(R.id.iv_verified);
            tv_time = (TextView) itemView.findViewById(R.id.tv_time);
            tv_device = (TextView) itemView.findViewById(R.id.tv_device);
            tv_comment = (TextView) itemView.findViewById(R.id.tv_comment);
            tv_text = (TextView) itemView.findViewById(R.id.tv_text);
            tv_reply_text = (TextView) itemView.findViewById(R.id.tv_reply_text);
            iv_weibo_avatar = (ImageView) itemView.findViewById(R.id.iv_weibo_avatar);
            iv_weibo_name = (TextView) itemView.findViewById(R.id.iv_weibo_name);
            iv_weibo_text = (TextView) itemView.findViewById(R.id.iv_weibo_text);
        }
    }

} public abstract class LoadMoreAdapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private static final int TYPE_FOOTER = 1001;
    private static final int TYPE_HEADER = 1002;
    // 头ViewHolder
    protected FooterViewHolder mFooterViewHolder;
    // 尾ViewHolder
    protected HeaderViewHolder mHeaderViewHolder;
    /**
     * 头view
     */
    protected View mHeaderView;
    /**
     * 尾view
     */
    protected View mFooterView;

    public synchronized List<T> getList() {
        return list;
    }

    protected List<T> list = new ArrayList<>();
    protected boolean loadSuccess = true;

    // 是否为加载更多
    private boolean isLoadingMore;

    public void setIsLoadingMore(boolean isLoadingMore) {
        this.isLoadingMore = isLoadingMore;
    }

    public boolean isLoadingMore() {
        return isLoadingMore;
    }

    public void addHeaderView(View view) {
        this.mHeaderView = view;
    }

    public LoadMoreAdapter(){
        mFooterView = LayoutInflater.from(MyApplication.getContext()).inflate(R.layout.layout_footer,null);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        if (viewType == TYPE_HEADER && mHeaderView != null) {
            mHeaderViewHolder = new HeaderViewHolder(mHeaderView);
            return mHeaderViewHolder;
        } else if (viewType == TYPE_FOOTER && mFooterView != null) {
           mFooterViewHolder = new FooterViewHolder(mFooterView);
            return mFooterViewHolder;
        } else {
            return createCustomViewHolder(parent, viewType);
        }
    }

    public abstract RecyclerView.ViewHolder createCustomViewHolder(ViewGroup parent, int viewType);

    public abstract void bindCustomViewHolder(RecyclerView.ViewHolder holder, int position);

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (mHeaderView != null && holder.getItemViewType() == TYPE_HEADER) {
            return;
        } else if (mFooterView != null && holder.getItemViewType() == TYPE_FOOTER) {
            final FooterViewHolder viewHolder = (FooterViewHolder) holder;
            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (!loadSuccess) {
                        loadSuccess = !loadSuccess;
                        viewHolder.ll_load_more.setVisibility(View.VISIBLE);
                        viewHolder.tv_load_fail.setVisibility(View.INVISIBLE);
                        if (listener != null) {
                            listener.onLoadingMore();
                        }
                    }
                }
            });
        } else {
            if (mHeaderView != null) {
                position--;
            }
            bindCustomViewHolder(holder, position);
        }
    }

    @Override
    public int getItemCount() {
        int exViewNum = 0;
        //如果有头View或尾View
        if (mHeaderView != null) {
            exViewNum++;
        }
        if (mFooterView != null) {
            exViewNum++;
        }
        return list.size() + exViewNum;
    }

    @Override
    public void onViewDetachedFromWindow(RecyclerView.ViewHolder holder) {
        super.onViewDetachedFromWindow(holder);
        holder.itemView.clearAnimation();
    }

    @Override
    public int getItemViewType(int position) {
        if (mHeaderView != null && position == 0) {
            return TYPE_HEADER;
        } else if (mFooterView != null && position == getItemCount() - 1) {
            return TYPE_FOOTER;
        } else {
            if (mHeaderView != null) {
                return super.getItemViewType(position - 1);
            }
            return super.getItemViewType(position);
        }
    }

    /**
     * 是否成功加载更多，加载失败显示 “加载失败，点击重试”
     */
    public void completeLoadMore(boolean success) {
        loadSuccess = success;
        LogUtils.i("isLoadingMore : " + isLoadingMore);
        if (mFooterViewHolder == null) {
            return;
        }
        if (!success) {
            isLoadingMore = true;
            mFooterViewHolder.ll_load_more.setVisibility(View.INVISIBLE);
            mFooterViewHolder.tv_load_fail.setText(mFooterViewHolder.itemView.getContext().getResources().getString(R.string.load_fail));
            mFooterViewHolder.tv_load_fail.setVisibility(View.VISIBLE);
        } else {
            isLoadingMore = false;
        }
    }

    /**
     * 设置列表到底的文字提示，例如 “没有更多微博了”
     */
    public void setEndText(String endText) {
        completeLoadMore(false);
        loadSuccess = true;
        if (mFooterViewHolder != null)
            mFooterViewHolder.tv_load_fail.setText(endText);
    }

    /**
     * 初始化FooterView
     */
    public void initFooterViewHolder() {
        if (mFooterViewHolder != null) {
            mFooterViewHolder.tv_load_fail.setVisibility(View.INVISIBLE);
            mFooterViewHolder.ll_load_more.setVisibility(View.VISIBLE);
        }
    }

    /**
     * 增加一条数据
     *
     * @param position
     * @param t
     */
    public void addData(int position, T t) {
        list.add(position, t);
        notifyItemInserted(position);
    }

    /**
     * 删除一条数据
     *
     * @param position
     */
    public void removeData(int position) {
        list.remove(position);
        notifyItemRemoved(position);
    }

    /**
     * 清除recyclerview数据
     */
    public void clearData() {
        list.clear();
        notifyDataSetChanged();
    }

    //footer viewholder
    public static class FooterViewHolder extends RecyclerView.ViewHolder {

        public LinearLayout ll_load_more;
        public TextView tv_load_fail;

        public FooterViewHolder(View itemView) {
            super(itemView);
            ll_load_more = (LinearLayout) itemView.findViewById(R.id.ll_load_more);
            tv_load_fail = (TextView) itemView.findViewById(R.id.tv_load_fail);
        }
    }

    //header viewhoder
    public static class HeaderViewHolder extends RecyclerView.ViewHolder {
        public HeaderViewHolder(View itemView) {
            super(itemView);
        }
    }

    // 加载更多监听器
    private OnLoadingMoreListener listener;

    /**
     * 设置加载更多监听器
     *
     * @return
     */
    public void setOnLoadingMoreListener(OnLoadingMoreListener listener) {
        this.listener = listener;
    }

    /**
     * 得到加载更多监听器
     *
     * @return
     */
    public OnLoadingMoreListener getListener() {
        return listener;
    }

    /**
     * 刷新的监听器
     */
    public interface OnLoadingMoreListener {
        void onLoadingMore();
    }
} public class MyApplication extends Application {

    private static Context context;
    private static ThreadPoolExecutor executor;
    private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
    private static final int CORE_POOL_SIZE = CPU_COUNT + 1;
    private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1;
    private static final int KEEP_ALIVE = 1;
    private static final BlockingQueue<Runnable> sPoolWorkQueue =
            new LinkedBlockingQueue<Runnable>(128);
    private static final ThreadFactory sThreadFactory = new ThreadFactory() {
        private final AtomicInteger mCount = new AtomicInteger(1);

        public Thread newThread(Runnable r) {
            return new Thread(r, "AsyncTask #" + mCount.getAndIncrement());
        }
    };
    private static RequestQueue mQueue;

    /**
     * 得到volley队列
     * @return
     */
    public static RequestQueue getRequestQueue() {
            return mQueue;
    }

    public static Context getContext() {
        return context;
    }

    public static ThreadPoolExecutor getExecutor() {
        return executor;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
                .threadPriority(Thread.NORM_PRIORITY - 1).denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024)
                .diskCacheFileNameGenerator(new Md5FileNameGenerator()).diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(300).tasksProcessingOrder(QueueProcessingType.LIFO)
                .build();
        ImageLoader.getInstance().init(config);
        executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE,
                TimeUnit.SECONDS, sPoolWorkQueue, sThreadFactory);
        mQueue = Volley.newRequestQueue(context);
    }

} public class AppConstant {
    /**
     * App Key
     */
    public static final String APP_KEY = "2146675350";
    /**
     * App Secret
     */
    public static final String APP_SECRET = "2c990a9d6f2fd0a59a3f76da68663a58";
    /**
     * 默认回调页面
     */
    public static final String REDIRECT_URL = "https://api.weibo.com/oauth2/default.html";
    /**
     * OAuth2的authorize接口
     */
    public static final String AUTHORIZE_URL = "https://open.weibo.cn/oauth2/authorize";
    /**
     * OAuth2的access_token接口
     */
    public static final String ACCESS_TOKEN_URL = "https://api.weibo.com/oauth2/access_token";
    /**
     * 根据用户ID获取用户信息
     */
    public static final String USERS_SHOW_URL = "https://api.weibo.com/2/users/show.json";
    /**
     * 查询用户access_token的授权相关信息，包括授权时间，过期时间和scope权限。
     */
    public static final String GET_TOKEN_INFO_URL = "https://api.weibo.com/oauth2/get_token_info";
    /**
     * 获取当前登录用户及其所关注用户的最新微博
     */
    public static final String HOME_TIMELINE_URL = "https://api.weibo.com/2/statuses/home_timeline.json";
    /**
     * 搜索用户时的联想搜索建议
     */
    public static final String SEARCH_USER_URL = "https://api.weibo.com/2/search/suggestions/users.json";
    /**
     * 根据地理信息坐标返回实际地址
     */
    public static final String GEO_TO_ADDRESS_URL = "https://api.weibo.com/2/location/geo/geo_to_address.json";
    /**
     * 发布一条新微博
     */
    public static final String STATUSES_UPDATE_URL = "https://api.weibo.com/2/statuses/update.json";
    /**
     * 上传图片并发布一条新微博
     */
    public static final String STATUSES_UPLOAD_URL = "https://upload.api.weibo.com/2/statuses/upload.json";
    /**
     * 获取双向关注用户的最新微博
     */
    public static final String STATUSES_BILATERAL_TIMELINE_URL = "https://api.weibo.com/2/statuses/bilateral_timeline.json";
    /**
     * 转发一条微博
     */
    public static final String STATUSES_REPOST_URL = "https://api.weibo.com/2/statuses/repost.json";
    /**
     * 对一条微博进行评论
     */
    public static final String COMMENTS_CREATE_URL = "https://api.weibo.com/2/comments/create.json";
    /**
     * 获取用户的关注列表
     */
    public static final String FRIENDSHIPS_FRIENDS_URL = "https://api.weibo.com/2/friendships/friends.json";
    /**
     * 获取某个位置周边的动态
     */
    public static final String PLACE_NEARBY_TIMELINE_URL = "https://api.weibo.com/2/place/nearby_timeline.json";
    /**
     * 获取我的收藏
     */
    public static final String MY_FAVORITE_URL = "https://api.weibo.com/2/favorites.json";
    /**
     * 添加一条微博到收藏里
     */
    public static final String FAVORITE_CREATE_URL = "https://api.weibo.com/2/favorites/create.json";
    /**
     * 取消收藏一条微博
     */
    public static final String FAVORITE_DESTROY_URL = "https://api.weibo.com/2/favorites/destroy.json";
    /**
     * 根据微博ID返回某条微博的评论列表
     */
    public static final String COMMENTS_SHOW_URL = "https://api.weibo.com/2/comments/show.json";
    /**
     * 获取指定微博的转发微博列表
     */
    public static final String STATUSES_REPOST_TIMELINE_URL = "https://api.weibo.com/2/statuses/repost_timeline.json";
    /**
     * 批量获取指定微博的转发数评论数
     */
    public static final String STATUSES_COUNT_URL = "https://api.weibo.com/2/statuses/count.json";
    /**
     * 回复一条评论
     */
    public static final String COMMENTS_REPLY_URL = "https://api.weibo.com/2/comments/reply.json";
    /**
     * 获取某个用户最新发表的微博列表
     */
    public static final String STATUSES_USER_TIMELINE_URL = "https://api.weibo.com/2/statuses/user_timeline.json";
    /**
     * 返回最新的公共微博
     */
    public static final String STATUSES_PUBLIC_TIMELINE_URL = "https://api.weibo.com/2/statuses/public_timeline.json";
    /**
     * 获取某个用户的各种消息未读数
     */
    public static final String REMIND_UNREAD_COUNT_URL = "https://rm.api.weibo.com/2/remind/unread_count.json";
    /**
     * 授权回收接口，帮助开发者主动取消用户的授权。
     */
    public static final String OAUTH2_REVOKEOAUTH2_URL = "https://api.weibo.com/oauth2/revokeoauth2";
    /**
     * 获取最新的提到当前登录用户的评论，即@我的评论
     */
    public static final String COMMENTS_MENTIONS_URL = "https://api.weibo.com/2/comments/mentions.json";
    /**
     * 获取当前登录用户所接收到的评论列表
     */
    public static final String COMMENTS_TO_ME_URL = "https://api.weibo.com/2/comments/to_me.json";
    /**
     * 获取最新的提到登录用户的微博列表，即@我的微博
     */
    public static final String STATUSES_MENTIONS_URL = "https://api.weibo.com/2/statuses/mentions.json";
} public class RemindComment {
    /**
     * {
     "created_at": "Mon Nov 09 11:46:07 +0800 2015",
     "id": 3907234537005921,
     "text": "回复@活得好像一条狗:已经私信",
     "source_allowclick": 0,
     "source_type": 1,
     "source": "<a href=\"http://app.weibo.com/t/feed/173r1J\" rel=\"nofollow\">三星Galaxy NOTE III</a>",
     "user": {
     "id": 3588597747,
     "idstr": "3588597747",
     "class": 1,
     "screen_name": "坏孩子_56430",
     "name": "坏孩子_56430",
     "province": "62",
     "city": "1",
     "location": "甘肃 兰州",
     "description": "",
     "url": "",
     "profile_image_url": "http://tp4.sinaimg.cn/3588597747/50/0/1",
     "profile_url": "u/3588597747",
     "domain": "",
     "weihao": "",
     "gender": "m",
     "followers_count": 35,
     "friends_count": 136,
     "pagefriends_count": 2,
     "statuses_count": 517,
     "favourites_count": 69,
     "created_at": "Sat Jul 06 03:06:43 +0800 2013",
     "following": false,
     "allow_all_act_msg": false,
     "geo_enabled": true,
     "verified": false,
     "verified_type": -1,
     "remark": "",
     "ptype": 0,
     "allow_all_comment": true,
     "avatar_large": "http://tp4.sinaimg.cn/3588597747/180/0/1",
     "avatar_hd": "http://tp4.sinaimg.cn/3588597747/180/0/1",
     "verified_reason": "",
     "verified_trade": "",
     "verified_reason_url": "",
     "verified_source": "",
     "verified_source_url": "",
     "follow_me": false,
     "online_status": 0,
     "bi_followers_count": 5,
     "lang": "zh-cn",
     "star": 0,
     "mbtype": 0,
     "mbrank": 0,
     "block_word": 0,
     "block_app": 0,
     "credit_score": 80,
     "user_ability": 0,
     "urank": 18
     },
     "mid": "3907234537005921",
     "idstr": "3907234537005921",
     "status": {
     "created_at": "Mon Nov 09 10:20:59 +0800 2015",
     "id": 3907213103973691,
     "mid": "3907213103973691",
     "idstr": "3907213103973691",
     "text": "冻友冻友，培训机构哪家强？达内，汇文，端得，还有什么？",
     "source_allowclick": 0,
     "source_type": 1,
     "source": "<a href=\"http://app.weibo.com/t/feed/YdTaa\" rel=\"nofollow\">fabuduan</a>",
     "favorited": false,
     "truncated": false,
     "in_reply_to_status_id": "",
     "in_reply_to_user_id": "",
     "in_reply_to_screen_name": "",
     "pic_urls": [],
     "geo": null,
     "user": {
     "id": 2806842024,
     "idstr": "2806842024",
     "class": 1,
     "screen_name": "量院速冻",
     "name": "量院速冻",
     "province": "33",
     "city": "1",
     "location": "浙江 杭州",
     "description": "中国计量大学综合信息互动讨论。发布方法①登录fabuduan.com/cjlusd ②微信添加“fabuduan” 回复“cjlusd”绑定。自由发言，请文明使用，拒绝广告。",
     "url": "http://fabuduan.com/cjlusd",
     "profile_image_url": "http://tp1.sinaimg.cn/2806842024/50/40014824820/1",
     "cover_image": "http://ww1.sinaimg.cn/crop.0.0.920.300/a74d02a8gw1emnk8uotkoj20pk08cwie.jpg",
     "cover_image_phone": "http://ww1.sinaimg.cn/crop.0.0.0.0/a74d02a8jw1eakd2gsjn6j20f00f00w0.jpg",
     "profile_url": "cjlusd",
     "domain": "cjlusd",
     "weihao": "",
     "gender": "m",
     "followers_count": 27050,
     "friends_count": 2358,
     "pagefriends_count": 3,
     "statuses_count": 134324,
     "favourites_count": 730,
     "created_at": "Fri May 18 11:41:15 +0800 2012",
     "following": true,
     "allow_all_act_msg": true,
     "geo_enabled": false,
     "verified": false,
     "verified_type": 220,
     "remark": "",
     "ptype": 0,
     "allow_all_comment": true,
     "avatar_large": "http://tp1.sinaimg.cn/2806842024/180/40014824820/1",
     "avatar_hd": "http://tp1.sinaimg.cn/2806842024/180/40014824820/1",
     "verified_reason": "",
     "verified_trade": "",
     "verified_reason_url": "",
     "verified_source": "",
     "verified_source_url": "",
     "follow_me": false,
     "online_status": 0,
     "bi_followers_count": 2308,
     "lang": "zh-cn",
     "star": 0,
     "mbtype": 12,
     "mbrank": 6,
     "block_word": 0,
     "block_app": 1,
     "credit_score": 80,
     "user_ability": 0,
     "urank": 34
     },
     "reposts_count": 0,
     "comments_count": 0,
     "attitudes_count": 0,
     "mlevel": 0,
     "visible": {
     "type": 0,
     "list_id": 0
     },
     "biz_feature": 0,
     "darwin_tags": [],
     "userType": 0
     },
     "reply_comment": {
     "created_at": "Mon Nov 09 11:39:41 +0800 2015",
     "id": 3907232908992444,
     "text": "回复@坏孩子_56430:可以[doge]",
     "source_allowclick": 0,
     "source_type": 1,
     "source": "<a href=\"http://app.weibo.com/t/feed/22zMnn\" rel=\"nofollow\">小米手机</a>",
     "user": {
     "id": 2949821927,
     "idstr": "2949821927",
     "class": 1,
     "screen_name": "活得好像一条狗",
     "name": "活得好像一条狗",
     "province": "33",
     "city": "1",
     "location": "浙江 杭州",
     "description": "我好想追上风，追上时间",
     "url": "",
     "profile_image_url": "http://tp4.sinaimg.cn/2949821927/50/40069702276/1",
     "cover_image_phone": "http://ww1.sinaimg.cn/crop.0.0.640.640.640/6ce2240djw1e9112irynuj20hs0hs42i.jpg",
     "profile_url": "u/2949821927",
     "domain": "",
     "weihao": "",
     "gender": "m",
     "followers_count": 82,
     "friends_count": 209,
     "pagefriends_count": 0,
     "statuses_count": 231,
     "favourites_count": 260,
     "created_at": "Sun Sep 16 19:53:55 +0800 2012",
     "following": false,
     "allow_all_act_msg": false,
     "geo_enabled": true,
     "verified": false,
     "verified_type": -1,
     "remark": "",
     "ptype": 0,
     "allow_all_comment": true,
     "avatar_large": "http://tp4.sinaimg.cn/2949821927/180/40069702276/1",
     "avatar_hd": "http://ww4.sinaimg.cn/crop.697.316.441.441.1024/afd2b5e7gw1elxsu36hfuj21hc0xcac4.jpg",
     "verified_reason": "",
     "verified_trade": "",
     "verified_reason_url": "",
     "verified_source": "",
     "verified_source_url": "",
     "follow_me": false,
     "online_status": 0,
     "bi_followers_count": 7,
     "lang": "zh-cn",
     "star": 0,
     "mbtype": 0,
     "mbrank": 0,
     "block_word": 0,
     "block_app": 0,
     "credit_score": 80,
     "user_ability": 0,
     "urank": 17
     },
     "mid": "3907232908992444",
     "idstr": "3907232908992444",
     "floor_num": 6
     },
     "floor_num": 7
     }
     */
    private String created_at;
    private int floor_num;
    private long id;
    private String idstr;
    private String mid;
    private String source;
    private Reply_comment reply_comment;
    private int source_allowclick;
    private int source_type;
    private Status status;
    private String text;
    private User user;

    public static class Reply_comment{

        private String created_at;
        private int floor_num;
        private long id;
        private String idstr;
        private String mid;
        private String source;
        private int source_allowclick;
        private int source_type;
        private String text;
        private User user;

        public String getCreated_at() {
            return created_at;
        }

        public void setCreated_at(String created_at) {
            this.created_at = created_at;
        }

        public int getFloor_num() {
            return floor_num;
        }

        public void setFloor_num(int floor_num) {
            this.floor_num = floor_num;
        }

        public long getId() {
            return id;
        }

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

        public String getIdstr() {
            return idstr;
        }

        public void setIdstr(String idstr) {
            this.idstr = idstr;
        }

        public String getMid() {
            return mid;
        }

        public void setMid(String mid) {
            this.mid = mid;
        }

        public String getSource() {
            return source;
        }

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

        public int getSource_allowclick() {
            return source_allowclick;
        }

        public void setSource_allowclick(int source_allowclick) {
            this.source_allowclick = source_allowclick;
        }

        public int getSource_type() {
            return source_type;
        }

        public void setSource_type(int source_type) {
            this.source_type = source_type;
        }

        public String getText() {
            return text;
        }

        public void setText(String text) {
            this.text = text;
        }

        public User getUser() {
            return user;
        }

        public void setUser(User user) {
            this.user = user;
        }
    }

    public Reply_comment getReply_comment() {
        return reply_comment;
    }

    public void setReply_comment(Reply_comment reply_comment) {
        this.reply_comment = reply_comment;
    }

    public String getCreated_at() {
        return created_at;
    }

    public void setCreated_at(String created_at) {
        this.created_at = created_at;
    }

    public int getFloor_num() {
        return floor_num;
    }

    public void setFloor_num(int floor_num) {
        this.floor_num = floor_num;
    }

    public long getId() {
        return id;
    }

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

    public String getIdstr() {
        return idstr;
    }

    public void setIdstr(String idstr) {
        this.idstr = idstr;
    }

    public String getMid() {
        return mid;
    }

    public void setMid(String mid) {
        this.mid = mid;
    }

    public String getSource() {
        return source;
    }

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

    public int getSource_allowclick() {
        return source_allowclick;
    }

    public void setSource_allowclick(int source_allowclick) {
        this.source_allowclick = source_allowclick;
    }

    public int getSource_type() {
        return source_type;
    }

    public void setSource_type(int source_type) {
        this.source_type = source_type;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
} public class JsonUtils {

    private static String tag = JsonUtils.class.getSimpleName();

    public static String getString(String json, String name) {
        String temp = null;
        JSONObject jsonObject = null;
        try {
            jsonObject = new JSONObject(json);
            temp = jsonObject.getString(name);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return temp;
    }

    /**
     * 把json转化为bean
     *
     * @param jsonString
     * @param cls
     * @param <T>
     * @return
     */
    public static <T> T getBeanFromJson(String jsonString, Class<T> cls) {
        T t = JSON.parseObject(jsonString, cls);
        return t;
    }

    /**
     * 把json转化为List
     *
     * @param jsonString
     * @param cls
     * @param <T>
     * @return
     */
    public static <T> List<T> getListFromJson(String jsonString, Class<T> cls) {
        List<T> list = JSON.parseArray(jsonString, cls);
        return list;
    }

} public class LogUtils {
	/** 日志输出级别NONE */

	public static final int LEVEL_NONE = 0;

	/** 日志输出级别V */

	public static final int LEVEL_VERBOSE = 1;

	/** 日志输出级别D */

	public static final int LEVEL_DEBUG = 2;

	/** 日志输出级别I */

	public static final int LEVEL_INFO = 3;

	/** 日志输出级别W */

	public static final int LEVEL_WARN = 4;

	/** 日志输出级别E */

	public static final int LEVEL_ERROR = 5;



	/** 日志输出时的TAG */

	private static String mTag = "koku";

	/** 是否允许输出log */

	private static int mDebuggable = LEVEL_ERROR;



	/** 用于记时的变量 */

	private static long mTimestamp = 0;





	/** 以级别为 d 的形式输出LOG */

	public static void v(String msg) {

		if (mDebuggable >= LEVEL_VERBOSE) {

			Log.v(mTag, msg);

		}

	}



	/** 以级别为 d 的形式输出LOG */

	public static void d(String msg) {

		if (mDebuggable >= LEVEL_DEBUG) {

			Log.d(mTag, msg);

		}

	}



	/** 以级别为 i 的形式输出LOG */

	public static void i(String msg) {

		if (mDebuggable >= LEVEL_INFO) {

			Log.i(mTag, msg);

		}

	}



	/** 以级别为 w 的形式输出LOG */

	public static void w(String msg) {

		if (mDebuggable >= LEVEL_WARN) {

			Log.w(mTag, msg);

		}

	}



	/** 以级别为 w 的形式输出Throwable */

	public static void w(Throwable tr) {

		if (mDebuggable >= LEVEL_WARN) {

			Log.w(mTag, "", tr);

		}

	}



	/** 以级别为 w 的形式输出LOG信息和Throwable */

	public static void w(String msg, Throwable tr) {

		if (mDebuggable >= LEVEL_WARN && null != msg) {

			Log.w(mTag, msg, tr);

		}

	}



	/** 以级别为 e 的形式输出LOG */

	public static void e(String msg) {

		if (mDebuggable >= LEVEL_ERROR) {

			Log.e(mTag, msg);

		}

	}



	/** 以级别为 e 的形式输出Throwable */

	public static void e(Throwable tr) {

		if (mDebuggable >= LEVEL_ERROR) {

			Log.e(mTag, "", tr);

		}

	}


	/** 以级别为 e 的形式输出LOG信息和Throwable */

	public static void e(String msg, Throwable tr) {

		if (mDebuggable >= LEVEL_ERROR && null != msg) {

			Log.e(mTag, msg, tr);

		}

	}


	/** 以级别为 e 的形式输出msg信息,附带时间戳，用于输出一个时间段结束点* @param msg 需要输出的msg */

	public static void elapsed(String msg) {

		long currentTime = System.currentTimeMillis();

		long elapsedTime = currentTime - mTimestamp;

		mTimestamp = currentTime;

		e("[Elapsed：" + elapsedTime + "]" + msg);

	}




} public class SharePrefUtil {

	private static String tag = SharePrefUtil.class.getSimpleName();
	private static SharedPreferences sp;
	private static final String SP_NAME = "config";

	/**
	 * 保存布尔值
	 * 
	 * @param context
	 * @param key
	 * @param value
	 */
	public static void saveBoolean(Context context, String key, boolean value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putBoolean(key, value).commit();
	}

	/**
	 * 保存字符串
	 * 
	 * @param context
	 * @param key
	 * @param value
	 */
	public static void saveString(Context context, String key, String value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putString(key, value).commit();

	}

	public static void clear(Context context) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().clear().commit();
	}

	/**
	 * 保存long型
	 * 
	 * @param context
	 * @param key
	 * @param value
	 */
	public static void saveLong(Context context, String key, long value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putLong(key, value).commit();
	}

	public static void saveStringSet(Context context, String key,
			Set<String> value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putStringSet(key, value).commit();
	}

	public static Set<String> getStringSet(Context context, String key,
			Set<String> defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getStringSet(key, defValue);
	}

	/**
	 * 保存int型
	 * 
	 * @param context
	 * @param key
	 * @param value
	 */
	public static void saveInt(Context context, String key, int value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putInt(key, value).commit();
	}

	/**
	 * 保存float型
	 * 
	 * @param context
	 * @param key
	 * @param value
	 */
	public static void saveFloat(Context context, String key, float value) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		sp.edit().putFloat(key, value).commit();
	}

	/**
	 * 获取字符值
	 * 
	 * @param context
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static String getString(Context context, String key, String defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getString(key, defValue);
	}

	/**
	 * 获取int值
	 * 
	 * @param context
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static int getInt(Context context, String key, int defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getInt(key, defValue);
	}

	/**
	 * 获取long值
	 * 
	 * @param context
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static long getLong(Context context, String key, long defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getLong(key, defValue);
	}

	/**
	 * 获取float值
	 * 
	 * @param context
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static float getFloat(Context context, String key, float defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getFloat(key, defValue);
	}

	/**
	 * 获取布尔值
	 * 
	 * @param context
	 * @param key
	 * @param defValue
	 * @return
	 */
	public static boolean getBoolean(Context context, String key,
			boolean defValue) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		return sp.getBoolean(key, defValue);
	}

	/**
	 * 将对象进行base64编码后保存到SharePref中
	 * 
	 * @param context
	 * @param key
	 * @param object
	 */
	public static void saveObj(Context context, String key, Object object) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oos = null;
		try {
			oos = new ObjectOutputStream(baos);
			oos.writeObject(object);
			// 将对象的转为base64码
			String objBase64 = new String(Base64.encode(baos.toByteArray(),
					Base64.DEFAULT));

			sp.edit().putString(key, objBase64).commit();
			oos.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 将SharePref中经过base64编码的对象读取出来
	 * 
	 * @param context
	 * @param key
	 * @return
	 */
	public static Object getObj(Context context, String key) {
		if (sp == null)
			sp = context.getSharedPreferences(SP_NAME, 0);
		String objBase64 = sp.getString(key, null);
		if (TextUtils.isEmpty(objBase64))
			return null;

		// 对Base64格式的字符串进行解码
		byte[] base64Bytes = Base64
				.decode(objBase64.getBytes(), Base64.DEFAULT);
		ByteArrayInputStream bais = new ByteArrayInputStream(base64Bytes);

		ObjectInputStream ois;
		Object obj = null;
		try {
			ois = new ObjectInputStream(bais);
			obj = (Object) ois.readObject();
			ois.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return obj;
	}

} public class AutoLoadRecyclerView extends RecyclerView {

    // 加载更多监听器
    private LoadMoreAdapter.OnLoadingMoreListener listener;

    private LoadMoreAdapter adapter;

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

    public AutoLoadRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    @Override
    public void setAdapter(Adapter adapter) {
        super.setAdapter(adapter);
        this.adapter = (LoadMoreAdapter) adapter;
        listener = ((LoadMoreAdapter) adapter).getListener();

    }

    private void initView() {
        this.setHasFixedSize(true);
        this.setItemAnimator(new DefaultItemAnimator());
        final LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(getContext());
        this.setLayoutManager(mLinearLayoutManager);
//        this.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL_LIST));
        this.addOnScrollListener(new OnScrollListener() {
            private int lastVisibleItem;

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                lastVisibleItem = mLinearLayoutManager.findLastVisibleItemPosition();
            }

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {
                if (adapter == null) {
                    return;
                }
                if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE && lastVisibleItem == adapter.getItemCount() - 1 && !adapter.isLoadingMore()) {
                    adapter.setIsLoadingMore(true);
                    if (listener != null) {
                        handler.sendEmptyMessageDelayed(0, 500);
                    }
                }
            }
        });
    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            listener.onLoadingMore();
        }
    };

} public class FixedSwipeRefreshLayout extends SwipeRefreshLayout {

    public static final int[] SWIPE_REFRESH_LAYOUT_COLOR = new int[]{android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light, android.R.color.holo_blue_bright, android.R.color.holo_purple};

    public FixedSwipeRefreshLayout(Context context) {
        super(context);
    }

    public FixedSwipeRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

//    @Override
//    public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
//        if (isEnabled() && !isRefreshing()) {
//            super.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
//        } else {
//            dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, null);
//        }
//
//    }

    @Override
    public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
        return !isRefreshing() && super.onStartNestedScroll(child, target, nestedScrollAxes);
    }
}
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.yuqirong.koku.R;
import com.yuqirong.koku.adapter.CommentRemindAdapter;
import com.yuqirong.koku.adapter.LoadMoreAdapter;
import com.yuqirong.koku.application.MyApplication;
import com.yuqirong.koku.constant.AppConstant;
import com.yuqirong.koku.entity.RemindComment;
import com.yuqirong.koku.util.JsonUtils;
import com.yuqirong.koku.util.LogUtils;
import com.yuqirong.koku.util.SharePrefUtil;
import com.yuqirong.koku.view.AutoLoadRecyclerView;
import com.yuqirong.koku.view.FixedSwipeRefreshLayout;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
package com.yuqirong.koku.fragment;





/**
 * 提醒中@我的微博
 * Created by Administrator on 2015/11/12.
 */
public class WeiboRemindFragment extends BaseFragment {

    private AutoLoadRecyclerView mRecyclerView;
    private FixedSwipeRefreshLayout mSwipeRefreshLayout;
    private CommentRemindAdapter adapter;
    private String max_id;
    private static Handler mHandler = new Handler();

    @Override
    public void initData(Bundle savedInstanceState) {
        getDataFromServer();
    }

    private void getDataFromServer() {
        String url = AppConstant.COMMENTS_MENTIONS_URL + "?access_token="
                + SharePrefUtil.getString(context, "access_token", "") + "&count=20&max_id=" + max_id;
        LogUtils.i("获取@我的微博列表" + url);
        getData(url, new Response.Listener<String>() {
            @Override
            public void onResponse(String result) {
                try {
                    JSONObject jsonObject = new JSONObject(result);
                    max_id = jsonObject.getString("next_cursor");
                    if (max_id.equals("0")) {
                        adapter.setEndText(context.getString(R.string.load_finish));
                    }
                    String comments = jsonObject.getString("comments");
                    processData(comments);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        });
    }

    private void processData(final String comments) {
        MyApplication.getExecutor().execute(new Runnable() {
            @Override
            public void run() {
                final List<RemindComment> remindComments = JsonUtils.getListFromJson(comments, RemindComment.class);