TouTiao开源项目 分析笔记17 新闻媒体专栏

2019年11月17日 阅读数:198
这篇文章主要向大家介绍TouTiao开源项目 分析笔记17 新闻媒体专栏,主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。

1.效果预览

1.1.要实现的效果javascript

  

 

 

1.2.如何调转到新闻媒体专栏html

  点击右上角的用户图标。 java

  在新闻详情页面的Fragment的菜单点击事件中触发。react

case R.id.action_open_media_home:
                MediaHomeActivity.launch(mediaId);
                break;

 


2.媒体主页的活动页面

2.1.源代码android

package com.jasonjan.headnews.module.media.home;

import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.ContentLoadingProgressBar;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;

import com.jasonjan.headnews.R;
import com.jasonjan.headnews.adapter.BasePagerAdapter;
import com.jasonjan.headnews.global.InitApp;
import com.jasonjan.headnews.main.ErrorAction;
import com.jasonjan.headnews.main.RetrofitFactory;
import com.jasonjan.headnews.module.base.BaseActivity;

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

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by JasonJan on 2018/1/9.
 */

public class MediaHomeActivity extends BaseActivity{

    private static final String ARG_MEDIAID = "mediaId";
    private String mediaId = null;
    private Toolbar toolbar;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private ContentLoadingProgressBar progressBar;

    public static void launch(String MediaId) {
        InitApp.AppContext.startActivity(new Intent(InitApp.AppContext, MediaHomeActivity.class)
                .putExtra(ARG_MEDIAID, MediaId)
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_media_home);
        initView();
        initData();
    }

    private void initView(){
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setBackgroundColor(SettingUtil.getInstance().getColor());

        tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        viewPager = (ViewPager) findViewById(R.id.view_pager);
        tabLayout.setBackgroundColor(SettingUtil.getInstance().getColor());
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

        progressBar = (ContentLoadingProgressBar) findViewById(R.id.pb_progress);
        int color = SettingUtil.getInstance().getColor();
        progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
        progressBar.show();

        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                if (position == 0) {
                    if (slidrInterface != null) {
                        slidrInterface.unlock();
                    }
                } else {
                    if (slidrInterface != null) {
                        slidrInterface.lock();
                    }
                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    private void initData(){
        Intent intent = getIntent();
        this.mediaId = intent.getStringExtra(ARG_MEDIAID);
        if (TextUtils.isEmpty(mediaId)) {
            onError();
            return;
        }
        RetrofitFactory.getRetrofit().create(IMobileMediaApi.class)
                .getMediaProfile(mediaId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(this.<MediaProfileBean>bindToLifecycle())
                .subscribe(new Consumer<MediaProfileBean>() {
                    @Override
                    public void accept(@NonNull MediaProfileBean bean) throws Exception {
                        String name = bean.getData().getName();
                        initToolBar(toolbar, true, name);
                        List<MediaProfileBean.DataBean.TopTabBean> topTab = bean.getData().getTop_tab();
                        if (null != topTab && topTab.size() < 0) {
                            onError();
                            return;
                        }
                        initTabLayout(bean.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(@NonNull Throwable throwable) throws Exception {
                        onError();
                        ErrorAction.print(throwable);
                    }
                });
    }

    private void initTabLayout(MediaProFileBean.DataBean dataBean){
        List<Fragment> fragmentList = new ArrayList<>();
        List<String> titleList = new ArrayList<>();
        List<MediaProfileBean.DataBean.TopTabBean> topTab = dataBean.getTop_tab();
        for (MediaProfileBean.DataBean.TopTabBean bean : topTab) {
            if (bean.getType().equals("all")) {
                fragmentList.add(MediaArticleFragment.newInstance(dataBean));
                titleList.add(bean.getShow_name());
            }
            if (bean.getType().equals("video")) {
                fragmentList.add(MediaVideoFragment.newInstance(mediaId));
                titleList.add(bean.getShow_name());
            }
            if (bean.getType().equals("wenda")) {
                fragmentList.add(MediaWendaFragment.newInstance(dataBean.getUser_id() + ""));
                titleList.add(bean.getShow_name());
            }
        }
        BasePagerAdapter pagerAdapter = new BasePagerAdapter(getSupportFragmentManager(), fragmentList, titleList);
        viewPager.setAdapter(pagerAdapter);
        viewPager.setOffscreenPageLimit(topTab.size());
        progressBar.hide();
    }

    private void onError() {
        progressBar.hide();
        Snackbar.make(progressBar, getString(R.string.error), Snackbar.LENGTH_INDEFINITE).show();
    }
}

 

 

2.2.首先是一个静态的供外部调用的launch函数web

  传入一个媒体id数据库

  保存起来之后再用json

  外部调用这个函数后,会打开这个活动api

 

 

2.3.而后是一个onCreate函数。服务器

  首先加载这个活动的布局==>activity_media_home.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/viewBackground"
    android:fitsSystemWindows="true">

    <include layout="@layout/toolbar"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.design.widget.TabLayout
            android:id="@+id/tab_layout"
            style="@style/TabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:tabTextColor="@color/gray">
        </android.support.design.widget.TabLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/view_pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/tab_layout"
            tools:layout="@layout/fragment_list">
        </android.support.v4.view.ViewPager>

        <android.support.v4.widget.ContentLoadingProgressBar
            android:id="@+id/pb_progress"
            style="?android:attr/progressBarStyle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"/>
    </RelativeLayout>

</android.support.design.widget.CoordinatorLayout>

  预览图片:

  

  

 

2.4.加载视图。

  获取toolbar,设置背景颜色。

  获取tabLayout,设置viewPager。

  获取progressBar,设置颜色。

  设置viewPager页面变化监听器。

  

 

2.5.初始化数据。

  获取intent中的媒体id。

  调用API,获取媒体简介。

  请求数据成功后,初始化tabLayout+viewPager。

 

 

2.6.数据出错。

  若是获取的媒体id为空,

  先将进度条隐藏,而后利用Snackbar(相似Toast)显示错误信息。


3.基础Bean类

3.1.查看服务器返回数据 

 /**
     * message : success
     * data : {"status":0,"is_followed":false,"current_user_id":0,"media_id":5540918998,"description":"慧眼看中国,咱们愿作你的4D眼镜。独家调查、深度报道,在这里,新京报能让你获得不同的知足。","apply_auth_url":"sslocal://webview?url=https%3A%2F%2Fapi.snssdk.com%2Fuser%2Fprofile%2Fauth%2Fguide%2F&bounce_disable=1&hide_bar=1&title=","is_following":false,"bottom_tab":[],"article_limit_enable":1,"verified_agency":"头条认证","bg_img_url":"http://p3.pstatp.com/origin/bc30011684fa86d4b71","verified_content":"新京报官方账号","screen_name":"新京报","common_friends":[],"pgc_like_count":0,"visit_count_recent":659921,"star_chart":{},"user_verified":true,"top_tab":[{"url":"http://issub.snssdk.com/dongtai/list/v8","is_default":false,"show_name":"动态","type":"dongtai"},{"url":"","is_default":true,"show_name":"文章","type":"all"},{"url":"","is_default":false,"show_name":"视频","type":"video"},{"url":"http://isub.snssdk.com/2/user/tab_wenda/","is_default":false,"show_name":"问答","type":"wenda"}],"user_auth_info":"{\"auth_type\": \"0\", \"auth_info\": \"新京报官方账号\"}","is_blocking":0,"is_blocked":0,"user_id":5540918998,"name":"新京报","big_avatar_url":"http://p3.pstatp.com/large/8532/7581013616","area":null,"private_letter_permission":1,"gender":0,"industry":null,"apply_auth_entry_title":"个人认证","share_url":"http://m.toutiao.com/profile/5540918998/","show_private_letter":0,"ugc_publish_media_id":1553029780342785,"avatar_url":"http://p3.pstatp.com/medium/8532/7581013616","followers_count":654244,"media_type":"7","followings_count":2,"medals":[]}
     */

 

  而后是data

 /**
         * status : 0
         * is_followed : false
         * current_user_id : 0
         * media_id : 5540918998
         * description : 慧眼看中国,咱们愿作你的4D眼镜。独家调查、深度报道,在这里,新京报能让你获得不同的知足。
         * apply_auth_url : sslocal://webview?url=https%3A%2F%2Fapi.snssdk.com%2Fuser%2Fprofile%2Fauth%2Fguide%2F&bounce_disable=1&hide_bar=1&title=
         * is_following : false
         * bottom_tab : []
         * article_limit_enable : 1
         * verified_agency : 头条认证
         * bg_img_url : http://p3.pstatp.com/origin/bc30011684fa86d4b71
         * verified_content : 新京报官方账号
         * screen_name : 新京报
         * common_friends : []
         * pgc_like_count : 0
         * visit_count_recent : 659921
         * star_chart : {}
         * user_verified : true
         * top_tab : [{"url":"http://issub.snssdk.com/dongtai/list/v8","is_default":false,"show_name":"动态","type":"dongtai"},{"url":"","is_default":true,"show_name":"文章","type":"all"},{"url":"","is_default":false,"show_name":"视频","type":"video"},{"url":"http://isub.snssdk.com/2/user/tab_wenda/","is_default":false,"show_name":"问答","type":"wenda"}]
         * user_auth_info : {"auth_type": "0", "auth_info": "新京报官方账号"}
         * is_blocking : 0
         * is_blocked : 0
         * user_id : 5540918998
         * name : 新京报
         * big_avatar_url : http://p3.pstatp.com/large/8532/7581013616
         * area : null
         * private_letter_permission : 1
         * gender : 0
         * industry : null
         * apply_auth_entry_title : 个人认证
         * share_url : http://m.toutiao.com/profile/5540918998/
         * show_private_letter : 0
         * ugc_publish_media_id : 1553029780342785
         * avatar_url : http://p3.pstatp.com/medium/8532/7581013616
         * followers_count : 654244
         * media_type : 7
         * followings_count : 2
         * medals : []
         */

 

  而后是服务器返回的TopTabBean数据

/**
             * url : http://issub.snssdk.com/dongtai/list/v8
             * is_default : false
             * show_name : 动态
             * type : dongtai
             */

 

 

3.2.根据返回的数据类型建立序列化MediaProfileBean类  

package com.jasonjan.headnews.bean.media;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * Created by JasonJan on 2018/1/9.
 */

public class MediaProfileBean {
    /**
     * message : success
     * data : {"status":0,"is_followed":false,"current_user_id":0,"media_id":5540918998,"description":"慧眼看中国,咱们愿作你的4D眼镜。独家调查、深度报道,在这里,新京报能让你获得不同的知足。","apply_auth_url":"sslocal://webview?url=https%3A%2F%2Fapi.snssdk.com%2Fuser%2Fprofile%2Fauth%2Fguide%2F&bounce_disable=1&hide_bar=1&title=","is_following":false,"bottom_tab":[],"article_limit_enable":1,"verified_agency":"头条认证","bg_img_url":"http://p3.pstatp.com/origin/bc30011684fa86d4b71","verified_content":"新京报官方账号","screen_name":"新京报","common_friends":[],"pgc_like_count":0,"visit_count_recent":659921,"star_chart":{},"user_verified":true,"top_tab":[{"url":"http://issub.snssdk.com/dongtai/list/v8","is_default":false,"show_name":"动态","type":"dongtai"},{"url":"","is_default":true,"show_name":"文章","type":"all"},{"url":"","is_default":false,"show_name":"视频","type":"video"},{"url":"http://isub.snssdk.com/2/user/tab_wenda/","is_default":false,"show_name":"问答","type":"wenda"}],"user_auth_info":"{\"auth_type\": \"0\", \"auth_info\": \"新京报官方账号\"}","is_blocking":0,"is_blocked":0,"user_id":5540918998,"name":"新京报","big_avatar_url":"http://p3.pstatp.com/large/8532/7581013616","area":null,"private_letter_permission":1,"gender":0,"industry":null,"apply_auth_entry_title":"个人认证","share_url":"http://m.toutiao.com/profile/5540918998/","show_private_letter":0,"ugc_publish_media_id":1553029780342785,"avatar_url":"http://p3.pstatp.com/medium/8532/7581013616","followers_count":654244,"media_type":"7","followings_count":2,"medals":[]}
     */

    private String message;
    private DataBean data;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean implements Parcelable {
        public static final Creator<DataBean> CREATOR = new Creator<DataBean>() {
            @Override
            public DataBean createFromParcel(Parcel in) {
                return new DataBean(in);
            }

            @Override
            public DataBean[] newArray(int size) {
                return new DataBean[size];
            }
        };
        /**
         * status : 0
         * is_followed : false
         * current_user_id : 0
         * media_id : 5540918998
         * description : 慧眼看中国,咱们愿作你的4D眼镜。独家调查、深度报道,在这里,新京报能让你获得不同的知足。
         * apply_auth_url : sslocal://webview?url=https%3A%2F%2Fapi.snssdk.com%2Fuser%2Fprofile%2Fauth%2Fguide%2F&bounce_disable=1&hide_bar=1&title=
         * is_following : false
         * bottom_tab : []
         * article_limit_enable : 1
         * verified_agency : 头条认证
         * bg_img_url : http://p3.pstatp.com/origin/bc30011684fa86d4b71
         * verified_content : 新京报官方账号
         * screen_name : 新京报
         * common_friends : []
         * pgc_like_count : 0
         * visit_count_recent : 659921
         * star_chart : {}
         * user_verified : true
         * top_tab : [{"url":"http://issub.snssdk.com/dongtai/list/v8","is_default":false,"show_name":"动态","type":"dongtai"},{"url":"","is_default":true,"show_name":"文章","type":"all"},{"url":"","is_default":false,"show_name":"视频","type":"video"},{"url":"http://isub.snssdk.com/2/user/tab_wenda/","is_default":false,"show_name":"问答","type":"wenda"}]
         * user_auth_info : {"auth_type": "0", "auth_info": "新京报官方账号"}
         * is_blocking : 0
         * is_blocked : 0
         * user_id : 5540918998
         * name : 新京报
         * big_avatar_url : http://p3.pstatp.com/large/8532/7581013616
         * area : null
         * private_letter_permission : 1
         * gender : 0
         * industry : null
         * apply_auth_entry_title : 个人认证
         * share_url : http://m.toutiao.com/profile/5540918998/
         * show_private_letter : 0
         * ugc_publish_media_id : 1553029780342785
         * avatar_url : http://p3.pstatp.com/medium/8532/7581013616
         * followers_count : 654244
         * media_type : 7
         * followings_count : 2
         * medals : []
         */

        private int status;
        private boolean is_followed;
        private int current_user_id;
        private String media_id;
        private String description;
        private String apply_auth_url;
        private boolean is_following;
        private int article_limit_enable;
        private String verified_agency;
        private String bg_img_url;
        private String verified_content;
        private String screen_name;
        private int pgc_like_count;
        private int visit_count_recent;
        private StarChartBean star_chart;
        private boolean user_verified;
        private String user_auth_info;
        private int is_blocking;
        private int is_blocked;
        private long user_id;
        private String name;
        private String big_avatar_url;
        private Object area;
        private int private_letter_permission;
        private int gender;
        private Object industry;
        private String apply_auth_entry_title;
        private String share_url;
        private int show_private_letter;
        private long ugc_publish_media_id;
        private String avatar_url;
        private String followers_count;
        private String media_type;
        private int followings_count;
        private List<?> bottom_tab;
        private List<?> common_friends;
        private List<TopTabBean> top_tab;
        private List<?> medals;

        protected DataBean(Parcel in) {
            status = in.readInt();
            is_followed = in.readByte() != 0;
            current_user_id = in.readInt();
            media_id = in.readString();
            description = in.readString();
            apply_auth_url = in.readString();
            is_following = in.readByte() != 0;
            article_limit_enable = in.readInt();
            verified_agency = in.readString();
            bg_img_url = in.readString();
            verified_content = in.readString();
            screen_name = in.readString();
            pgc_like_count = in.readInt();
            visit_count_recent = in.readInt();
            user_verified = in.readByte() != 0;
            user_auth_info = in.readString();
            is_blocking = in.readInt();
            is_blocked = in.readInt();
            user_id = in.readLong();
            name = in.readString();
            big_avatar_url = in.readString();
            private_letter_permission = in.readInt();
            gender = in.readInt();
            apply_auth_entry_title = in.readString();
            share_url = in.readString();
            show_private_letter = in.readInt();
            ugc_publish_media_id = in.readLong();
            avatar_url = in.readString();
            followers_count = in.readString();
            media_type = in.readString();
            followings_count = in.readInt();
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeInt(status);
            dest.writeByte((byte) (is_followed ? 1 : 0));
            dest.writeInt(current_user_id);
            dest.writeString(media_id);
            dest.writeString(description);
            dest.writeString(apply_auth_url);
            dest.writeByte((byte) (is_following ? 1 : 0));
            dest.writeInt(article_limit_enable);
            dest.writeString(verified_agency);
            dest.writeString(bg_img_url);
            dest.writeString(verified_content);
            dest.writeString(screen_name);
            dest.writeInt(pgc_like_count);
            dest.writeInt(visit_count_recent);
            dest.writeByte((byte) (user_verified ? 1 : 0));
            dest.writeString(user_auth_info);
            dest.writeInt(is_blocking);
            dest.writeInt(is_blocked);
            dest.writeLong(user_id);
            dest.writeString(name);
            dest.writeString(big_avatar_url);
            dest.writeInt(private_letter_permission);
            dest.writeInt(gender);
            dest.writeString(apply_auth_entry_title);
            dest.writeString(share_url);
            dest.writeInt(show_private_letter);
            dest.writeLong(ugc_publish_media_id);
            dest.writeString(avatar_url);
            dest.writeString(followers_count);
            dest.writeString(media_type);
            dest.writeInt(followings_count);
        }

        @Override
        public int describeContents() {
            return 0;
        }

        public int getStatus() {
            return status;
        }

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

        public boolean isIs_followed() {
            return is_followed;
        }

        public void setIs_followed(boolean is_followed) {
            this.is_followed = is_followed;
        }

        public int getCurrent_user_id() {
            return current_user_id;
        }

        public void setCurrent_user_id(int current_user_id) {
            this.current_user_id = current_user_id;
        }

        public String getMedia_id() {
            return media_id;
        }

        public void setMedia_id(String media_id) {
            this.media_id = media_id;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getApply_auth_url() {
            return apply_auth_url;
        }

        public void setApply_auth_url(String apply_auth_url) {
            this.apply_auth_url = apply_auth_url;
        }

        public boolean isIs_following() {
            return is_following;
        }

        public void setIs_following(boolean is_following) {
            this.is_following = is_following;
        }

        public int getArticle_limit_enable() {
            return article_limit_enable;
        }

        public void setArticle_limit_enable(int article_limit_enable) {
            this.article_limit_enable = article_limit_enable;
        }

        public String getVerified_agency() {
            return verified_agency;
        }

        public void setVerified_agency(String verified_agency) {
            this.verified_agency = verified_agency;
        }

        public String getBg_img_url() {
            return bg_img_url;
        }

        public void setBg_img_url(String bg_img_url) {
            this.bg_img_url = bg_img_url;
        }

        public String getVerified_content() {
            return verified_content;
        }

        public void setVerified_content(String verified_content) {
            this.verified_content = verified_content;
        }

        public String getScreen_name() {
            return screen_name;
        }

        public void setScreen_name(String screen_name) {
            this.screen_name = screen_name;
        }

        public int getPgc_like_count() {
            return pgc_like_count;
        }

        public void setPgc_like_count(int pgc_like_count) {
            this.pgc_like_count = pgc_like_count;
        }

        public int getVisit_count_recent() {
            return visit_count_recent;
        }

        public void setVisit_count_recent(int visit_count_recent) {
            this.visit_count_recent = visit_count_recent;
        }

        public StarChartBean getStar_chart() {
            return star_chart;
        }

        public void setStar_chart(StarChartBean star_chart) {
            this.star_chart = star_chart;
        }

        public boolean isUser_verified() {
            return user_verified;
        }

        public void setUser_verified(boolean user_verified) {
            this.user_verified = user_verified;
        }

        public String getUser_auth_info() {
            return user_auth_info;
        }

        public void setUser_auth_info(String user_auth_info) {
            this.user_auth_info = user_auth_info;
        }

        public int getIs_blocking() {
            return is_blocking;
        }

        public void setIs_blocking(int is_blocking) {
            this.is_blocking = is_blocking;
        }

        public int getIs_blocked() {
            return is_blocked;
        }

        public void setIs_blocked(int is_blocked) {
            this.is_blocked = is_blocked;
        }

        public long getUser_id() {
            return user_id;
        }

        public void setUser_id(long user_id) {
            this.user_id = user_id;
        }

        public String getName() {
            return name;
        }

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

        public String getBig_avatar_url() {
            return big_avatar_url;
        }

        public void setBig_avatar_url(String big_avatar_url) {
            this.big_avatar_url = big_avatar_url;
        }

        public Object getArea() {
            return area;
        }

        public void setArea(Object area) {
            this.area = area;
        }

        public int getPrivate_letter_permission() {
            return private_letter_permission;
        }

        public void setPrivate_letter_permission(int private_letter_permission) {
            this.private_letter_permission = private_letter_permission;
        }

        public int getGender() {
            return gender;
        }

        public void setGender(int gender) {
            this.gender = gender;
        }

        public Object getIndustry() {
            return industry;
        }

        public void setIndustry(Object industry) {
            this.industry = industry;
        }

        public String getApply_auth_entry_title() {
            return apply_auth_entry_title;
        }

        public void setApply_auth_entry_title(String apply_auth_entry_title) {
            this.apply_auth_entry_title = apply_auth_entry_title;
        }

        public String getShare_url() {
            return share_url;
        }

        public void setShare_url(String share_url) {
            this.share_url = share_url;
        }

        public int getShow_private_letter() {
            return show_private_letter;
        }

        public void setShow_private_letter(int show_private_letter) {
            this.show_private_letter = show_private_letter;
        }

        public long getUgc_publish_media_id() {
            return ugc_publish_media_id;
        }

        public void setUgc_publish_media_id(long ugc_publish_media_id) {
            this.ugc_publish_media_id = ugc_publish_media_id;
        }

        public String getAvatar_url() {
            return avatar_url;
        }

        public void setAvatar_url(String avatar_url) {
            this.avatar_url = avatar_url;
        }

        public String getFollowers_count() {
            return followers_count;
        }

        public void setFollowers_count(String followers_count) {
            this.followers_count = followers_count;
        }

        public String getMedia_type() {
            return media_type;
        }

        public void setMedia_type(String media_type) {
            this.media_type = media_type;
        }

        public int getFollowings_count() {
            return followings_count;
        }

        public void setFollowings_count(int followings_count) {
            this.followings_count = followings_count;
        }

        public List<?> getBottom_tab() {
            return bottom_tab;
        }

        public void setBottom_tab(List<?> bottom_tab) {
            this.bottom_tab = bottom_tab;
        }

        public List<?> getCommon_friends() {
            return common_friends;
        }

        public void setCommon_friends(List<?> common_friends) {
            this.common_friends = common_friends;
        }

        public List<TopTabBean> getTop_tab() {
            return top_tab;
        }

        public void setTop_tab(List<TopTabBean> top_tab) {
            this.top_tab = top_tab;
        }

        public List<?> getMedals() {
            return medals;
        }

        public void setMedals(List<?> medals) {
            this.medals = medals;
        }

        public static class StarChartBean {
        }

        public static class TopTabBean {
            /**
             * url : http://issub.snssdk.com/dongtai/list/v8
             * is_default : false
             * show_name : 动态
             * type : dongtai
             */

            private String url;
            private boolean is_default;
            private String show_name;
            private String type;

            public String getUrl() {
                return url;
            }

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

            public boolean isIs_default() {
                return is_default;
            }

            public void setIs_default(boolean is_default) {
                this.is_default = is_default;
            }

            public String getShow_name() {
                return show_name;
            }

            public void setShow_name(String show_name) {
                this.show_name = show_name;
            }

            public String getType() {
                return type;
            }

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

 

 

3.3.而后看一下MultiMediaArticleBean类型的数据。 

 /**
     * media_id : 1562831380917250
     * has_more : 1
     * next : {"max_behot_time":1496726727}
     * page_type : 1
     * message : success
     * data:{}
     */

 

  而后是data 

 /**
         * item_status : 20
         * datetime : 2017-06-20 19:31
         * video_infos : []
         * has_m3u8_video : 0
         * keywords : 淘宝客,阿里妈妈
         * article_live_type : none
         * has_mp4_video : 0
         * title : 淘宝客每月扣除的10%真的合理吗?
         * source : 神勇依旧
         * natant_level : 0
         * own_group : false
         * share_count : 0
         * list_play_effective_count : 0
         * verify_detail : {"pass_time":"2017-06-20 19:32:29","auto":{"status":10},"editor":{"status":20}}
         * categories : ["news_tech/other","news_tech"]
         * repin_count : 4
         * display_status : 0
         * level : 0
         * digg_count : 0
         * comments_count : 1
         * cover_image_infos : [{"mimetype":"image/jpeg","image_type":1,"height":183,"width":1709,"web_uri":"289800014415a3581e72","desc":""},{"mimetype":"image/jpeg","image_type":1,"height":188,"width":1711,"web_uri":"289500042fec5ebb4c19","desc":""},{"mimetype":"image/jpeg","image_type":1,"height":576,"width":697,"web_uri":"2892000245cb9654fa20","desc":""}]
         * max_comments : 0
         * middle_image : http://p2.pstatp.com/list/2892000245cb9654fa20
         * pgc_id : 6433681916943140000
         * ad_type : 2
         * create_time : 1497958309
         * book_info :
         * article_sub_type : 0
         * label : ["科技"]
         * pgc_ad : 0
         * group_source : 2
         * image_url : http://p2.pstatp.com/list/2892000245cb9654fa20
         * is_key_item : 1
         * str_group_id : 6433679784035221761
         * source_url : http://is.snssdk.com/item/6433681916943139329/
         * item_id : 6433681916943140000
         * good_voice : false
         * group_id : 6433679784035222000
         * language : zh
         * display_url : http://toutiao.com/group/6433679784035221761/
         * region : 156
         * content_cards :
         * has_gallery : false
         * modify_time : 1497958355
         * content_cntw : 250
         * external_visit_count_format : 327
         * detail_mode : 0
         * impression_count : 4015
         * image_list : [{"url":"http://p2.pstatp.com/list/2892000245cb9654fa20","pc_url":"http://p2.pstatp.com/list/194x108/2892000245cb9654fa20"}]
         * str_item_id : 6433681916943139329
         * group_status : 1
         * creator_uid : 6619635172
         * original_media_id : 0
         * city :
         * bury_count : 0
         * web_article_type : 1
         * review_comment : false
         * comment_count : 1
         * internal_visit_count : 208
         * media_id : 1562831380917250
         * go_detail_count : 535
         * group_flags : 0
         * total_read_count : 535
         * detail_play_effective_count : 0
         * visibility : 3
         * pc_image_url : http://p2.pstatp.com/list/126x82/2892000245cb9654fa20
         * was_recommended : 1
         * thumb_image : [{"url":"http://p9.pstatp.com/thumb/289800014415a3581e72","width":1709,"url_list":[{"url":"http://p9.pstatp.com/thumb/289800014415a3581e72"},{"url":"http://pb1.pstatp.com/thumb/289800014415a3581e72"},{"url":"http://pb3.pstatp.com/thumb/289800014415a3581e72"}],"uri":"thumb/289800014415a3581e72","height":183},{"url":"http://p3.pstatp.com/thumb/289500042fec5ebb4c19","width":1711,"url_list":[{"url":"http://p3.pstatp.com/thumb/289500042fec5ebb4c19"},{"url":"http://pb9.pstatp.com/thumb/289500042fec5ebb4c19"},{"url":"http://pb1.pstatp.com/thumb/289500042fec5ebb4c19"}],"uri":"thumb/289500042fec5ebb4c19","height":188},{"url":"http://p1.pstatp.com/thumb/2892000245cb9654fa20","width":697,"url_list":[{"url":"http://p1.pstatp.com/thumb/2892000245cb9654fa20"},{"url":"http://pb3.pstatp.com/thumb/2892000245cb9654fa20"},{"url":"http://pb9.pstatp.com/thumb/2892000245cb9654fa20"}],"uri":"thumb/2892000245cb9654fa20","height":576}]
         * seo_url : http://is.snssdk.com/item/6433681916943139329/
         * external_visit_count : 327
         * image_detail : [{"url":"http://p9.pstatp.com/large/289800014415a3581e72","width":1709,"url_list":[{"url":"http://p9.pstatp.com/large/289800014415a3581e72"},{"url":"http://pb1.pstatp.com/large/289800014415a3581e72"},{"url":"http://pb3.pstatp.com/large/289800014415a3581e72"}],"uri":"large/289800014415a3581e72","height":183},{"url":"http://p3.pstatp.com/large/289500042fec5ebb4c19","width":1711,"url_list":[{"url":"http://p3.pstatp.com/large/289500042fec5ebb4c19"},{"url":"http://pb9.pstatp.com/large/289500042fec5ebb4c19"},{"url":"http://pb1.pstatp.com/large/289500042fec5ebb4c19"}],"uri":"large/289500042fec5ebb4c19","height":188},{"url":"http://p1.pstatp.com/large/2892000245cb9654fa20","width":697,"url_list":[{"url":"http://p1.pstatp.com/large/2892000245cb9654fa20"},{"url":"http://pb3.pstatp.com/large/2892000245cb9654fa20"},{"url":"http://pb9.pstatp.com/large/2892000245cb9654fa20"}],"uri":"large/2892000245cb9654fa20","height":576}]
         * ban_action : false
         * review_comment_mode : 0
         * has_inner_video : false
         * has_image : true
         * play_effective_count : 0
         * ban_comment : 0
         * abstract : 又到了阿里妈妈发工资的时间了,几家欢喜几家愁,对于一些大牛和老淘客来讲,今天和平时没啥区别,就是帐户多了不少数字。我有一个朋友初入淘客,今天一样的也去领薪水了,不过结果她很郁闷,为啥少了。因而乎我让她截图给我,因而我举例给她了。---- 我跟她说你,不要忘记看这个了。
         * middle_mode : true
         * is_original : false
         * ban_bury : false
         * article_type : 0
         * tag : news_tech
         * image_infos : [{"mimetype":"image/png","image_type":1,"height":183,"width":1709,"web_uri":"289800014415a3581e72","desc":""},{"mimetype":"image/png","image_type":1,"height":188,"width":1711,"web_uri":"289500042fec5ebb4c19","desc":""},{"mimetype":"image/png","image_type":1,"height":576,"width":697,"web_uri":"2892000245cb9654fa20","desc":""}]
         * optional_data : {"golden_second_awards":"0","pgc_source":"0"}
         * app_url : sslocal://detail?item_id=6433681916943139329&groupid=6433679784035221761&gd_label=click_pgc&aggr_type=2
         * internal_visit_count_format : 208
         * has_video : false
         * article_url : http://toutiao.com/group/6433679784035221761/
         * display_mode :
         * composition : 8
         * publish_time : 1497958302
         * wap_open : 0
         * tag_id : 6433679784035222000
         * pgc_article_type : 0
         * display_type : 0
         * gallery : []
         * detail_source : 神勇依旧
         * url : http://toutiao.com/group/6433679784035221761/
         * web_display_type : 4
         * behot_time : 1497958302
         * more_mode : true
         * show_play_effective_count : true
         * video_duration_str : 03:49
         * flags : 64
         */

 

  

3.4.而后根据数据来设置这个Bean类 

package com.meiji.toutiao.bean.media;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * Created by Meiji on 2017/7/1.
 */

public class MultiMediaArticleBean {

    /**
     * media_id : 1562831380917250
     * has_more : 1
     * next : {"max_behot_time":1496726727}
     * page_type : 1
     * message : success
     * data:{}
     */

    private long media_id;
    private String has_more;
    private NextBean next;
    private int page_type;
    private String message;
    private List<DataBean> data;

    public long getMedia_id() {
        return media_id;
    }

    public void setMedia_id(long media_id) {
        this.media_id = media_id;
    }

    public String getHas_more() {
        return has_more;
    }

    public void setHas_more(String has_more) {
        this.has_more = has_more;
    }

    public NextBean getNext() {
        return next;
    }

    public void setNext(NextBean next) {
        this.next = next;
    }

    public int getPage_type() {
        return page_type;
    }

    public void setPage_type(int page_type) {
        this.page_type = page_type;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public static class NextBean {
        /**
         * max_behot_time : 1496726727
         */

        private String max_behot_time;

        public String getMax_behot_time() {
            return max_behot_time;
        }

        public void setMax_behot_time(String max_behot_time) {
            this.max_behot_time = max_behot_time;
        }
    }

    public static class DataBean {
        /**
         * item_status : 20
         * datetime : 2017-06-20 19:31
         * video_infos : []
         * has_m3u8_video : 0
         * keywords : 淘宝客,阿里妈妈
         * article_live_type : none
         * has_mp4_video : 0
         * title : 淘宝客每月扣除的10%真的合理吗?
         * source : 神勇依旧
         * natant_level : 0
         * own_group : false
         * share_count : 0
         * list_play_effective_count : 0
         * verify_detail : {"pass_time":"2017-06-20 19:32:29","auto":{"status":10},"editor":{"status":20}}
         * categories : ["news_tech/other","news_tech"]
         * repin_count : 4
         * display_status : 0
         * level : 0
         * digg_count : 0
         * comments_count : 1
         * cover_image_infos : [{"mimetype":"image/jpeg","image_type":1,"height":183,"width":1709,"web_uri":"289800014415a3581e72","desc":""},{"mimetype":"image/jpeg","image_type":1,"height":188,"width":1711,"web_uri":"289500042fec5ebb4c19","desc":""},{"mimetype":"image/jpeg","image_type":1,"height":576,"width":697,"web_uri":"2892000245cb9654fa20","desc":""}]
         * max_comments : 0
         * middle_image : http://p2.pstatp.com/list/2892000245cb9654fa20
         * pgc_id : 6433681916943140000
         * ad_type : 2
         * create_time : 1497958309
         * book_info :
         * article_sub_type : 0
         * label : ["科技"]
         * pgc_ad : 0
         * group_source : 2
         * image_url : http://p2.pstatp.com/list/2892000245cb9654fa20
         * is_key_item : 1
         * str_group_id : 6433679784035221761
         * source_url : http://is.snssdk.com/item/6433681916943139329/
         * item_id : 6433681916943140000
         * good_voice : false
         * group_id : 6433679784035222000
         * language : zh
         * display_url : http://toutiao.com/group/6433679784035221761/
         * region : 156
         * content_cards :
         * has_gallery : false
         * modify_time : 1497958355
         * content_cntw : 250
         * external_visit_count_format : 327
         * detail_mode : 0
         * impression_count : 4015
         * image_list : [{"url":"http://p2.pstatp.com/list/2892000245cb9654fa20","pc_url":"http://p2.pstatp.com/list/194x108/2892000245cb9654fa20"}]
         * str_item_id : 6433681916943139329
         * group_status : 1
         * creator_uid : 6619635172
         * original_media_id : 0
         * city :
         * bury_count : 0
         * web_article_type : 1
         * review_comment : false
         * comment_count : 1
         * internal_visit_count : 208
         * media_id : 1562831380917250
         * go_detail_count : 535
         * group_flags : 0
         * total_read_count : 535
         * detail_play_effective_count : 0
         * visibility : 3
         * pc_image_url : http://p2.pstatp.com/list/126x82/2892000245cb9654fa20
         * was_recommended : 1
         * thumb_image : [{"url":"http://p9.pstatp.com/thumb/289800014415a3581e72","width":1709,"url_list":[{"url":"http://p9.pstatp.com/thumb/289800014415a3581e72"},{"url":"http://pb1.pstatp.com/thumb/289800014415a3581e72"},{"url":"http://pb3.pstatp.com/thumb/289800014415a3581e72"}],"uri":"thumb/289800014415a3581e72","height":183},{"url":"http://p3.pstatp.com/thumb/289500042fec5ebb4c19","width":1711,"url_list":[{"url":"http://p3.pstatp.com/thumb/289500042fec5ebb4c19"},{"url":"http://pb9.pstatp.com/thumb/289500042fec5ebb4c19"},{"url":"http://pb1.pstatp.com/thumb/289500042fec5ebb4c19"}],"uri":"thumb/289500042fec5ebb4c19","height":188},{"url":"http://p1.pstatp.com/thumb/2892000245cb9654fa20","width":697,"url_list":[{"url":"http://p1.pstatp.com/thumb/2892000245cb9654fa20"},{"url":"http://pb3.pstatp.com/thumb/2892000245cb9654fa20"},{"url":"http://pb9.pstatp.com/thumb/2892000245cb9654fa20"}],"uri":"thumb/2892000245cb9654fa20","height":576}]
         * seo_url : http://is.snssdk.com/item/6433681916943139329/
         * external_visit_count : 327
         * image_detail : [{"url":"http://p9.pstatp.com/large/289800014415a3581e72","width":1709,"url_list":[{"url":"http://p9.pstatp.com/large/289800014415a3581e72"},{"url":"http://pb1.pstatp.com/large/289800014415a3581e72"},{"url":"http://pb3.pstatp.com/large/289800014415a3581e72"}],"uri":"large/289800014415a3581e72","height":183},{"url":"http://p3.pstatp.com/large/289500042fec5ebb4c19","width":1711,"url_list":[{"url":"http://p3.pstatp.com/large/289500042fec5ebb4c19"},{"url":"http://pb9.pstatp.com/large/289500042fec5ebb4c19"},{"url":"http://pb1.pstatp.com/large/289500042fec5ebb4c19"}],"uri":"large/289500042fec5ebb4c19","height":188},{"url":"http://p1.pstatp.com/large/2892000245cb9654fa20","width":697,"url_list":[{"url":"http://p1.pstatp.com/large/2892000245cb9654fa20"},{"url":"http://pb3.pstatp.com/large/2892000245cb9654fa20"},{"url":"http://pb9.pstatp.com/large/2892000245cb9654fa20"}],"uri":"large/2892000245cb9654fa20","height":576}]
         * ban_action : false
         * review_comment_mode : 0
         * has_inner_video : false
         * has_image : true
         * play_effective_count : 0
         * ban_comment : 0
         * abstract : 又到了阿里妈妈发工资的时间了,几家欢喜几家愁,对于一些大牛和老淘客来讲,今天和平时没啥区别,就是帐户多了不少数字。我有一个朋友初入淘客,今天一样的也去领薪水了,不过结果她很郁闷,为啥少了。因而乎我让她截图给我,因而我举例给她了。---- 我跟她说你,不要忘记看这个了。
         * middle_mode : true
         * is_original : false
         * ban_bury : false
         * article_type : 0
         * tag : news_tech
         * image_infos : [{"mimetype":"image/png","image_type":1,"height":183,"width":1709,"web_uri":"289800014415a3581e72","desc":""},{"mimetype":"image/png","image_type":1,"height":188,"width":1711,"web_uri":"289500042fec5ebb4c19","desc":""},{"mimetype":"image/png","image_type":1,"height":576,"width":697,"web_uri":"2892000245cb9654fa20","desc":""}]
         * optional_data : {"golden_second_awards":"0","pgc_source":"0"}
         * app_url : sslocal://detail?item_id=6433681916943139329&groupid=6433679784035221761&gd_label=click_pgc&aggr_type=2
         * internal_visit_count_format : 208
         * has_video : false
         * article_url : http://toutiao.com/group/6433679784035221761/
         * display_mode :
         * composition : 8
         * publish_time : 1497958302
         * wap_open : 0
         * tag_id : 6433679784035222000
         * pgc_article_type : 0
         * display_type : 0
         * gallery : []
         * detail_source : 神勇依旧
         * url : http://toutiao.com/group/6433679784035221761/
         * web_display_type : 4
         * behot_time : 1497958302
         * more_mode : true
         * show_play_effective_count : true
         * video_duration_str : 03:49
         * flags : 64
         */

        private int item_status;
        private String datetime;
        private int has_m3u8_video;
        private String keywords;
        private String article_live_type;
        private int has_mp4_video;
        private String title;
        private String source;
        private int natant_level;
        private boolean own_group;
        private int share_count;
        private int list_play_effective_count;
        private VerifyDetailBean verify_detail;
        private int repin_count;
        private int display_status;
        private int level;
        private int digg_count;
        private String comments_count;
        private int max_comments;
        private String middle_image;
        private long pgc_id;
        private int ad_type;
        private int create_time;
        private String book_info;
        private int article_sub_type;
        private int pgc_ad;
        private int group_source;
        private String image_url;
        private int is_key_item;
        private String str_group_id;
        private String source_url;
        private long item_id;
        private boolean good_voice;
        private long group_id;
        private String language;
        private String display_url;
        private int region;
        private String content_cards;
        private boolean has_gallery;
        private int modify_time;
        private int content_cntw;
        private String external_visit_count_format;
        private int detail_mode;
        private int impression_count;
        private String str_item_id;
        private int group_status;
        private long creator_uid;
        private int original_media_id;
        private String city;
        private int bury_count;
        private int web_article_type;
        private boolean review_comment;
        private int comment_count;
        private int internal_visit_count;
        private long media_id;
        private String go_detail_count;
        private int group_flags;
        private int total_read_count;
        private int detail_play_effective_count;
        private int visibility;
        private String pc_image_url;
        private int was_recommended;
        private String seo_url;
        private int external_visit_count;
        private boolean ban_action;
        private int review_comment_mode;
        private boolean has_inner_video;
        private boolean has_image;
        private String play_effective_count;
        private int ban_comment;
        @SerializedName("abstract")
        private String abstractX;
        private boolean middle_mode;
        private boolean is_original;
        private boolean ban_bury;
        private int article_type;
        private String tag;
        private OptionalDataBean optional_data;
        private String app_url;
        private String internal_visit_count_format;
        private boolean has_video;
        private String article_url;
        private String display_mode;
        private int composition;
        private int publish_time;
        private int wap_open;
        private long tag_id;
        private int pgc_article_type;
        private int display_type;
        private String detail_source;
        private String url;
        private int web_display_type;
        private int behot_time;
        private boolean more_mode;
        private boolean show_play_effective_count;
        private String video_duration_str;
        private int flags;
        private List<VideoInfosBean> video_infos;
        private List<String> categories;
        private List<CoverImageInfosBean> cover_image_infos;
        private List<String> label;
        private List<ImageListBean> image_list;
        private List<ThumbImageBean> thumb_image;
        private List<ImageDetailBean> image_detail;
        private List<ImageInfosBean> image_infos;
        private List<?> gallery;

        public int getItem_status() {
            return item_status;
        }

        public void setItem_status(int item_status) {
            this.item_status = item_status;
        }

        public String getDatetime() {
            return datetime;
        }

        public void setDatetime(String datetime) {
            this.datetime = datetime;
        }

        public int getHas_m3u8_video() {
            return has_m3u8_video;
        }

        public void setHas_m3u8_video(int has_m3u8_video) {
            this.has_m3u8_video = has_m3u8_video;
        }

        public String getKeywords() {
            return keywords;
        }

        public void setKeywords(String keywords) {
            this.keywords = keywords;
        }

        public String getArticle_live_type() {
            return article_live_type;
        }

        public void setArticle_live_type(String article_live_type) {
            this.article_live_type = article_live_type;
        }

        public int getHas_mp4_video() {
            return has_mp4_video;
        }

        public void setHas_mp4_video(int has_mp4_video) {
            this.has_mp4_video = has_mp4_video;
        }

        public String getTitle() {
            return title;
        }

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

        public String getSource() {
            return source;
        }

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

        public int getNatant_level() {
            return natant_level;
        }

        public void setNatant_level(int natant_level) {
            this.natant_level = natant_level;
        }

        public boolean isOwn_group() {
            return own_group;
        }

        public void setOwn_group(boolean own_group) {
            this.own_group = own_group;
        }

        public int getShare_count() {
            return share_count;
        }

        public void setShare_count(int share_count) {
            this.share_count = share_count;
        }

        public int getList_play_effective_count() {
            return list_play_effective_count;
        }

        public void setList_play_effective_count(int list_play_effective_count) {
            this.list_play_effective_count = list_play_effective_count;
        }

        public VerifyDetailBean getVerify_detail() {
            return verify_detail;
        }

        public void setVerify_detail(VerifyDetailBean verify_detail) {
            this.verify_detail = verify_detail;
        }

        public int getRepin_count() {
            return repin_count;
        }

        public void setRepin_count(int repin_count) {
            this.repin_count = repin_count;
        }

        public int getDisplay_status() {
            return display_status;
        }

        public void setDisplay_status(int display_status) {
            this.display_status = display_status;
        }

        public int getLevel() {
            return level;
        }

        public void setLevel(int level) {
            this.level = level;
        }

        public int getDigg_count() {
            return digg_count;
        }

        public void setDigg_count(int digg_count) {
            this.digg_count = digg_count;
        }

        public String getComments_count() {
            return comments_count;
        }

        public void setComments_count(String comments_count) {
            this.comments_count = comments_count;
        }

        public int getMax_comments() {
            return max_comments;
        }

        public void setMax_comments(int max_comments) {
            this.max_comments = max_comments;
        }

        public String getMiddle_image() {
            return middle_image;
        }

        public void setMiddle_image(String middle_image) {
            this.middle_image = middle_image;
        }

        public long getPgc_id() {
            return pgc_id;
        }

        public void setPgc_id(long pgc_id) {
            this.pgc_id = pgc_id;
        }

        public int getAd_type() {
            return ad_type;
        }

        public void setAd_type(int ad_type) {
            this.ad_type = ad_type;
        }

        public int getCreate_time() {
            return create_time;
        }

        public void setCreate_time(int create_time) {
            this.create_time = create_time;
        }

        public String getBook_info() {
            return book_info;
        }

        public void setBook_info(String book_info) {
            this.book_info = book_info;
        }

        public int getArticle_sub_type() {
            return article_sub_type;
        }

        public void setArticle_sub_type(int article_sub_type) {
            this.article_sub_type = article_sub_type;
        }

        public int getPgc_ad() {
            return pgc_ad;
        }

        public void setPgc_ad(int pgc_ad) {
            this.pgc_ad = pgc_ad;
        }

        public int getGroup_source() {
            return group_source;
        }

        public void setGroup_source(int group_source) {
            this.group_source = group_source;
        }

        public String getImage_url() {
            return image_url;
        }

        public void setImage_url(String image_url) {
            this.image_url = image_url;
        }

        public int getIs_key_item() {
            return is_key_item;
        }

        public void setIs_key_item(int is_key_item) {
            this.is_key_item = is_key_item;
        }

        public String getStr_group_id() {
            return str_group_id;
        }

        public void setStr_group_id(String str_group_id) {
            this.str_group_id = str_group_id;
        }

        public String getSource_url() {
            return source_url;
        }

        public void setSource_url(String source_url) {
            this.source_url = source_url;
        }

        public long getItem_id() {
            return item_id;
        }

        public void setItem_id(long item_id) {
            this.item_id = item_id;
        }

        public boolean isGood_voice() {
            return good_voice;
        }

        public void setGood_voice(boolean good_voice) {
            this.good_voice = good_voice;
        }

        public long getGroup_id() {
            return group_id;
        }

        public void setGroup_id(long group_id) {
            this.group_id = group_id;
        }

        public String getLanguage() {
            return language;
        }

        public void setLanguage(String language) {
            this.language = language;
        }

        public String getDisplay_url() {
            return display_url;
        }

        public void setDisplay_url(String display_url) {
            this.display_url = display_url;
        }

        public int getRegion() {
            return region;
        }

        public void setRegion(int region) {
            this.region = region;
        }

        public String getContent_cards() {
            return content_cards;
        }

        public void setContent_cards(String content_cards) {
            this.content_cards = content_cards;
        }

        public boolean isHas_gallery() {
            return has_gallery;
        }

        public void setHas_gallery(boolean has_gallery) {
            this.has_gallery = has_gallery;
        }

        public int getModify_time() {
            return modify_time;
        }

        public void setModify_time(int modify_time) {
            this.modify_time = modify_time;
        }

        public int getContent_cntw() {
            return content_cntw;
        }

        public void setContent_cntw(int content_cntw) {
            this.content_cntw = content_cntw;
        }

        public String getExternal_visit_count_format() {
            return external_visit_count_format;
        }

        public void setExternal_visit_count_format(String external_visit_count_format) {
            this.external_visit_count_format = external_visit_count_format;
        }

        public int getDetail_mode() {
            return detail_mode;
        }

        public void setDetail_mode(int detail_mode) {
            this.detail_mode = detail_mode;
        }

        public int getImpression_count() {
            return impression_count;
        }

        public void setImpression_count(int impression_count) {
            this.impression_count = impression_count;
        }

        public String getStr_item_id() {
            return str_item_id;
        }

        public void setStr_item_id(String str_item_id) {
            this.str_item_id = str_item_id;
        }

        public int getGroup_status() {
            return group_status;
        }

        public void setGroup_status(int group_status) {
            this.group_status = group_status;
        }

        public long getCreator_uid() {
            return creator_uid;
        }

        public void setCreator_uid(long creator_uid) {
            this.creator_uid = creator_uid;
        }

        public int getOriginal_media_id() {
            return original_media_id;
        }

        public void setOriginal_media_id(int original_media_id) {
            this.original_media_id = original_media_id;
        }

        public String getCity() {
            return city;
        }

        public void setCity(String city) {
            this.city = city;
        }

        public int getBury_count() {
            return bury_count;
        }

        public void setBury_count(int bury_count) {
            this.bury_count = bury_count;
        }

        public int getWeb_article_type() {
            return web_article_type;
        }

        public void setWeb_article_type(int web_article_type) {
            this.web_article_type = web_article_type;
        }

        public boolean isReview_comment() {
            return review_comment;
        }

        public void setReview_comment(boolean review_comment) {
            this.review_comment = review_comment;
        }

        public int getComment_count() {
            return comment_count;
        }

        public void setComment_count(int comment_count) {
            this.comment_count = comment_count;
        }

        public int getInternal_visit_count() {
            return internal_visit_count;
        }

        public void setInternal_visit_count(int internal_visit_count) {
            this.internal_visit_count = internal_visit_count;
        }

        public long getMedia_id() {
            return media_id;
        }

        public void setMedia_id(long media_id) {
            this.media_id = media_id;
        }

        public String getGo_detail_count() {
            return go_detail_count;
        }

        public void setGo_detail_count(String go_detail_count) {
            this.go_detail_count = go_detail_count;
        }

        public int getGroup_flags() {
            return group_flags;
        }

        public void setGroup_flags(int group_flags) {
            this.group_flags = group_flags;
        }

        public int getTotal_read_count() {
            return total_read_count;
        }

        public void setTotal_read_count(int total_read_count) {
            this.total_read_count = total_read_count;
        }

        public int getDetail_play_effective_count() {
            return detail_play_effective_count;
        }

        public void setDetail_play_effective_count(int detail_play_effective_count) {
            this.detail_play_effective_count = detail_play_effective_count;
        }

        public int getVisibility() {
            return visibility;
        }

        public void setVisibility(int visibility) {
            this.visibility = visibility;
        }

        public String getPc_image_url() {
            return pc_image_url;
        }

        public void setPc_image_url(String pc_image_url) {
            this.pc_image_url = pc_image_url;
        }

        public int getWas_recommended() {
            return was_recommended;
        }

        public void setWas_recommended(int was_recommended) {
            this.was_recommended = was_recommended;
        }

        public String getSeo_url() {
            return seo_url;
        }

        public void setSeo_url(String seo_url) {
            this.seo_url = seo_url;
        }

        public int getExternal_visit_count() {
            return external_visit_count;
        }

        public void setExternal_visit_count(int external_visit_count) {
            this.external_visit_count = external_visit_count;
        }

        public boolean isBan_action() {
            return ban_action;
        }

        public void setBan_action(boolean ban_action) {
            this.ban_action = ban_action;
        }

        public int getReview_comment_mode() {
            return review_comment_mode;
        }

        public void setReview_comment_mode(int review_comment_mode) {
            this.review_comment_mode = review_comment_mode;
        }

        public boolean isHas_inner_video() {
            return has_inner_video;
        }

        public void setHas_inner_video(boolean has_inner_video) {
            this.has_inner_video = has_inner_video;
        }

        public boolean isHas_image() {
            return has_image;
        }

        public void setHas_image(boolean has_image) {
            this.has_image = has_image;
        }

        public String getPlay_effective_count() {
            return play_effective_count;
        }

        public void setPlay_effective_count(String play_effective_count) {
            this.play_effective_count = play_effective_count;
        }

        public int getBan_comment() {
            return ban_comment;
        }

        public void setBan_comment(int ban_comment) {
            this.ban_comment = ban_comment;
        }

        public String getAbstractX() {
            return abstractX;
        }

        public void setAbstractX(String abstractX) {
            this.abstractX = abstractX;
        }

        public boolean isMiddle_mode() {
            return middle_mode;
        }

        public void setMiddle_mode(boolean middle_mode) {
            this.middle_mode = middle_mode;
        }

        public boolean isIs_original() {
            return is_original;
        }

        public void setIs_original(boolean is_original) {
            this.is_original = is_original;
        }

        public boolean isBan_bury() {
            return ban_bury;
        }

        public void setBan_bury(boolean ban_bury) {
            this.ban_bury = ban_bury;
        }

        public int getArticle_type() {
            return article_type;
        }

        public void setArticle_type(int article_type) {
            this.article_type = article_type;
        }

        public String getTag() {
            return tag;
        }

        public void setTag(String tag) {
            this.tag = tag;
        }

        public OptionalDataBean getOptional_data() {
            return optional_data;
        }

        public void setOptional_data(OptionalDataBean optional_data) {
            this.optional_data = optional_data;
        }

        public String getApp_url() {
            return app_url;
        }

        public void setApp_url(String app_url) {
            this.app_url = app_url;
        }

        public String getInternal_visit_count_format() {
            return internal_visit_count_format;
        }

        public void setInternal_visit_count_format(String internal_visit_count_format) {
            this.internal_visit_count_format = internal_visit_count_format;
        }

        public boolean isHas_video() {
            return has_video;
        }

        public void setHas_video(boolean has_video) {
            this.has_video = has_video;
        }

        public String getArticle_url() {
            return article_url;
        }

        public void setArticle_url(String article_url) {
            this.article_url = article_url;
        }

        public String getDisplay_mode() {
            return display_mode;
        }

        public void setDisplay_mode(String display_mode) {
            this.display_mode = display_mode;
        }

        public int getComposition() {
            return composition;
        }

        public void setComposition(int composition) {
            this.composition = composition;
        }

        public int getPublish_time() {
            return publish_time;
        }

        public void setPublish_time(int publish_time) {
            this.publish_time = publish_time;
        }

        public int getWap_open() {
            return wap_open;
        }

        public void setWap_open(int wap_open) {
            this.wap_open = wap_open;
        }

        public long getTag_id() {
            return tag_id;
        }

        public void setTag_id(long tag_id) {
            this.tag_id = tag_id;
        }

        public int getPgc_article_type() {
            return pgc_article_type;
        }

        public void setPgc_article_type(int pgc_article_type) {
            this.pgc_article_type = pgc_article_type;
        }

        public int getDisplay_type() {
            return display_type;
        }

        public void setDisplay_type(int display_type) {
            this.display_type = display_type;
        }

        public String getDetail_source() {
            return detail_source;
        }

        public void setDetail_source(String detail_source) {
            this.detail_source = detail_source;
        }

        public String getUrl() {
            return url;
        }

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

        public int getWeb_display_type() {
            return web_display_type;
        }

        public void setWeb_display_type(int web_display_type) {
            this.web_display_type = web_display_type;
        }

        public int getBehot_time() {
            return behot_time;
        }

        public void setBehot_time(int behot_time) {
            this.behot_time = behot_time;
        }

        public boolean isMore_mode() {
            return more_mode;
        }

        public void setMore_mode(boolean more_mode) {
            this.more_mode = more_mode;
        }

        public boolean isShow_play_effective_count() {
            return show_play_effective_count;
        }

        public void setShow_play_effective_count(boolean show_play_effective_count) {
            this.show_play_effective_count = show_play_effective_count;
        }

        public String getVideo_duration_str() {
            return video_duration_str;
        }

        public void setVideo_duration_str(String video_duration_str) {
            this.video_duration_str = video_duration_str;
        }

        public int getFlags() {
            return flags;
        }

        public void setFlags(int flags) {
            this.flags = flags;
        }

        public List<VideoInfosBean> getVideo_infos() {
            return video_infos;
        }

        public void setVideo_infos(List<VideoInfosBean> video_infos) {
            this.video_infos = video_infos;
        }

        public List<String> getCategories() {
            return categories;
        }

        public void setCategories(List<String> categories) {
            this.categories = categories;
        }

        public List<CoverImageInfosBean> getCover_image_infos() {
            return cover_image_infos;
        }

        public void setCover_image_infos(List<CoverImageInfosBean> cover_image_infos) {
            this.cover_image_infos = cover_image_infos;
        }

        public List<String> getLabel() {
            return label;
        }

        public void setLabel(List<String> label) {
            this.label = label;
        }

        public List<ImageListBean> getImage_list() {
            return image_list;
        }

        public void setImage_list(List<ImageListBean> image_list) {
            this.image_list = image_list;
        }

        public List<ThumbImageBean> getThumb_image() {
            return thumb_image;
        }

        public void setThumb_image(List<ThumbImageBean> thumb_image) {
            this.thumb_image = thumb_image;
        }

        public List<ImageDetailBean> getImage_detail() {
            return image_detail;
        }

        public void setImage_detail(List<ImageDetailBean> image_detail) {
            this.image_detail = image_detail;
        }

        public List<ImageInfosBean> getImage_infos() {
            return image_infos;
        }

        public void setImage_infos(List<ImageInfosBean> image_infos) {
            this.image_infos = image_infos;
        }

        public List<?> getGallery() {
            return gallery;
        }

        public void setGallery(List<?> gallery) {
            this.gallery = gallery;
        }

        public static class VerifyDetailBean {
            /**
             * pass_time : 2017-06-20 19:32:29
             * auto : {"status":10}
             * editor : {"status":20}
             */

            private String pass_time;
            private AutoBean auto;
            private EditorBean editor;

            public String getPass_time() {
                return pass_time;
            }

            public void setPass_time(String pass_time) {
                this.pass_time = pass_time;
            }

            public AutoBean getAuto() {
                return auto;
            }

            public void setAuto(AutoBean auto) {
                this.auto = auto;
            }

            public EditorBean getEditor() {
                return editor;
            }

            public void setEditor(EditorBean editor) {
                this.editor = editor;
            }

            public static class AutoBean {
                /**
                 * status : 10
                 */

                private int status;

                public int getStatus() {
                    return status;
                }

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

            public static class EditorBean {
                /**
                 * status : 20
                 */

                private int status;

                public int getStatus() {
                    return status;
                }

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

        public static class OptionalDataBean {
            /**
             * golden_second_awards : 0
             * pgc_source : 0
             */

            private String golden_second_awards;
            private String pgc_source;

            public String getGolden_second_awards() {
                return golden_second_awards;
            }

            public void setGolden_second_awards(String golden_second_awards) {
                this.golden_second_awards = golden_second_awards;
            }

            public String getPgc_source() {
                return pgc_source;
            }

            public void setPgc_source(String pgc_source) {
                this.pgc_source = pgc_source;
            }
        }

        public static class VideoInfosBean {
            /**
             * thumb_height : 626
             * sp : toutiao
             * vid : 4becfef9e95d4152beab7f360270dacb
             * thumb_width : 360
             * video_partner : 0
             * duration : 229
             * thumb_url : 28500007053c906d74f7
             * video_size : {"high":{"h":640,"subjective_score":0,"w":368,"file_size":18369097},"normal":{"h":626,"subjective_score":0,"w":360,"file_size":16674479}}
             * vu : 4becfef9e95d4152beab7f360270dacb
             */

            private int thumb_height;
            private String sp;
            private String vid;
            private int thumb_width;
            private int video_partner;
            private int duration;
            private String thumb_url;
            private VideoSizeBean video_size;
            private String vu;

            public int getThumb_height() {
                return thumb_height;
            }

            public void setThumb_height(int thumb_height) {
                this.thumb_height = thumb_height;
            }

            public String getSp() {
                return sp;
            }

            public void setSp(String sp) {
                this.sp = sp;
            }

            public String getVid() {
                return vid;
            }

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

            public int getThumb_width() {
                return thumb_width;
            }

            public void setThumb_width(int thumb_width) {
                this.thumb_width = thumb_width;
            }

            public int getVideo_partner() {
                return video_partner;
            }

            public void setVideo_partner(int video_partner) {
                this.video_partner = video_partner;
            }

            public int getDuration() {
                return duration;
            }

            public void setDuration(int duration) {
                this.duration = duration;
            }

            public String getThumb_url() {
                return thumb_url;
            }

            public void setThumb_url(String thumb_url) {
                this.thumb_url = thumb_url;
            }

            public VideoSizeBean getVideo_size() {
                return video_size;
            }

            public void setVideo_size(VideoSizeBean video_size) {
                this.video_size = video_size;
            }

            public String getVu() {
                return vu;
            }

            public void setVu(String vu) {
                this.vu = vu;
            }

            public static class VideoSizeBean {
                /**
                 * high : {"h":640,"subjective_score":0,"w":368,"file_size":18369097}
                 * normal : {"h":626,"subjective_score":0,"w":360,"file_size":16674479}
                 */

                private HighBean high;
                private NormalBean normal;

                public HighBean getHigh() {
                    return high;
                }

                public void setHigh(HighBean high) {
                    this.high = high;
                }

                public NormalBean getNormal() {
                    return normal;
                }

                public void setNormal(NormalBean normal) {
                    this.normal = normal;
                }

                public static class HighBean {
                    /**
                     * h : 640
                     * subjective_score : 0
                     * w : 368
                     * file_size : 18369097
                     */

                    private int h;
                    private int subjective_score;
                    private int w;
                    private int file_size;

                    public int getH() {
                        return h;
                    }

                    public void setH(int h) {
                        this.h = h;
                    }

                    public int getSubjective_score() {
                        return subjective_score;
                    }

                    public void setSubjective_score(int subjective_score) {
                        this.subjective_score = subjective_score;
                    }

                    public int getW() {
                        return w;
                    }

                    public void setW(int w) {
                        this.w = w;
                    }

                    public int getFile_size() {
                        return file_size;
                    }

                    public void setFile_size(int file_size) {
                        this.file_size = file_size;
                    }
                }

                public static class NormalBean {
                    /**
                     * h : 626
                     * subjective_score : 0
                     * w : 360
                     * file_size : 16674479
                     */

                    private int h;
                    private int subjective_score;
                    private int w;
                    private int file_size;

                    public int getH() {
                        return h;
                    }

                    public void setH(int h) {
                        this.h = h;
                    }

                    public int getSubjective_score() {
                        return subjective_score;
                    }

                    public void setSubjective_score(int subjective_score) {
                        this.subjective_score = subjective_score;
                    }

                    public int getW() {
                        return w;
                    }

                    public void setW(int w) {
                        this.w = w;
                    }

                    public int getFile_size() {
                        return file_size;
                    }

                    public void setFile_size(int file_size) {
                        this.file_size = file_size;
                    }
                }
            }
        }

        public static class CoverImageInfosBean {
            /**
             * mimetype : image/jpeg
             * image_type : 1
             * height : 183
             * width : 1709
             * web_uri : 289800014415a3581e72
             * desc :
             */

            private String mimetype;
            private int image_type;
            private int height;
            private int width;
            private String web_uri;
            private String desc;

            public String getMimetype() {
                return mimetype;
            }

            public void setMimetype(String mimetype) {
                this.mimetype = mimetype;
            }

            public int getImage_type() {
                return image_type;
            }

            public void setImage_type(int image_type) {
                this.image_type = image_type;
            }

            public int getHeight() {
                return height;
            }

            public void setHeight(int height) {
                this.height = height;
            }

            public int getWidth() {
                return width;
            }

            public void setWidth(int width) {
                this.width = width;
            }

            public String getWeb_uri() {
                return web_uri;
            }

            public void setWeb_uri(String web_uri) {
                this.web_uri = web_uri;
            }

            public String getDesc() {
                return desc;
            }

            public void setDesc(String desc) {
                this.desc = desc;
            }
        }

        public static class ImageListBean {
            /**
             * url : http://p2.pstatp.com/list/2892000245cb9654fa20
             * pc_url : http://p2.pstatp.com/list/194x108/2892000245cb9654fa20
             */

            private String url;
            private String pc_url;

            public String getUrl() {
                return url;
            }

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

            public String getPc_url() {
                return pc_url;
            }

            public void setPc_url(String pc_url) {
                this.pc_url = pc_url;
            }
        }

        public static class ThumbImageBean {
            /**
             * url : http://p9.pstatp.com/thumb/289800014415a3581e72
             * width : 1709
             * url_list : [{"url":"http://p9.pstatp.com/thumb/289800014415a3581e72"},{"url":"http://pb1.pstatp.com/thumb/289800014415a3581e72"},{"url":"http://pb3.pstatp.com/thumb/289800014415a3581e72"}]
             * uri : thumb/289800014415a3581e72
             * height : 183
             */

            private String url;
            private int width;
            private String uri;
            private int height;
            private List<UrlListBean> url_list;

            public String getUrl() {
                return url;
            }

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

            public int getWidth() {
                return width;
            }

            public void setWidth(int width) {
                this.width = width;
            }

            public String getUri() {
                return uri;
            }

            public void setUri(String uri) {
                this.uri = uri;
            }

            public int getHeight() {
                return height;
            }

            public void setHeight(int height) {
                this.height = height;
            }

            public List<UrlListBean> getUrl_list() {
                return url_list;
            }

            public void setUrl_list(List<UrlListBean> url_list) {
                this.url_list = url_list;
            }

            public static class UrlListBean {
                /**
                 * url : http://p9.pstatp.com/thumb/289800014415a3581e72
                 */

                private String url;

                public String getUrl() {
                    return url;
                }

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

        public static class ImageDetailBean {
            /**
             * url : http://p9.pstatp.com/large/289800014415a3581e72
             * width : 1709
             * url_list : [{"url":"http://p9.pstatp.com/large/289800014415a3581e72"},{"url":"http://pb1.pstatp.com/large/289800014415a3581e72"},{"url":"http://pb3.pstatp.com/large/289800014415a3581e72"}]
             * uri : large/289800014415a3581e72
             * height : 183
             */

            private String url;
            private int width;
            private String uri;
            private int height;
            private List<UrlListBeanX> url_list;

            public String getUrl() {
                return url;
            }

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

            public int getWidth() {
                return width;
            }

            public void setWidth(int width) {
                this.width = width;
            }

            public String getUri() {
                return uri;
            }

            public void setUri(String uri) {
                this.uri = uri;
            }

            public int getHeight() {
                return height;
            }

            public void setHeight(int height) {
                this.height = height;
            }

            public List<UrlListBeanX> getUrl_list() {
                return url_list;
            }

            public void setUrl_list(List<UrlListBeanX> url_list) {
                this.url_list = url_list;
            }

            public static class UrlListBeanX {
                /**
                 * url : http://p9.pstatp.com/large/289800014415a3581e72
                 */

                private String url;

                public String getUrl() {
                    return url;
                }

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

        public static class ImageInfosBean {
            /**
             * mimetype : image/png
             * image_type : 1
             * height : 183
             * width : 1709
             * web_uri : 289800014415a3581e72
             * desc :
             */

            private String mimetype;
            private int image_type;
            private int height;
            private int width;
            private String web_uri;
            private String desc;

            public String getMimetype() {
                return mimetype;
            }

            public void setMimetype(String mimetype) {
                this.mimetype = mimetype;
            }

            public int getImage_type() {
                return image_type;
            }

            public void setImage_type(int image_type) {
                this.image_type = image_type;
            }

            public int getHeight() {
                return height;
            }

            public void setHeight(int height) {
                this.height = height;
            }

            public int getWidth() {
                return width;
            }

            public void setWidth(int width) {
                this.width = width;
            }

            public String getWeb_uri() {
                return web_uri;
            }

            public void setWeb_uri(String web_uri) {
                this.web_uri = web_uri;
            }

            public String getDesc() {
                return desc;
            }

            public void setDesc(String desc) {
                this.desc = desc;
            }
        }
    }
}
View Code

 

 

3.5.而后看一下Media问答返回的数据

 /**
     * cursor : 6428403867490189569
     * err_no : 0
     * err_tips :
     * api_param : {"origin_from":"out_wenda","enter_from":"out_wenda"}
     * has_more : 1
     * login_user : {}
     * total : 185
     * user_data : {"all_brow_cnt_str":"","is_verify":0,"curretn_month_digg_cnt_str":"本月共0人点赞","all_digg_cnt_str":"","current_month_brow_cnt":"0","youzhi_info":[],"laomo_info":[],"uname":"","all_brow_cnt":"0","is_valid":0,"current_month_brow_cnt_str":"本月共0人浏览","user_intro":"","current_month_digg_cnt":"0","all_digg_cnt":"0","user_profile_image_url":"","ming_ren_tang":"","schema":""}
     * can_ask : false
     * answer_question:[]
     * 
     */

 

 

3.6.根据返回类型设置多媒体问答Bean类 

public class MediaWendaBean {

    /**
     * cursor : 6428403867490189569
     * err_no : 0
     * err_tips :
     * api_param : {"origin_from":"out_wenda","enter_from":"out_wenda"}
     * has_more : 1
     * login_user : {}
     * total : 185
     * user_data : {"all_brow_cnt_str":"","is_verify":0,"curretn_month_digg_cnt_str":"本月共0人点赞","all_digg_cnt_str":"","current_month_brow_cnt":"0","youzhi_info":[],"laomo_info":[],"uname":"","all_brow_cnt":"0","is_valid":0,"current_month_brow_cnt_str":"本月共0人浏览","user_intro":"","current_month_digg_cnt":"0","all_digg_cnt":"0","user_profile_image_url":"","ming_ren_tang":"","schema":""}
     * can_ask : false
     * answer_question:[]
     *
     */

    private String cursor;
    private int err_no;
    private String err_tips;
    //    private boolean has_more;
    private int total;
    private boolean can_ask;
    private List<AnswerQuestionBean> answer_question;

    public String getCursor() {
        return cursor;
    }

    public void setCursor(String cursor) {
        this.cursor = cursor;
    }

    public int getErr_no() {
        return err_no;
    }

    public void setErr_no(int err_no) {
        this.err_no = err_no;
    }

    public String getErr_tips() {
        return err_tips;
    }

    public void setErr_tips(String err_tips) {
        this.err_tips = err_tips;
    }

//    public boolean getHas_more() {
//        return has_more;
//    }

//    public void setHas_more(boolean has_more) {
//        this.has_more = has_more;
//    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public boolean isCan_ask() {
        return can_ask;
    }

    public void setCan_ask(boolean can_ask) {
        this.can_ask = can_ask;
    }

    public List<AnswerQuestionBean> getAnswer_question() {
        return answer_question;
    }

    public void setAnswer_question(List<AnswerQuestionBean> answer_question) {
        this.answer_question = answer_question;
    }

    public static class AnswerQuestionBean {
        /**
         */

        private AnswerBean answer;
        private QuestionBean question;

        public AnswerBean getAnswer() {
            return answer;
        }

        public void setAnswer(AnswerBean answer) {
            this.answer = answer;
        }

        public QuestionBean getQuestion() {
            return question;
        }

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

        public static class AnswerBean {
            /**
             * show_time : 2017.06.22
             * content_abstract : {"text":"这个问题的发问,仍是围绕在卡上面。若是证实身份的方式不在是这张卡,而是你的眼角膜,或是指纹,那么全部录入的信息就能够经过你证实的物件来提取了,还要看整个社会在一个什么高度。若是一卡在手,那若是遗失了,就很麻烦了。卡的合并,那么这个办卡的部门也须要合并,这个是个大工程了。若是身份证,是你身体的一部分,那么,什么都简单了。","thumb_image_list":[{"url":"http://p3.pstatp.com/list/r555/289d0019a74b9a89ddfe","url_list":[{"url":"http://p3.pstatp.com/list/r555/289d0019a74b9a89ddfe"},{"url":"http://pb9.pstatp.com/list/r555/289d0019a74b9a89ddfe"},{"url":"http://pb3.pstatp.com/list/r555/289d0019a74b9a89ddfe"}],"uri":"list/r555/289d0019a74b9a89ddfe","height":555,"width":354,"type":1}],"large_image_list":[{"url":"http://p3.pstatp.com/large/289d0019a74b9a89ddfe","url_list":[{"url":"http://p3.pstatp.com/large/289d0019a74b9a89ddfe"},{"url":"http://pb9.pstatp.com/large/289d0019a74b9a89ddfe"},{"url":"http://pb3.pstatp.com/large/289d0019a74b9a89ddfe"}],"uri":"large/289d0019a74b9a89ddfe","height":555,"width":354,"type":1}]}
             * user : {"uname":"神勇依旧","avatar_url":"http://p3.pstatp.com/thumb/1a6a000adbc3a1f0a4c5","user_id":"6619635172","is_verify":0,"create_time":1464350006,"user_intro":"","user_auth_info":"","schema":"sslocal://profile?uid=6619635172&refer=wenda"}
             * ans_url : https://ic.snssdk.com/wenda/v1/wapanswer/content/?ansid=6434402977758314753
             * ansid : 6434402977758314753
             * is_show_bury : false
             * wap_url : https://wenda.toutiao.com/m/wapshare/answer/brow/?ansid=6434402977758314753&
             * is_buryed : false
             * bury_count : 0
             * title :
             * is_delete : 0
             * digg_count : 0
             * content : <p><p>这个问题的发问,仍是围绕在卡上面。若是证实身份的方式不在是这张卡,而是你的眼角膜,或是指纹,那么全部录入的信息就能够经过你证实的物件来提取了,还要看整个社会在一个什么高度。若是一卡在手,那若是遗失了,就很麻烦了。卡的合并,那么这个办卡的部门也须要合并,这个是个大工程了。若是身份证,是你身体的一部分,那么,什么都简单了。</p><br/><img src="http://p3.pstatp.com/origin/289d0019a74b9a89ddfe" img_width="354" img_height="555" onerror="javascript:errorimg.call(this);" ></p>
             * brow_count : 18
             * is_digg : false
             * schema : sslocal://wenda_detail?ansid=6434402977758314753
             */

            private String show_time;
            private ContentAbstractBean content_abstract;
            private UserBean user;
            private String ans_url;
            private String ansid;
            private boolean is_show_bury;
            private String wap_url;
            private boolean is_buryed;
            private int bury_count;
            private String title;
            private int is_delete;
            private int digg_count;
            private String content;
            private int brow_count;
            private boolean is_digg;
            private String schema;

            public String getShow_time() {
                return show_time;
            }

            public void setShow_time(String show_time) {
                this.show_time = show_time;
            }

            public ContentAbstractBean getContent_abstract() {
                return content_abstract;
            }

            public void setContent_abstract(ContentAbstractBean content_abstract) {
                this.content_abstract = content_abstract;
            }

            public UserBean getUser() {
                return user;
            }

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

            public String getAns_url() {
                return ans_url;
            }

            public void setAns_url(String ans_url) {
                this.ans_url = ans_url;
            }

            public String getAnsid() {
                return ansid;
            }

            public void setAnsid(String ansid) {
                this.ansid = ansid;
            }

            public boolean isIs_show_bury() {
                return is_show_bury;
            }

            public void setIs_show_bury(boolean is_show_bury) {
                this.is_show_bury = is_show_bury;
            }

            public String getWap_url() {
                return wap_url;
            }

            public void setWap_url(String wap_url) {
                this.wap_url = wap_url;
            }

            public boolean isIs_buryed() {
                return is_buryed;
            }

            public void setIs_buryed(boolean is_buryed) {
                this.is_buryed = is_buryed;
            }

            public int getBury_count() {
                return bury_count;
            }

            public void setBury_count(int bury_count) {
                this.bury_count = bury_count;
            }

            public String getTitle() {
                return title;
            }

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

            public int getIs_delete() {
                return is_delete;
            }

            public void setIs_delete(int is_delete) {
                this.is_delete = is_delete;
            }

            public int getDigg_count() {
                return digg_count;
            }

            public void setDigg_count(int digg_count) {
                this.digg_count = digg_count;
            }

            public String getContent() {
                return content;
            }

            public void setContent(String content) {
                this.content = content;
            }

            public int getBrow_count() {
                return brow_count;
            }

            public void setBrow_count(int brow_count) {
                this.brow_count = brow_count;
            }

            public boolean isIs_digg() {
                return is_digg;
            }

            public void setIs_digg(boolean is_digg) {
                this.is_digg = is_digg;
            }

            public String getSchema() {
                return schema;
            }

            public void setSchema(String schema) {
                this.schema = schema;
            }

            public static class ContentAbstractBean {
                /**
                 * text : 这个问题的发问,仍是围绕在卡上面。若是证实身份的方式不在是这张卡,而是你的眼角膜,或是指纹,那么全部录入的信息就能够经过你证实的物件来提取了,还要看整个社会在一个什么高度。若是一卡在手,那若是遗失了,就很麻烦了。卡的合并,那么这个办卡的部门也须要合并,这个是个大工程了。若是身份证,是你身体的一部分,那么,什么都简单了。
                 * thumb_image_list : [{"url":"http://p3.pstatp.com/list/r555/289d0019a74b9a89ddfe","url_list":[{"url":"http://p3.pstatp.com/list/r555/289d0019a74b9a89ddfe"},{"url":"http://pb9.pstatp.com/list/r555/289d0019a74b9a89ddfe"},{"url":"http://pb3.pstatp.com/list/r555/289d0019a74b9a89ddfe"}],"uri":"list/r555/289d0019a74b9a89ddfe","height":555,"width":354,"type":1}]
                 * large_image_list : [{"url":"http://p3.pstatp.com/large/289d0019a74b9a89ddfe","url_list":[{"url":"http://p3.pstatp.com/large/289d0019a74b9a89ddfe"},{"url":"http://pb9.pstatp.com/large/289d0019a74b9a89ddfe"},{"url":"http://pb3.pstatp.com/large/289d0019a74b9a89ddfe"}],"uri":"large/289d0019a74b9a89ddfe","height":555,"width":354,"type":1}]
                 */

                private String text;
                private List<ThumbImageListBean> thumb_image_list;
                private List<LargeImageListBean> large_image_list;

                public String getText() {
                    return text;
                }

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

                public List<ThumbImageListBean> getThumb_image_list() {
                    return thumb_image_list;
                }

                public void setThumb_image_list(List<ThumbImageListBean> thumb_image_list) {
                    this.thumb_image_list = thumb_image_list;
                }

                public List<LargeImageListBean> getLarge_image_list() {
                    return large_image_list;
                }

                public void setLarge_image_list(List<LargeImageListBean> large_image_list) {
                    this.large_image_list = large_image_list;
                }

                public static class ThumbImageListBean {
                    /**
                     * url : http://p3.pstatp.com/list/r555/289d0019a74b9a89ddfe
                     * url_list : [{"url":"http://p3.pstatp.com/list/r555/289d0019a74b9a89ddfe"},{"url":"http://pb9.pstatp.com/list/r555/289d0019a74b9a89ddfe"},{"url":"http://pb3.pstatp.com/list/r555/289d0019a74b9a89ddfe"}]
                     * uri : list/r555/289d0019a74b9a89ddfe
                     * height : 555
                     * width : 354
                     * type : 1
                     */

                    private String url;
                    private String uri;
                    private int height;
                    private int width;
                    private int type;
                    private List<UrlListBean> url_list;

                    public String getUrl() {
                        return url;
                    }

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

                    public String getUri() {
                        return uri;
                    }

                    public void setUri(String uri) {
                        this.uri = uri;
                    }

                    public int getHeight() {
                        return height;
                    }

                    public void setHeight(int height) {
                        this.height = height;
                    }

                    public int getWidth() {
                        return width;
                    }

                    public void setWidth(int width) {
                        this.width = width;
                    }

                    public int getType() {
                        return type;
                    }

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

                    public List<UrlListBean> getUrl_list() {
                        return url_list;
                    }

                    public void setUrl_list(List<UrlListBean> url_list) {
                        this.url_list = url_list;
                    }

                    public static class UrlListBean {
                        /**
                         * url : http://p3.pstatp.com/list/r555/289d0019a74b9a89ddfe
                         */

                        private String url;

                        public String getUrl() {
                            return url;
                        }

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

                public static class LargeImageListBean {
                    /**
                     * url : http://p3.pstatp.com/large/289d0019a74b9a89ddfe
                     * url_list : [{"url":"http://p3.pstatp.com/large/289d0019a74b9a89ddfe"},{"url":"http://pb9.pstatp.com/large/289d0019a74b9a89ddfe"},{"url":"http://pb3.pstatp.com/large/289d0019a74b9a89ddfe"}]
                     * uri : large/289d0019a74b9a89ddfe
                     * height : 555
                     * width : 354
                     * type : 1
                     */

                    private String url;
                    private String uri;
                    private int height;
                    private int width;
                    private int type;
                    private List<UrlListBeanX> url_list;

                    public String getUrl() {
                        return url;
                    }

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

                    public String getUri() {
                        return uri;
                    }

                    public void setUri(String uri) {
                        this.uri = uri;
                    }

                    public int getHeight() {
                        return height;
                    }

                    public void setHeight(int height) {
                        this.height = height;
                    }

                    public int getWidth() {
                        return width;
                    }

                    public void setWidth(int width) {
                        this.width = width;
                    }

                    public int getType() {
                        return type;
                    }

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

                    public List<UrlListBeanX> getUrl_list() {
                        return url_list;
                    }

                    public void setUrl_list(List<UrlListBeanX> url_list) {
                        this.url_list = url_list;
                    }

                    public static class UrlListBeanX {
                        /**
                         * url : http://p3.pstatp.com/large/289d0019a74b9a89ddfe
                         */

                        private String url;

                        public String getUrl() {
                            return url;
                        }

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

            public static class UserBean {
                /**
                 * uname : 神勇依旧
                 * avatar_url : http://p3.pstatp.com/thumb/1a6a000adbc3a1f0a4c5
                 * user_id : 6619635172
                 * is_verify : 0
                 * create_time : 1464350006
                 * user_intro :
                 * user_auth_info :
                 * schema : sslocal://profile?uid=6619635172&refer=wenda
                 */

                private String uname;
                private String avatar_url;
                private String user_id;
                private int is_verify;
                private int create_time;
                private String user_intro;
                private String user_auth_info;
                private String schema;

                public String getUname() {
                    return uname;
                }

                public void setUname(String uname) {
                    this.uname = uname;
                }

                public String getAvatar_url() {
                    return avatar_url;
                }

                public void setAvatar_url(String avatar_url) {
                    this.avatar_url = avatar_url;
                }

                public String getUser_id() {
                    return user_id;
                }

                public void setUser_id(String user_id) {
                    this.user_id = user_id;
                }

                public int getIs_verify() {
                    return is_verify;
                }

                public void setIs_verify(int is_verify) {
                    this.is_verify = is_verify;
                }

                public int getCreate_time() {
                    return create_time;
                }

                public void setCreate_time(int create_time) {
                    this.create_time = create_time;
                }

                public String getUser_intro() {
                    return user_intro;
                }

                public void setUser_intro(String user_intro) {
                    this.user_intro = user_intro;
                }

                public String getUser_auth_info() {
                    return user_auth_info;
                }

                public void setUser_auth_info(String user_auth_info) {
                    this.user_auth_info = user_auth_info;
                }

                public String getSchema() {
                    return schema;
                }

                public void setSchema(String schema) {
                    this.schema = schema;
                }
            }
        }

        public static class QuestionBean {
            /**
             * content : {"text":"你们以为《身份证》实现驾驶证、医保卡、银行卡、公交卡等一卡多用怎么样?外观变化不大,可是针对不一样的刷卡或扫描就能够实现其余卡的功能。能够设置密码、指纹识别等功能是否是就更方便快捷!","pic_uri_list":[{"width":640,"type":"1","web_uri":"289e00197d4a3ff1c255","height":398}],"thumb_image_list":[{"url":"http://p3.pstatp.com/list/r640/289e00197d4a3ff1c255","url_list":[{"url":"http://p3.pstatp.com/list/r640/289e00197d4a3ff1c255"},{"url":"http://pb9.pstatp.com/list/r640/289e00197d4a3ff1c255"},{"url":"http://pb3.pstatp.com/list/r640/289e00197d4a3ff1c255"}],"uri":"289e00197d4a3ff1c255","height":398,"width":640,"type":1}],"large_image_list":[{"url":"http://p3.pstatp.com/large/289e00197d4a3ff1c255","url_list":[{"url":"http://p3.pstatp.com/large/289e00197d4a3ff1c255"},{"url":"http://pb9.pstatp.com/large/289e00197d4a3ff1c255"},{"url":"http://pb3.pstatp.com/large/289e00197d4a3ff1c255"}],"uri":"289e00197d4a3ff1c255","height":398,"width":640,"type":1}]}
             * tag_name :
             * create_time : 1498091836
             * normal_ans_count : 11
             * user : {"uname":"霸鱼1982","avatar_url":"http://p3.pstatp.com/thumb/307/3518148306","user_id":"1959892080","is_verify":0,"create_time":1375854608,"user_intro":"","user_auth_info":"","schema":"sslocal://profile?uid=1959892080&refer=wenda"}
             * title : 你们以为身份证明现驾驶证、医保卡、银行卡、公交卡等一卡多用怎么样?
             * qid : 6434255442293031169
             * nice_ans_count : 7
             * tag_id : 0
             * fold_reason : {"open_url":"sslocal://detail?groupid=6293724675596402946","title":"为何折叠?"}
             */

            private ContentBean content;
            private String tag_name;
            private int create_time;
            private int normal_ans_count;
            private UserBeanX user;
            private String title;
            private String qid;
            private int nice_ans_count;
            private int tag_id;
            private FoldReasonBean fold_reason;

            public ContentBean getContent() {
                return content;
            }

            public void setContent(ContentBean content) {
                this.content = content;
            }

            public String getTag_name() {
                return tag_name;
            }

            public void setTag_name(String tag_name) {
                this.tag_name = tag_name;
            }

            public int getCreate_time() {
                return create_time;
            }

            public void setCreate_time(int create_time) {
                this.create_time = create_time;
            }

            public int getNormal_ans_count() {
                return normal_ans_count;
            }

            public void setNormal_ans_count(int normal_ans_count) {
                this.normal_ans_count = normal_ans_count;
            }

            public UserBeanX getUser() {
                return user;
            }

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

            public String getTitle() {
                return title;
            }

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

            public String getQid() {
                return qid;
            }

            public void setQid(String qid) {
                this.qid = qid;
            }

            public int getNice_ans_count() {
                return nice_ans_count;
            }

            public void setNice_ans_count(int nice_ans_count) {
                this.nice_ans_count = nice_ans_count;
            }

            public int getTag_id() {
                return tag_id;
            }

            public void setTag_id(int tag_id) {
                this.tag_id = tag_id;
            }

            public FoldReasonBean getFold_reason() {
                return fold_reason;
            }

            public void setFold_reason(FoldReasonBean fold_reason) {
                this.fold_reason = fold_reason;
            }

            public static class ContentBean {
                /**
                 * text : 你们以为《身份证》实现驾驶证、医保卡、银行卡、公交卡等一卡多用怎么样?外观变化不大,可是针对不一样的刷卡或扫描就能够实现其余卡的功能。能够设置密码、指纹识别等功能是否是就更方便快捷!
                 * pic_uri_list : [{"width":640,"type":"1","web_uri":"289e00197d4a3ff1c255","height":398}]
                 * thumb_image_list : [{"url":"http://p3.pstatp.com/list/r640/289e00197d4a3ff1c255","url_list":[{"url":"http://p3.pstatp.com/list/r640/289e00197d4a3ff1c255"},{"url":"http://pb9.pstatp.com/list/r640/289e00197d4a3ff1c255"},{"url":"http://pb3.pstatp.com/list/r640/289e00197d4a3ff1c255"}],"uri":"289e00197d4a3ff1c255","height":398,"width":640,"type":1}]
                 * large_image_list : [{"url":"http://p3.pstatp.com/large/289e00197d4a3ff1c255","url_list":[{"url":"http://p3.pstatp.com/large/289e00197d4a3ff1c255"},{"url":"http://pb9.pstatp.com/large/289e00197d4a3ff1c255"},{"url":"http://pb3.pstatp.com/large/289e00197d4a3ff1c255"}],"uri":"289e00197d4a3ff1c255","height":398,"width":640,"type":1}]
                 */

                private String text;
                private List<PicUriListBean> pic_uri_list;
                private List<ThumbImageListBeanX> thumb_image_list;
                private List<LargeImageListBeanX> large_image_list;

                public String getText() {
                    return text;
                }

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

                public List<PicUriListBean> getPic_uri_list() {
                    return pic_uri_list;
                }

                public void setPic_uri_list(List<PicUriListBean> pic_uri_list) {
                    this.pic_uri_list = pic_uri_list;
                }

                public List<ThumbImageListBeanX> getThumb_image_list() {
                    return thumb_image_list;
                }

                public void setThumb_image_list(List<ThumbImageListBeanX> thumb_image_list) {
                    this.thumb_image_list = thumb_image_list;
                }

                public List<LargeImageListBeanX> getLarge_image_list() {
                    return large_image_list;
                }

                public void setLarge_image_list(List<LargeImageListBeanX> large_image_list) {
                    this.large_image_list = large_image_list;
                }

                public static class PicUriListBean {
                    /**
                     * width : 640
                     * type : 1
                     * web_uri : 289e00197d4a3ff1c255
                     * height : 398
                     */

                    private int width;
                    private String type;
                    private String web_uri;
                    private int height;

                    public int getWidth() {
                        return width;
                    }

                    public void setWidth(int width) {
                        this.width = width;
                    }

                    public String getType() {
                        return type;
                    }

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

                    public String getWeb_uri() {
                        return web_uri;
                    }

                    public void setWeb_uri(String web_uri) {
                        this.web_uri = web_uri;
                    }

                    public int getHeight() {
                        return height;
                    }

                    public void setHeight(int height) {
                        this.height = height;
                    }
                }

                public static class ThumbImageListBeanX {
                    /**
                     * url : http://p3.pstatp.com/list/r640/289e00197d4a3ff1c255
                     * url_list : [{"url":"http://p3.pstatp.com/list/r640/289e00197d4a3ff1c255"},{"url":"http://pb9.pstatp.com/list/r640/289e00197d4a3ff1c255"},{"url":"http://pb3.pstatp.com/list/r640/289e00197d4a3ff1c255"}]
                     * uri : 289e00197d4a3ff1c255
                     * height : 398
                     * width : 640
                     * type : 1
                     */

                    private String url;
                    private String uri;
                    private int height;
                    private int width;
                    private int type;
                    private List<UrlListBeanXX> url_list;

                    public String getUrl() {
                        return url;
                    }

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

                    public String getUri() {
                        return uri;
                    }

                    public void setUri(String uri) {
                        this.uri = uri;
                    }

                    public int getHeight() {
                        return height;
                    }

                    public void setHeight(int height) {
                        this.height = height;
                    }

                    public int getWidth() {
                        return width;
                    }

                    public void setWidth(int width) {
                        this.width = width;
                    }

                    public int getType() {
                        return type;
                    }

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

                    public List<UrlListBeanXX> getUrl_list() {
                        return url_list;
                    }

                    public void setUrl_list(List<UrlListBeanXX> url_list) {
                        this.url_list = url_list;
                    }

                    public static class UrlListBeanXX {
                        /**
                         * url : http://p3.pstatp.com/list/r640/289e00197d4a3ff1c255
                         */

                        private String url;

                        public String getUrl() {
                            return url;
                        }

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

                public static class LargeImageListBeanX {
                    /**
                     * url : http://p3.pstatp.com/large/289e00197d4a3ff1c255
                     * url_list : [{"url":"http://p3.pstatp.com/large/289e00197d4a3ff1c255"},{"url":"http://pb9.pstatp.com/large/289e00197d4a3ff1c255"},{"url":"http://pb3.pstatp.com/large/289e00197d4a3ff1c255"}]
                     * uri : 289e00197d4a3ff1c255
                     * height : 398
                     * width : 640
                     * type : 1
                     */

                    private String url;
                    private String uri;
                    private int height;
                    private int width;
                    private int type;
                    private List<UrlListBeanXXX> url_list;

                    public String getUrl() {
                        return url;
                    }

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

                    public String getUri() {
                        return uri;
                    }

                    public void setUri(String uri) {
                        this.uri = uri;
                    }

                    public int getHeight() {
                        return height;
                    }

                    public void setHeight(int height) {
                        this.height = height;
                    }

                    public int getWidth() {
                        return width;
                    }

                    public void setWidth(int width) {
                        this.width = width;
                    }

                    public int getType() {
                        return type;
                    }

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

                    public List<UrlListBeanXXX> getUrl_list() {
                        return url_list;
                    }

                    public void setUrl_list(List<UrlListBeanXXX> url_list) {
                        this.url_list = url_list;
                    }

                    public static class UrlListBeanXXX {
                        /**
                         * url : http://p3.pstatp.com/large/289e00197d4a3ff1c255
                         */

                        private String url;

                        public String getUrl() {
                            return url;
                        }

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

            public static class UserBeanX {
                /**
                 * uname : 霸鱼1982
                 * avatar_url : http://p3.pstatp.com/thumb/307/3518148306
                 * user_id : 1959892080
                 * is_verify : 0
                 * create_time : 1375854608
                 * user_intro :
                 * user_auth_info :
                 * schema : sslocal://profile?uid=1959892080&refer=wenda
                 */

                private String uname;
                private String avatar_url;
                private String user_id;
                private int is_verify;
                private int create_time;
                private String user_intro;
                private String user_auth_info;
                private String schema;

                public String getUname() {
                    return uname;
                }

                public void setUname(String uname) {
                    this.uname = uname;
                }

                public String getAvatar_url() {
                    return avatar_url;
                }

                public void setAvatar_url(String avatar_url) {
                    this.avatar_url = avatar_url;
                }

                public String getUser_id() {
                    return user_id;
                }

                public void setUser_id(String user_id) {
                    this.user_id = user_id;
                }

                public int getIs_verify() {
                    return is_verify;
                }

                public void setIs_verify(int is_verify) {
                    this.is_verify = is_verify;
                }

                public int getCreate_time() {
                    return create_time;
                }

                public void setCreate_time(int create_time) {
                    this.create_time = create_time;
                }

                public String getUser_intro() {
                    return user_intro;
                }

                public void setUser_intro(String user_intro) {
                    this.user_intro = user_intro;
                }

                public String getUser_auth_info() {
                    return user_auth_info;
                }

                public void setUser_auth_info(String user_auth_info) {
                    this.user_auth_info = user_auth_info;
                }

                public String getSchema() {
                    return schema;
                }

                public void setSchema(String schema) {
                    this.schema = schema;
                }
            }

            public static class FoldReasonBean {
                /**
                 * open_url : sslocal://detail?groupid=6293724675596402946
                 * title : 为何折叠?
                 */

                private String open_url;
                private String title;

                public String getOpen_url() {
                    return open_url;
                }

                public void setOpen_url(String open_url) {
                    this.open_url = open_url;
                }

                public String getTitle() {
                    return title;
                }

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

 


4.建立3种Fragment

4.1.首先设置最底层接口==>IMediaProfile 

public interface IMediaProfile {
    interface View extends IBaseListView<Presenter> {

        /**
         * 请求数据
         */
        void onLoadData();

        /**
         * 刷新
         */
        void onRefresh();
    }

    interface Presenter extends IBasePresenter {

        /**
         * 请求数据
         */
        void doLoadArticle(String... mediaId);

        void doLoadVideo(String... mediaId);

        void doLoadWenda(String... mediaId);

        /**
         * 再起请求数据
         */
        void doLoadMoreData(int type);

        /**
         * 设置适配器
         */
        void doSetAdapter(List<MultiMediaArticleBean.DataBean> list);

        void doSetWendaAdapter(List<MediaWendaBean.AnswerQuestionBean> list);

        void doRefresh(int type);

        void doShowNoMore();
    }
}

 

 

4.2.而后是MediaArticleFragment片断。 

public class MediaArticleFragment extends BaseListFragment<IMediaProfile.Presenter> implements IMediaProfile.View,SwipeRefreshLayout.OnRefreshListener{
    private static final String TAG = "MediaArticleFragment";
    private MediaProfileBean.DataBean dataBean = null;

    public static MediaArticleFragment newInstance(Parcelable parcelable) {
        Bundle args = new Bundle();
        args.putParcelable(TAG, parcelable);
        MediaArticleFragment fragment = new MediaArticleFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setPresenter(IMediaProfile.Presenter presenter) {
        if (null == presenter) {
            this.presenter = new MediaTabPresenter(this);
        }
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        adapter = new MultiTypeAdapter(oldItems);
        Register.registerMediaArticleItem(adapter);
        recyclerView.setAdapter(adapter);
        recyclerView.addOnScrollListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore() {
                if (canLoadMore) {
                    canLoadMore = false;
                    presenter.doLoadMoreData(TYPE_ARTICLE);
                }
            }
        });
    }

    @Override
    protected void initData() {
        Bundle bundle = getArguments();
        this.dataBean = bundle.getParcelable(TAG);
        if (null == dataBean) {
            onShowNetError();
        }
    }

    @Override
    public void onSetAdapter(List<?> list) {
        Items newItems = new Items();
        newItems.add(dataBean);
        newItems.addAll(list);
        newItems.add(new LoadingBean());
        DiffCallback.notifyDataSetChanged(oldItems, newItems, DiffCallback.MUlTI_MEDIA, adapter);
        oldItems.clear();
        oldItems.addAll(newItems);
        canLoadMore = true;
    }


    @Override
    public void fetchData() {
        onLoadData();
    }

    @Override
    public void onLoadData() {
        presenter.doLoadArticle(dataBean.getMedia_id());
    }

    @Override
    public void onRefresh() {
        onShowLoading();
        presenter.doRefresh(TYPE_ARTICLE);
    }
}

  首先一个新建实例的函数,传入了一个序列化Bean类,返回一个fragment。

  

  而后重写设置处理器,传入了一个底层接口的一个处理器,保存之后再用。

 

  而后重写初始化视图,新建适配器+注册数据类型+recycleview滑动监听事件。

 

  而后重写初始化数据,获取bundle中的bean类。

 

  而后重写设置适配器,传入一个List,处理新老数据。

 

  而后重写填充数据,调用了onLoadData方法。

 

  而后重写了加载数据,调用了处理器的加载文章的函数。

 

  而后重写了onRefresh方法,调用了处理器的刷新方法。

 

 

4.3.媒体问答的片断==>MediaWendaFragment

public class MediaWendaFragment extends BaseListFragment<IMediaProfile.Presenter> implements IMediaProfile.View {

    private static final String TAG = "MediaWendaFragment";
    private String mediaId;

    public static MediaWendaFragment newInstance(String mediaId) {
        Bundle args = new Bundle();
        args.putString(TAG, mediaId);
        MediaWendaFragment fragment = new MediaWendaFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setPresenter(IMediaProfile.Presenter presenter) {
        if (null == presenter) {
            this.presenter = new MediaTabPresenter(this);
        }
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        adapter = new MultiTypeAdapter(oldItems);
        Register.registerMediaWendaItem(adapter);
        recyclerView.setAdapter(adapter);
        recyclerView.addOnScrollListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore() {
                if (canLoadMore) {
                    canLoadMore = false;
                    presenter.doLoadMoreData(TYPE_WENDA);
                }
            }
        });
    }

    @Override
    protected void initData() {
        Bundle bundle = getArguments();
        mediaId = bundle.getString(TAG);
        if (TextUtils.isEmpty(mediaId)) {
            onShowNetError();
        }
    }

    @Override
    public void onLoadData() {
        onShowLoading();
        presenter.doLoadWenda(mediaId);
    }

    @Override
    public void onRefresh() {
        presenter.doRefresh(TYPE_WENDA);
    }

    @Override
    public void onSetAdapter(List<?> list) {
        Items newItems = new Items(list);
        newItems.add(new LoadingBean());
        DiffCallback.notifyDataSetChanged(oldItems, newItems, DiffCallback.MEDIA_WENDA, adapter);
        oldItems.clear();
        oldItems.addAll(newItems);
        canLoadMore = true;
    }

    @Override
    public void fetchData() {
        onLoadData();
    }
}

  首先是新建一个实例,传入媒体Id,返回fragment。

 

  而后是重写setPresenter方法,传入底层接口的处理器。

 

  而后是重写初始化视图,传入一个视图便可。

  新建一个适配器,注册数据类型,而后设置recycleView的滑动监听事件。

 

  而后初始化数据,将Bundle中的媒体Id获取到。

 

  而后是加载数据,首先调用视图层的加载,而后调用处理器的加载问答类型。

 

  而后是刷新,一样调用了处理器的加载问答类型。

 

  而后是设置适配器,传入一个List,而后处理新老数据。

 

  最后是填充数据,调用onLoadData函数便可。

 

 

4.4.媒体视频类型片断==>MediaVideoFragment

public class MediaVideoFragment extends BaseListFragment<IMediaProfile.Presenter> implements IMediaProfile.View {
    
    private static final String TAG = "MediaVideoFragment";
    private String mediaId;

    public static MediaVideoFragment newInstance(String mediaId) {
        Bundle args = new Bundle();
        args.putString(TAG, mediaId);
        MediaVideoFragment fragment = new MediaVideoFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setPresenter(IMediaProfile.Presenter presenter) {
        if (null == presenter) {
            this.presenter = new MediaTabPresenter(this);
        }
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        adapter = new MultiTypeAdapter(oldItems);
        Register.registerMediaArticleItem(adapter);
        recyclerView.setAdapter(adapter);
        recyclerView.addOnScrollListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore() {
                if (canLoadMore) {
                    canLoadMore = false;
                    presenter.doLoadMoreData(TYPE_VIDEO);
                }
            }
        });
    }

    @Override
    protected void initData() {
        Bundle bundle = getArguments();
        mediaId = bundle.getString(TAG);
        if (TextUtils.isEmpty(mediaId)) {
            onShowNetError();
        }
    }

    @Override
    public void onLoadData() {
        onShowLoading();
        presenter.doLoadVideo(mediaId);
    }

    @Override
    public void onRefresh() {
        presenter.doRefresh(TYPE_VIDEO);
    }

    @Override
    public void onSetAdapter(List<?> list) {
        Items newItems = new Items(list);
        newItems.add(new LoadingBean());
        DiffCallback.notifyDataSetChanged(oldItems, newItems, DiffCallback.MUlTI_MEDIA, adapter);
        oldItems.clear();
        oldItems.addAll(newItems);
        canLoadMore = true;
    }

    @Override
    public void fetchData() {
        onLoadData();
    }
}

  首先一样是供外部调用的newInstance函数。传入媒体Id,返回Fragment。

  

  而后重写设置处理器,传入一个底层接口的处理器。

 

  而后重写初始化视图,新建一个适配器,注册数据类型+recyclerView滑动监听事件。

 

  而后重写初始化数据,从bundle中获得媒体Id。

 

  而后重写加载数据onLoadData,调用处理器的加载视频类型,传入媒体Id。

 

  而后重写onRefresh,调用处理器的刷新视频类型。

 

  而后重写onSetAdatper,传入一个List,处理新老数据。

 

  而后重写fetchData,调用onLoadData函数。 


5.建立共同处理器

5.1.源代码

public class MediaTabPresenter implements IMediaProfile.Presenter {
    static final int TYPE_ARTICLE = 0;
    static final int TYPE_VIDEO = 1;
    static final int TYPE_WENDA = 2;
    private static final String TAG = "MediaTabPresenter";
    private IMediaProfile.View view;
    private String mediaId;
    private String articleTime;
    private String videoTime;
    private int wendatotal;
    private String wendaCursor;
    private List<MultiMediaArticleBean.DataBean> articleList = new ArrayList<>();
    private List<MultiMediaArticleBean.DataBean> videoList = new ArrayList<>();
    private List<MediaWendaBean.AnswerQuestionBean> wendaList = new ArrayList<>();

    MediaTabPresenter(IMediaProfile.View view) {
        this.view = view;
        this.articleTime = TimeUtil.getCurrentTimeStamp();
        this.videoTime = TimeUtil.getCurrentTimeStamp();
    }

    @Override
    public void doRefresh() {

    }

    @Override
    public void doRefresh(int type) {
        switch (type) {
            case TYPE_ARTICLE:
                if (articleList.size() > 0) {
                    articleList.clear();
                    articleTime = TimeUtil.getCurrentTimeStamp();
                }
                doLoadArticle();
                break;
            case TYPE_VIDEO:
                if (videoList.size() > 0) {
                    videoList.clear();
                    videoTime = TimeUtil.getCurrentTimeStamp();
                }
                doLoadVideo();
                break;
            case TYPE_WENDA:
                if (wendaList.size() > 0) {
                    wendaList.clear();
                }
                doLoadWenda();
                break;
        }
    }

    @Override
    public void doShowNetError() {
        view.onHideLoading();
        view.onShowNetError();
    }

    @Override
    public void doLoadArticle(String... mediaId) {
        try {
            if (TextUtils.isEmpty(this.mediaId)) {
                this.mediaId = mediaId[0];
            }
        } catch (Exception e) {
            ErrorAction.print(e);
        }
        Map<String, String> map = ToutiaoUtil.getAsCp();

        RetrofitFactory.getRetrofit().create(IMobileMediaApi.class)
                .getMediaArticle(this.mediaId, this.articleTime, map.get(Constant.AS), map.get(Constant.CP))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(view.<MultiMediaArticleBean>bindToLife())
                .subscribe(new Consumer<MultiMediaArticleBean>() {
                    @Override
                    public void accept(@NonNull MultiMediaArticleBean bean) throws Exception {
                        articleTime = bean.getNext().getMax_behot_time();
                        List<MultiMediaArticleBean.DataBean> list = bean.getData();
                        if (null != list && list.size() > 0) {
                            doSetAdapter(list);
                        } else {
                            doShowNoMore();
                        }
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(@NonNull Throwable throwable) throws Exception {
                        doShowNetError();
                        ErrorAction.print(throwable);
                    }
                });
    }

    @Override
    public void doLoadVideo(String... mediaId) {
        try {
            if (TextUtils.isEmpty(this.mediaId)) {
                this.mediaId = mediaId[0];
            }
        } catch (Exception e) {
            ErrorAction.print(e);
        }
        Map<String, String> map = ToutiaoUtil.getAsCp();

        RetrofitFactory.getRetrofit().create(IMobileMediaApi.class)
                .getMediaVideo(this.mediaId, this.videoTime, map.get(Constant.AS), map.get(Constant.CP))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(view.<MultiMediaArticleBean>bindToLife())
                .subscribe(new Consumer<MultiMediaArticleBean>() {
                    @Override
                    public void accept(@NonNull MultiMediaArticleBean bean) throws Exception {
                        videoTime = bean.getNext().getMax_behot_time();
                        List<MultiMediaArticleBean.DataBean> list = bean.getData();
                        if (null != list && list.size() > 0) {
                            doSetAdapter(list);
                        } else {
                            doShowNoMore();
                        }
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(@NonNull Throwable throwable) throws Exception {
                        doShowNetError();
                        ErrorAction.print(throwable);
                    }
                });
    }

    @Override
    public void doLoadWenda(String... mediaId) {
        try {
            if (TextUtils.isEmpty(this.mediaId)) {
                this.mediaId = mediaId[0];
            }
        } catch (Exception e) {
            ErrorAction.print(e);
        }
        RetrofitFactory.getRetrofit().create(IMobileMediaApi.class)
                .getMediaWenda(this.mediaId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(view.<MediaWendaBean>bindToLife())
                .subscribe(new Consumer<MediaWendaBean>() {
                    @Override
                    public void accept(@NonNull MediaWendaBean bean) throws Exception {
                        wendatotal = bean.getTotal();
                        wendaCursor = bean.getCursor();
                        List<MediaWendaBean.AnswerQuestionBean> list = bean.getAnswer_question();
                        if (null != list && list.size() > 0) {
                            doSetWendaAdapter(list);
                        } else {
                            doShowNoMore();
                        }
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(@NonNull Throwable throwable) throws Exception {
                        doShowNetError();
                        ErrorAction.print(throwable);
                    }
                });
    }

    @Override
    public void doLoadMoreData(int type) {
        switch (type) {
            case TYPE_ARTICLE:
                doLoadArticle();
                break;
            case TYPE_VIDEO:
                doLoadVideo();
                break;
            case TYPE_WENDA:
                if (wendaList.size() < wendatotal) {
                    RetrofitFactory.getRetrofit().create(IMobileMediaApi.class)
                            .getMediaWendaLoadMore(this.mediaId, this.wendaCursor)
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .compose(view.<MediaWendaBean>bindToLife())
                            .subscribe(new Consumer<MediaWendaBean>() {
                                @Override
                                public void accept(@NonNull MediaWendaBean bean) throws Exception {
                                    List<MediaWendaBean.AnswerQuestionBean> list = bean.getAnswer_question();
                                    if (null != list && list.size() > 0) {
                                        doSetWendaAdapter(list);
                                    } else {
                                        doShowNoMore();
                                    }
                                }
                            }, new Consumer<Throwable>() {
                                @Override
                                public void accept(@NonNull Throwable throwable) throws Exception {
                                    view.onShowNoMore();
                                    ErrorAction.print(throwable);
                                }
                            });
                } else {
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            doShowNoMore();
                        }
                    }).start();
                }
                break;
        }
    }

    @Override
    public void doSetAdapter(List<MultiMediaArticleBean.DataBean> list) {
        articleList.addAll(list);
        view.onSetAdapter(articleList);
        view.onHideLoading();
    }

    @Override
    public void doSetWendaAdapter(List<MediaWendaBean.AnswerQuestionBean> list) {
        wendaList.addAll(list);
        view.onSetAdapter(wendaList);
        view.onHideLoading();
    }

    @Override
    public void doShowNoMore() {
        view.onHideLoading();
        view.onShowNoMore();
    }
    
}
View Code

 

 

5.2.构造函数,传进来一个底层接口的View。

 

 

5.3.重写刷新doRefresh(int type),传进来类型。

  根据类型,选择加载函数。

 

 

5.4.重写doShowNetError。

  先隐藏加载框。

  在显示网络错误。

 

 

5.5.加载文章类型doLoadArticle。

  传进来一个媒体Id。

  调用API请求媒体文章类型。

 

 

5.6.加载视频类型doLoadVideo。

  传进来一个媒体Id。

  调用API请求媒体视频类型。

 

 

5.7.加载问答类型doLoadWenda。

  传进来一个媒体Id。

  调用API请求媒体问答类型。

 

 

5.8.加载更多数据。

  传进来一个类型。

  调用不一样的加载函数。

  问答类型不同,这里加载更多调用了单独的API。

 

 

5.9.设置适配器doSetAdapter。

  传进来一个List。

  调用视图层的onSetAdapter(list)

  调用视图层的隐藏加载。

 

 

5.10.设置问答适配器。

  传进来另一个List。

  调用视图层的onSetAdapter(list)

  调用视图层的隐藏加载。

 

 

5.11.重写没有更多了。

  先调用视图层的隐藏加载。

  在调用视图层的没有更多。


6.API请求

6.1.获取媒体栏目主页信息

/**
     * 头条号主页信息
     * https://is.snssdk.com/user/profile/homepage/v3/json/?media_id=4377795668&to_html=0&source=article_top_author&refer=all
     *
     * @param mediaId 头条号ID
     */
    @GET("https://is.snssdk.com/user/profile/homepage/v3/json/?to_html=0&source=article_top_author&refer=all&aid=13")
    Observable<MediaProfileBean> getMediaProfile(
            @Query("media_id") String mediaId);

  传入一个媒体Id

  传出去一个Observable<MediaProfileBean>

 

 

6.1.获取媒体文章 

/**
     * 获取头条号文章
     * https://is.snssdk.com/pgc/ma/?page_type=1&max_behot_time=1495181160&media_id=52445544609&output=json&is_json=1&count=10&from=user_profile_app&version=2&as=479BB4B7254C150&cp=585DB1871ED64E1
     *
     * @param mediaId      头条号ID
     * @param maxBehotTime 时间轴
     */
    @GET("https://is.snssdk.com/pgc/ma/?page_type=1&output=json&is_json=1&count=20&from=user_profile_app&version=2")
    Observable<MultiMediaArticleBean> getMediaArticle(
            @Query("media_id") String mediaId,
            @Query("max_behot_time") String maxBehotTime,
            @Query("as") String as,
            @Query("cp") String cp);

  传入一个媒体Id,一个最近热点事件,一个头条的as和cp。

  传出去一个Observable<MultiMediaArticleBean>。

 

 

6.2.获取媒体视频

/**
     * 获取头条号视频
     * https://is.snssdk.com/pgc/ma/?page_type=0&max_behot_time=1495181160&media_id=52445544609&output=json&is_json=1&count=10&from=user_profile_app&version=2&as=479BB4B7254C150&cp=585DB1871ED64E1
     *
     * @param mediaId      头条号ID
     * @param maxBehotTime 时间轴
     */
    @GET("https://is.snssdk.com/pgc/ma/?page_type=0&output=json&is_json=1&count=10&from=user_profile_app&version=2")
    Observable<MultiMediaArticleBean> getMediaVideo(
            @Query("media_id") String mediaId,
            @Query("max_behot_time") String maxBehotTime,
            @Query("as") String as,
            @Query("cp") String cp);

  传入一个媒体Id,一个最大点击次数,一个AS,一个CP。

  传出去一个Observable<MultiMediaArticleBean>。

 

 

6.3.获取媒体问答  

/**
     * 获取头条号问答
     * https://is.snssdk.com/wenda/profile/wendatab/brow/?other_id=6619635172&format=json&from_channel=media_channel
     *
     * @param mediaId 头条号ID
     */
    @GET("https://is.snssdk.com/wenda/profile/wendatab/brow/?format=json&from_channel=media_channel")
    Observable<MediaWendaBean> getMediaWenda(
            @Query("other_id") String mediaId);

  传入一个媒体Id。

  返回一个Observable<MediaWendaBean>。

 

 

6.4.获取媒体问答(加载更多) 

/**
     * 获取头条号问答(加载更多)
     * http://is.snssdk.com/wenda/profile/wendatab/loadmore/?other_id=53294853357&format=json&from_channel=media_channel&cursor=6428177292098273538&count=10&offset=undefined
     *
     * @param mediaId 头条号ID
     * @param cursor  偏移量
     */
    @GET("http://is.snssdk.com/wenda/profile/wendatab/loadmore/?format=json&from_channel=media_channel&count=10&offset=undefined")
    Observable<MediaWendaBean> getMediaWendaLoadMore(
            @Query("other_id") String mediaId,
            @Query("cursor") String cursor);

  传入一个媒体Id,一个偏移量。

  返回一个Observable<MediaWendaBean>。

 

 

6.5.注册媒体文章类型 

/**
     * 注册媒体文章类型
     * @param adapter
     */
    public static void registerMediaArticleItem(@NonNull MultiTypeAdapter adapter) {
        adapter.register(MultiMediaArticleBean.DataBean.class)
                .to(new MediaArticleImgViewBinder(),
                        new MediaArticleVideoViewBinder(),
                        new MediaArticleTextViewBinder())
                .withClassLinker(new ClassLinker<MultiMediaArticleBean.DataBean>() {
                    @NonNull
                    @Override
                    public Class<? extends ItemViewBinder<MultiMediaArticleBean.DataBean, ?>> index(@NonNull MultiMediaArticleBean.DataBean item) {
                        if (item.isHas_video()) {
                            return MediaArticleVideoViewBinder.class;
                        }
                        if (null != item.getImage_list() && item.getImage_list().size() > 0) {
                            return MediaArticleImgViewBinder.class;
                        }
                        return MediaArticleTextViewBinder.class;
                    }
                });
        adapter.register(MediaProfileBean.DataBean.class, new MediaArticleHeaderViewBinder());
        adapter.register(LoadingBean.class, new LoadingViewBinder());
        adapter.register(LoadingEndBean.class, new LoadingEndViewBinder());
    }

 

 

6.6.注册媒体问答类型

public static void registerMediaWendaItem(@NonNull MultiTypeAdapter adapter) {
        adapter.register(MediaWendaBean.AnswerQuestionBean.class, new MediaWendaViewBinder());
        adapter.register(LoadingBean.class, new LoadingViewBinder());
        adapter.register(LoadingEndBean.class, new LoadingEndViewBinder());
    }

 

 

6.7.媒体文章一张图片的绑定器==>MediaArticleImgViewBinder

public class MediaArticleImgViewBinder extends ItemViewBinder<MultiMediaArticleBean.DataBean,MediaArticleImgViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected MediaArticleImgViewBinder.ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_media_article_img, parent, false);
        return new ViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull final MediaArticleImgViewBinder.ViewHolder holder, @NonNull final MultiMediaArticleBean.DataBean item) {

        final Context context = holder.itemView.getContext();

        try {
            String imgUrl = "";
            List<MultiMediaArticleBean.DataBean.ImageListBean> imageList = item.getImage_list();
            if (imageList != null && imageList.size() > 0) {
                String url = imageList.get(0).getUrl();
                if (!TextUtils.isEmpty(url)) {
                    if (NetWorkUtil.isWifiConnected(context)) {
                        // 加载高清图
                        url = url.replace("list", "large");
                    }
                    ImageLoader.loadCenterCrop(context, url, holder.iv_image, R.color.viewBackground);
                    imgUrl = imageList.get(0).getUrl().replace("list", "large");
                }
            }

            String title = item.getTitle();
            String abstractX = item.getAbstractX();
            String readCount = item.getTotal_read_count() + "阅读量";
            String countmmentCount = item.getComment_count() + "评论";
            String time = item.getBehot_time() + "";
            if (!TextUtils.isEmpty(time)) {
                time = TimeUtil.getTimeStampAgo(time);
            }

            holder.tv_title.setText(title);
            holder.tv_title.setTextSize(SettingUtil.getInstance().getTextSize());
            holder.tv_abstract.setText(abstractX);
            holder.tv_extra.setText(readCount + " - " + countmmentCount + " - " + time);
            final String finalImgUrl = imgUrl;
            RxView.clicks(holder.itemView)
                    .throttleFirst(1, TimeUnit.SECONDS)
                    .subscribe(new Consumer<Object>() {
                        @Override
                        public void accept(@io.reactivex.annotations.NonNull Object o) throws Exception {
                            MultiNewsArticleDataBean bean = new MultiNewsArticleDataBean();
                            bean.setTitle(item.getTitle());
                            bean.setDisplay_url(item.getDisplay_url());
                            bean.setMedia_name(item.getSource());
                            bean.setGroup_id(item.getGroup_id());
                            bean.setItem_id(item.getItem_id());
                            MultiNewsArticleDataBean.MediaInfoBean mediaInfo = new MultiNewsArticleDataBean.MediaInfoBean();
                            mediaInfo.setMedia_id(item.getMedia_id() + "");
                            bean.setMedia_info(mediaInfo);
                            NewsContentActivity.launch(bean, finalImgUrl);
                        }
                    });

            holder.iv_dots.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    PopupMenu popupMenu = new PopupMenu(context,
                            holder.iv_dots, Gravity.END, 0, R.style.MyPopupMenu);
                    popupMenu.inflate(R.menu.menu_share);
                    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                        @Override
                        public boolean onMenuItemClick(MenuItem menu) {
                            int itemId = menu.getItemId();
                            if (itemId == R.id.action_share) {
                                IntentAction.send(context, item.getTitle() + "\n" + item.getDisplay_url());
                            }
                            return false;
                        }
                    });
                    popupMenu.show();
                }
            });
        } catch (Exception e) {
            ErrorAction.print(e);
        }
    }
    
    class ViewHolder extends RecyclerView.ViewHolder {

        private ImageView iv_image;
        private TextView tv_title;
        private TextView tv_abstract;
        private TextView tv_extra;
        private ImageView iv_dots;

        ViewHolder(View itemView) {
            super(itemView);
            this.iv_image = itemView.findViewById(R.id.iv_image);
            this.tv_title = itemView.findViewById(R.id.tv_title);
            this.tv_abstract = itemView.findViewById(R.id.tv_abstract);
            this.tv_extra = itemView.findViewById(R.id.tv_extra);
            this.iv_dots = itemView.findViewById(R.id.iv_dots);
        }
    }
}
View Code

  须要的item布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginTop="4dp"
    android:background="@color/viewBackground"
    app:cardElevation="1dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackground"
        android:foreground="?attr/selectableItemBackground"
        android:padding="16dp">

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:baselineAligned="false">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/tv_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:maxLines="2"
                    android:textStyle="bold"
                    tools:text="菲总统称中国将向菲提供武器 已指示军方前往接收"/>

                <TextView
                    android:id="@+id/tv_abstract"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dp"
                    android:ellipsize="end"
                    android:maxLines="3"
                    tools:text="美国总统当选人特朗普日前暗示,可能拿美国的“一中政策”当谈判筹码,与中国大陆就诸如人民币汇率及南海等争议讨价还价。"/>
            </LinearLayout>

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ImageView
                    android:id="@+id/iv_dots"
                    android:layout_width="22dp"
                    android:layout_height="22dp"
                    android:layout_gravity="end"
                    android:padding="4dp"
                    android:scaleType="center"
                    app:srcCompat="@drawable/ic_dots_horizontal_grey500_24dp"
                    tools:ignore="ContentDescription"/>

                <ImageView
                    android:id="@+id/iv_image"
                    android:layout_width="72dp"
                    android:layout_height="72dp"
                    android:layout_marginLeft="8dp"
                    android:layout_marginStart="8dp"
                    android:layout_marginTop="4dp"
                    tools:ignore="ContentDescription"/>
            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/content"
            android:layout_marginTop="4dp"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tv_extra"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:maxLines="1"
                android:textAppearance="@style/TextAppearance.AppCompat.Caption"
                tools:text="123阅读量 - 2222条评论 - 1小时前"/>

        </LinearLayout>

    </RelativeLayout>
</android.support.v7.widget.CardView>
View Code

  效果预览:

  

 

 

6.8.媒体文章纯文字类型==>MediaArticleTextViewBinder

public class MediaArticleTextViewBinder extends ItemViewBinder<MultiMediaArticleBean.DataBean, MediaArticleTextViewBinder.ViewHolder> {
    @NonNull
    @Override
    protected MediaArticleTextViewBinder.ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_media_article_text, parent, false);
        return new ViewHolder(view);
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private TextView tv_extra;
        private TextView tv_title;
        private TextView tv_abstract;
        private ImageView iv_dots;

        ViewHolder(View itemView) {
            super(itemView);
            this.tv_extra = itemView.findViewById(R.id.tv_extra);
            this.tv_title = itemView.findViewById(R.id.tv_title);
            this.tv_abstract = itemView.findViewById(R.id.tv_abstract);
            this.iv_dots = itemView.findViewById(R.id.iv_dots);
        }
    }

    @Override
    protected void onBindViewHolder(@NonNull final MediaArticleTextViewBinder.ViewHolder holder, @NonNull final MultiMediaArticleBean.DataBean item) {

        final Context context = holder.itemView.getContext();

        try {
            String title = item.getTitle();
            String abstractX = item.getAbstractX();
            String readCount = item.getTotal_read_count() + "阅读量";
            String countmmentCount = item.getComment_count() + "评论";
            String time = item.getBehot_time() + "";
            if (!TextUtils.isEmpty(time)) {
                time = TimeUtil.getTimeStampAgo(time);
            }

            holder.tv_title.setText(title);
            holder.tv_title.setTextSize(SettingUtil.getInstance().getTextSize());
            holder.tv_abstract.setText(abstractX);
            holder.tv_extra.setText(readCount + " - " + countmmentCount + " - " + time);

            RxView.clicks(holder.itemView)
                    .throttleFirst(1, TimeUnit.SECONDS)
                    .subscribe(new Consumer<Object>() {
                        @Override
                        public void accept(@io.reactivex.annotations.NonNull Object o) throws Exception {
                            MultiNewsArticleDataBean bean = new MultiNewsArticleDataBean();
                            bean.setTitle(item.getTitle());
                            bean.setDisplay_url(item.getDisplay_url());
                            bean.setShare_url(item.getDisplay_url());
                            bean.setMedia_name(item.getSource());
                            MultiNewsArticleDataBean.MediaInfoBean mediaInfo = new MultiNewsArticleDataBean.MediaInfoBean();
                            mediaInfo.setMedia_id(item.getMedia_id() + "");
                            bean.setMedia_info(mediaInfo);
                            bean.setGroup_id(item.getGroup_id());
                            bean.setItem_id(item.getItem_id());
                            NewsContentActivity.launch(bean);
                        }
                    });

            holder.iv_dots.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    PopupMenu popupMenu = new PopupMenu(context,
                            holder.iv_dots, Gravity.END, 0, R.style.MyPopupMenu);
                    popupMenu.inflate(R.menu.menu_share);
                    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                        @Override
                        public boolean onMenuItemClick(MenuItem menu) {
                            int itemId = menu.getItemId();
                            if (itemId == R.id.action_share) {
                                IntentAction.send(context, item.getTitle() + "\n" + item.getDisplay_url());
                            }
                            return false;
                        }
                    });
                    popupMenu.show();
                }
            });
        } catch (Exception e) {
            ErrorAction.print(e);
        }
    }
}
View Code

  须要的item布局==>item_media_article_text.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginTop="4dp"
    android:background="@color/viewBackground"
    app:cardElevation="1dp">

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackground"
        android:foreground="?attr/selectableItemBackground"
        android:orientation="vertical"
        android:padding="16dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/tv_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/iv_dots"
                android:layout_toStartOf="@+id/iv_dots"
                android:ellipsize="end"
                android:maxLines="1"
                android:textStyle="bold"
                tools:text="菲总统称中国将向菲提供武 器已指示军方前往接收"/>

            <ImageView
                android:id="@+id/iv_dots"
                android:layout_width="22dp"
                android:layout_height="22dp"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:padding="4dp"
                android:scaleType="center"
                app:srcCompat="@drawable/ic_dots_horizontal_grey500_24dp"
                tools:ignore="ContentDescription"/>

        </RelativeLayout>

        <TextView
            android:id="@+id/tv_abstract"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:ellipsize="end"
            android:maxLines="3"
            tools:text="美国总统当选人特朗普日前暗示,可能拿美国的“一中政策”当谈判筹码,与中国大陆就诸如人民币汇率及南海等争议讨价还价。"/>

        <TextView
            android:id="@+id/tv_extra"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:ellipsize="end"
            android:maxLines="1"
            android:textAppearance="@style/TextAppearance.AppCompat.Caption"
            tools:text="123阅读量 - 2222条评论 - 1小时前"/>

    </LinearLayout>

</android.support.v7.widget.CardView>
View Code

  预览效果:

  

 

 

6.9.媒体文章视频类型==>MediaArticleVideoViewBinder

public class MediaArticleVideoViewBinder extends ItemViewBinder<MultiMediaArticleBean.DataBean, MediaArticleVideoViewBinder.ViewHolder> {
    
    private static final String TAG = "NewsArticleHasVideoView";

    @NonNull
    @Override
    protected MediaArticleVideoViewBinder.ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_media_article_video, parent, false);
        return new ViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull final ViewHolder holder, @NonNull final MultiMediaArticleBean.DataBean item) {

        final Context context = holder.itemView.getContext();

        try {
            List<MultiMediaArticleBean.DataBean.ImageListBean> imageList = item.getImage_list();
            String url = null;
            if (imageList != null && imageList.size() > 0) {
                url = imageList.get(0).getUrl();
                if (!TextUtils.isEmpty(url)) {
                    if (NetWorkUtil.isWifiConnected(context)) {
                        // 加载高清图
                        url = url.replace("list", "large");
                    }
                    ImageLoader.loadCenterCrop(context, url, holder.iv_video_image, R.color.viewBackground);
                }
            }

            final String title = item.getTitle();
            String readCount = item.getTotal_read_count() + "阅读量";
            String commentCount = item.getComment_count() + "评论";
            String datetime = item.getBehot_time() + "";
            if (!TextUtils.isEmpty(datetime)) {
                datetime = TimeUtil.getTimeStampAgo(datetime);
            }
            String video_time = item.getVideo_duration_str();

            holder.tv_title.setText(title);
            holder.tv_title.setTextSize(SettingUtil.getInstance().getTextSize());
            holder.tv_extra.setText(readCount + " - " + commentCount + " - " + datetime);
            holder.tv_video_time.setText(video_time);

            final String finalUrl = url;
            RxView.clicks(holder.itemView)
                    .throttleFirst(1, TimeUnit.SECONDS)
                    .observeOn(Schedulers.io())
                    .subscribe(new Consumer<Object>() {
                        @Override
                        public void accept(@io.reactivex.annotations.NonNull Object o) throws Exception {
                            MultiNewsArticleDataBean bean = new MultiNewsArticleDataBean();
                            bean.setTitle(title);
                            bean.setGroup_id(item.getGroup_id());
                            bean.setItem_id(item.getItem_id());
                            bean.setVideo_id(item.getVideo_infos().get(0).getVid());
                            bean.setAbstractX(item.getAbstractX());
                            bean.setSource(item.getSource());

                            String s = item.getVideo_duration_str();
                            int time = 0;
                            if (s.contains(":")) {
                                String[] split = s.split(":");
                                for (int i = 0; i < split.length; i++) {
                                    if (i == 0) {
                                        time = Integer.parseInt(split[i]) * 60;
                                    }
                                    time += Integer.parseInt(split[i]);
                                }
                            }
                            bean.setVideo_duration(time);

                            MultiNewsArticleDataBean.MediaInfoBean mediaInfoBean = new MultiNewsArticleDataBean.MediaInfoBean();
                            mediaInfoBean.setMedia_id(item.getMedia_id() + "");
                            bean.setMedia_info(mediaInfoBean);

                            MultiNewsArticleDataBean.VideoDetailInfoBean.DetailVideoLargeImageBean videobean = new MultiNewsArticleDataBean.VideoDetailInfoBean.DetailVideoLargeImageBean();
                            MultiNewsArticleDataBean.VideoDetailInfoBean videoDetail = new MultiNewsArticleDataBean.VideoDetailInfoBean();
                            videobean.setUrl(finalUrl);
                            videoDetail.setDetail_video_large_image(videobean);
                            bean.setVideo_detail_info(videoDetail);

                            //VideoContentActivity.launch(bean);
                        }
                    }, new Consumer<Throwable>() {
                        @Override
                        public void accept(@io.reactivex.annotations.NonNull Throwable throwable) throws Exception {
                            Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show();
                            ErrorAction.print(throwable);
                        }
                    });
            holder.iv_dots.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    PopupMenu popupMenu = new PopupMenu(context,
                            holder.iv_dots, Gravity.END, 0, R.style.MyPopupMenu);
                    popupMenu.inflate(R.menu.menu_share);
                    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                        @Override
                        public boolean onMenuItemClick(MenuItem menu) {
                            int itemId = menu.getItemId();
                            if (itemId == R.id.action_share) {
                                IntentAction.send(context, item.getTitle() + "\n" + item.getDisplay_url());
                            }
                            return false;
                        }
                    });
                    popupMenu.show();
                }
            });
        } catch (Exception e) {
            ErrorAction.print(e);
        }
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private TextView tv_extra;
        private TextView tv_title;
        private ImageView iv_video_image;
        private TextView tv_video_time;
        private ImageView iv_dots;


        ViewHolder(View itemView) {
            super(itemView);
            this.tv_extra = itemView.findViewById(R.id.tv_extra);
            this.tv_title = itemView.findViewById(R.id.tv_title);
            this.iv_video_image = itemView.findViewById(R.id.iv_video_image);
            this.tv_video_time = itemView.findViewById(R.id.tv_video_time);
            this.iv_dots = itemView.findViewById(R.id.iv_dots);
        }
    }
}
View Code

  须要的item布局==>item_media_article_video.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginTop="4dp"
    android:background="@color/viewBackground"
    app:cardElevation="1dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackground"
        android:foreground="?attr/selectableItemBackground"
        android:padding="16dp">

        <LinearLayout
            android:id="@+id/header"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="vertical">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/tv_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                    android:layout_centerVertical="true"
                    android:layout_toLeftOf="@+id/iv_dots"
                    android:layout_toStartOf="@+id/iv_dots"
                    android:ellipsize="end"
                    android:maxLines="1"
                    android:textStyle="bold"
                    tools:text="菲总统称中国将向菲提供武 器已指示军方前往接收"/>

                <ImageView
                    android:id="@+id/iv_dots"
                    android:layout_width="22dp"
                    android:layout_height="22dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:padding="4dp"
                    android:scaleType="center"
                    app:srcCompat="@drawable/ic_dots_horizontal_grey500_24dp"
                    tools:ignore="ContentDescription"/>

            </RelativeLayout>

            <TextView
                android:id="@+id/tv_extra"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="4dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:textAppearance="@style/TextAppearance.AppCompat.Caption"
                tools:text="123阅读量 - 2222条评论 - 1小时前"/>

        </LinearLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="169dp"
            android:layout_below="@id/header"
            android:layout_marginTop="4dp">

            <ImageView
                android:id="@+id/iv_video_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@color/viewBackground"
                tools:ignore="ContentDescription"/>

            <TextView
                android:id="@+id/tv_video_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:background="@color/textColorPrimary"
                android:padding="2dp"
                android:textColor="@color/White"
                tools:text="10:34"/>

        </RelativeLayout>

    </RelativeLayout>
</android.support.v7.widget.CardView>
View Code

  效果预览:

  

 

 

6.10.媒体问答类型视图绑定==>MediaWendaViewBinder 

public class MediaWendaViewBinder extends ItemViewBinder<MediaWendaBean.AnswerQuestionBean, MediaWendaViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected MediaWendaViewBinder.ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_media_article_wenda, parent, false);
        return new ViewHolder(view);
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private TextView tv_title;
        private TextView tv_abstract;
        private TextView tv_extra;
        private ImageView iv_dots;

        ViewHolder(View itemView) {
            super(itemView);
            this.tv_title = itemView.findViewById(R.id.tv_title);
            this.tv_abstract = itemView.findViewById(R.id.tv_abstract);
            this.tv_extra = itemView.findViewById(R.id.tv_extra);
            this.iv_dots = itemView.findViewById(R.id.iv_dots);
        }
    }

    @Override
    protected void onBindViewHolder(@NonNull final MediaWendaViewBinder.ViewHolder holder, @NonNull final MediaWendaBean.AnswerQuestionBean item) {

        final Context context = holder.itemView.getContext();

        try {
            MediaWendaBean.AnswerQuestionBean.AnswerBean answerBean = item.getAnswer();
            MediaWendaBean.AnswerQuestionBean.QuestionBean questionBean = item.getQuestion();

            final String title = questionBean.getTitle();
            String abstractX = answerBean.getContent_abstract().getText();
            String readCount = answerBean.getBrow_count() + "个回答";
            String time = answerBean.getShow_time();

            holder.tv_title.setText(title);
            holder.tv_title.setTextSize(SettingUtil.getInstance().getTextSize());
            holder.tv_abstract.setText(abstractX);
            holder.tv_extra.setText(readCount + "  -  " + time);

            RxView.clicks(holder.itemView)
                    .throttleFirst(1, TimeUnit.SECONDS)
                    .subscribe(new Consumer<Object>() {
                        @Override
                        public void accept(@io.reactivex.annotations.NonNull Object o) throws Exception {
                            WendaContentBean.AnsListBean ansBean = new WendaContentBean.AnsListBean();
                            WendaContentBean.AnsListBean.ShareDataBeanX shareBean = new WendaContentBean.AnsListBean.ShareDataBeanX();
                            WendaContentBean.AnsListBean.UserBeanX userBean = new WendaContentBean.AnsListBean.UserBeanX();
                            ansBean.setTitle(title);
                            ansBean.setQid(item.getQuestion().getQid());
                            ansBean.setAnsid(item.getQuestion().getQid());
                            shareBean.setShare_url(item.getAnswer().getWap_url());
                            userBean.setUname(item.getAnswer().getUser().getUname());
                            userBean.setAvatar_url(item.getAnswer().getUser().getAvatar_url());
                            ansBean.setShare_data(shareBean);
                            ansBean.setUser(userBean);
                            //WendaDetailActivity.launch(ansBean);
                        }
                    });

            holder.iv_dots.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    PopupMenu popupMenu = new PopupMenu(context,
                            holder.iv_dots, Gravity.END, 0, R.style.MyPopupMenu);
                    popupMenu.inflate(R.menu.menu_share);
                    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                        @Override
                        public boolean onMenuItemClick(MenuItem menu) {
                            int itemId = menu.getItemId();
                            if (itemId == R.id.action_share) {
                                IntentAction.send(context, title + "\n" + item.getAnswer().getWap_url());
                            }
                            return false;
                        }
                    });
                    popupMenu.show();
                }
            });
        } catch (Exception e) {
            ErrorAction.print(e);
        }
    }
}
View Code

  须要的item布局==>item_media_article_wenda.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginTop="4dp"
    android:background="@color/viewBackground"
    app:cardElevation="1dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackground"
        android:foreground="?attr/selectableItemBackground"
        android:padding="16dp">

        <RelativeLayout
            android:id="@+id/title_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/tv_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginEnd="22dp"
                android:layout_marginRight="22dp"
                android:ellipsize="end"
                android:maxLines="1"
                android:textStyle="bold"
                tools:text="菲总统称中国将向菲提供武 器已指示军方前往接收"/>

            <ImageView
                android:id="@+id/iv_dots"
                android:layout_width="22dp"
                android:layout_height="22dp"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:padding="4dp"
                android:scaleType="center"
                android:visibility="gone"
                app:srcCompat="@drawable/ic_dots_horizontal_grey500_24dp"
                tools:ignore="ContentDescription"/>

        </RelativeLayout>

        <TextView
            android:id="@+id/tv_abstract"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/title_view"
            android:layout_marginTop="4dp"
            android:ellipsize="end"
            android:maxLines="4"
            tools:text="美国总统当选人特朗普日前暗示,可能拿美国的“一中政策”当谈判筹码,与中国大陆就诸如人民币汇率及南海等争议讨价还价。"/>

        <TextView
            android:id="@+id/tv_extra"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tv_abstract"
            android:layout_marginTop="4dp"
            android:ellipsize="end"
            android:maxLines="1"
            android:textAppearance="@style/TextAppearance.AppCompat.Caption"
            tools:text="123阅读量 - 2222条评论 - 1小时前"/>

    </RelativeLayout>
</android.support.v7.widget.CardView>
View Code

  效果预览:

  

 

 

6.11.媒体文章头部视图绑定

public class MediaArticleHeaderViewBinder extends ItemViewBinder<MediaProfileBean.DataBean, MediaArticleHeaderViewBinder.ViewHolder> {

    private MediaChannelDao dao = new MediaChannelDao();

    @NonNull
    @Override
    protected MediaArticleHeaderViewBinder.ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_media_article_header, parent, false);
        return new ViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull final ViewHolder holder, @NonNull final MediaProfileBean.DataBean item) {

        final Context context = holder.itemView.getContext();

        try {
            // 设置头条号信息
            String imgUrl = item.getBg_img_url();
            if (!TextUtils.isEmpty(imgUrl)) {
                ImageLoader.loadCenterCrop(context, imgUrl, holder.iv_bg, R.color.viewBackground);
            }
            String avatarUrl = item.getBig_avatar_url();
            if (!TextUtils.isEmpty(imgUrl)) {
                ImageLoader.loadCenterCrop(context, avatarUrl, holder.cv_avatar, R.color.viewBackground);
            }
            holder.tv_name.setText(item.getName());
            holder.tv_desc.setText(item.getDescription());
            holder.tv_sub_count.setText(item.getFollowers_count() + " 订阅量");

            final String mediaId = item.getMedia_id();
            holder.setIsSub(mediaId);

            RxView.clicks(holder.tv_is_sub)
                    .throttleFirst(1, TimeUnit.SECONDS)
                    .observeOn(Schedulers.io())
                    .map(new Function<Object, Boolean>() {
                        @Override
                        public Boolean apply(@NonNull Object o) throws Exception {
                            return dao.queryIsExist(mediaId);
                        }
                    })
                    .observeOn(AndroidSchedulers.mainThread())
                    .doOnNext(new Consumer<Boolean>() {
                        @Override
                        public void accept(@NonNull Boolean isExist) throws Exception {
                            if (isExist) {
                                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                                builder.setMessage("取消订阅\" " + item.getName() + " \"?");
                                builder.setPositiveButton(R.string.button_enter, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        new Thread(new Runnable() {
                                            @Override
                                            public void run() {
                                                dao.delete(item.getMedia_id());
                                            }
                                        }).start();
                                        holder.tv_is_sub.setText("订阅");
                                        dialog.dismiss();
                                    }
                                });
                                builder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        holder.tv_is_sub.setText("已订阅");
                                        dialog.dismiss();
                                    }
                                });
                                builder.show();
                            }
                            if (!isExist) {
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        // 保存到数据库
                                        dao.add(item.getMedia_id(),
                                                item.getName(),
                                                item.getAvatar_url(),
                                                "news",
                                                item.getFollowers_count(),
                                                item.getDescription(),
                                                "http://toutiao.com/m" + item.getMedia_id());
                                    }
                                }).start();
                                holder.tv_is_sub.setText("已订阅");
                                Toast.makeText(context, "订阅成功", Toast.LENGTH_SHORT).show();
                            }
                        }
                    })
                    .subscribe(new Consumer<Boolean>() {
                        @Override
                        public void accept(@NonNull Boolean isExist) throws Exception {
                            holder.setIsSub(mediaId);
                        }
                    }, ErrorAction.error());

        } catch (Exception e) {
            ErrorAction.print(e);
        }
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private ImageView iv_bg;
        private CircleImageView cv_avatar;
        private TextView tv_name;
        private TextView tv_desc;
        private TextView tv_is_sub;
        private TextView tv_sub_count;

        public ViewHolder(View itemView) {
            super(itemView);
            this.iv_bg = itemView.findViewById(R.id.iv_bg);
            this.cv_avatar = itemView.findViewById(R.id.cv_avatar);
            this.tv_name = itemView.findViewById(R.id.tv_name);
            this.tv_desc = itemView.findViewById(R.id.tv_desc);
            this.tv_is_sub = itemView.findViewById(R.id.tv_is_sub);
            this.tv_sub_count = itemView.findViewById(R.id.tv_sub_count);
        }

        private void setIsSub(final String mediaId) {
            boolean isExist = dao.queryIsExist(mediaId);
            if (isExist) {
                tv_is_sub.setText("已订阅");
            } else {
                tv_is_sub.setText("订阅");
            }
        }
    }
}
View Code

  须要的item布局==>item_media_article_header.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/windowBackground">

    <ImageView
        android:id="@+id/iv_bg"
        android:layout_width="match_parent"
        android:layout_height="110dp"
        android:scaleType="centerCrop"
        android:src="@mipmap/error_image"
        tools:ignore="ContentDescription"/>

    <com.jasonjan.headnews.widget.CircleImageView
        android:id="@+id/cv_avatar"
        android:layout_width="52dp"
        android:layout_height="52dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="18dp"
        android:layout_marginStart="18dp"
        android:layout_marginTop="84dp"
        app:srcCompat="@color/viewBackground"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/iv_bg"
        android:orientation="vertical"
        android:paddingBottom="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingTop="36dp">

        <TextView
            android:id="@+id/tv_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textAppearance="@style/TextAppearance.AppCompat.Large"
            tools:text="新京报"/>

        <TextView
            android:id="@+id/tv_desc"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:ellipsize="end"
            android:maxLines="2"
            tools:text="慧眼看中国,咱们愿作你的4D眼镜。独家调查、深度报道,在这里,新京报能让你获得不同的知足。"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/tv_is_sub"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="?attr/selectableItemBackground"
                android:foreground="?attr/selectableItemBackground"
                android:gravity="center"
                android:padding="8dp"
                android:text="@string/subscribe"
                android:textSize="16sp"
                android:textStyle="bold"/>

            <TextView
                android:id="@+id/tv_sub_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp"
                tools:text="654244 订阅量"/>

        </LinearLayout>
    </LinearLayout>
</RelativeLayout>
View Code

  效果预览:

  

 

 

6.12.整理一下流程

  首先点击了右上角的用户图标后,进入一个MediaHomeActivity活动

  

  而后首先去请求了IMobileMediaApi接口,获取到MediaProfile一些信息

 

  而后执行初始化initTabLayout,将决定有几个分页

 

  而后将获取到的MediaProfile中的信息显示在文章中的头部

 

  而后请求文章列表的API,可见的时候,加载。

 

  而后请求视频列表的API,可见的时候,加载。

 

  而后请求问答列表的API,可见的时候,加载。