Why not show posts from server when use Retrofit in Android
<p>I want to use <code>Retrofit</code> to load data from server, and I use <code>DataModel</code> for set and get data.</p>

<p>This is what I would like to do. When I click on a Category, I want to see posts from this category in the other <code>Activity</code>.</p>

<p>For showing category posts I use this link : <a href="http://tellfa.com/tafrihgah/?json=get_category_posts" rel="nofollow">http://tellfa.com/tafrihgah/?json=get_category_posts</a></p>

<p>For filtering I use <code>category id</code>.</p>

<p>For example : <a href="http://tellfa.com/tafrihgah/?json=get_category_posts&amp;id=1" rel="nofollow">http://tellfa.com/tafrihgah/?json=get_category_posts&amp;id=1</a> by this link i see all of posts from Category1. <br></p>

<p>My <code>Retrofit interface</code> for set link: (I set <code>base_url</code> in <strong>other class</strong>)</p>

<pre><code>public interface Retrofit_ApiInterface {

    // For Categories Response
    @GET("tafrihgah/?json=get_category_posts&amp;")
    Call&lt;R_CatModelResponse&gt; getCatResponse(@Query("id") Integer id);
}
</code></pre>

<p>I send category id to other activity by this code : </p>

<pre><code>    public class ColoniesAdapter extends RecyclerView.Adapter&lt;ColoniesAdapter.ViewHolder&gt; {

        private List&lt;Retrofit_ColoniesModel&gt; mDateSet;
        private Context mContext;
        private SparseBooleanArray expandState = new SparseBooleanArray();

        public ColoniesAdapter(Context context, List&lt;Retrofit_ColoniesModel&gt; dataSet) {
            this.mContext = context;
            this.mDateSet = dataSet;
            for (int i = 0; i &lt; mDateSet.size(); i++) {
                expandState.append(i, false);
            }
        }

        @Override
        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

            View view = LayoutInflater.from(mContext).inflate(R.layout.colonies_row, parent, false);
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(final ViewHolder holder, final int position) {

            holder.colonies_title.setText(mDateSet.get(position).getTitle());
            holder.colonies_title.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int pos = holder.getPosition();
                    Retrofit_ColoniesModel model = mDateSet.get(pos);
                    mContext.startActivity(new Intent(v.getContext(), Category_page.class)
                            .putExtra("categoryTitle", model.getTitle())
                            .putExtra("categoryID", model.getId()));

                    Toast.makeText(mContext, " " + model.getId(), Toast.LENGTH_SHORT).show();
                }
            });

...
</code></pre>

<p><strong>Category_page code:</strong></p>

<pre><code>public class Category_page extends AppCompatActivity {

    private static final long RIPPLE_DURATION = 250;
    private Toolbar toolbar;
    private TextView toolbar_title;
    private ImageView toolbar_menuImage;
    private RelativeLayout root;
    private CategoryAdapter mAdapter;
    private RecyclerView cat_recyclerView;
    private LinearLayoutManager mLayoutManager;
    private RelativeLayout loadLayout;
    private String catTitle = "";
    private Integer catID;
    private Bundle bundle;
    private int pageCount = 1;
    private Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.category_page);
        //if (!EventBus.getDefault().isRegistered(this)) {
        //   EventBus.getDefault().register(this);
        //}

        // Hide StatusBar color
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

        // Initializing
        context = Category_page.this;
        toolbar = (Toolbar) findViewById(R.id.category_toolbar);
        cat_recyclerView = (RecyclerView) findViewById(R.id.category_recycler);
        toolbar_title = (TextView) toolbar.findViewById(R.id.toolbar_pages_title);
        mLayoutManager = new LinearLayoutManager(this);
        root = (RelativeLayout) findViewById(R.id.category_root);
        loadLayout = (RelativeLayout) findViewById(R.id.category_empty_layout);
        // Toolbar
        setSupportActionBar(toolbar);
        if (toolbar != null) {
            getSupportActionBar().setTitle("");
        }

        // Receive Data
        bundle = getIntent().getExtras();
        catID = bundle.getInt("categoryID");
        if (bundle != null) {
            catTitle = bundle.getString("categoryTitle");
        }
        if (catTitle != null) {
            toolbar_title.setText(catTitle);
        }

        // Load data
        //LoadData(catID);
        // Menu
        View guillotineMenu = LayoutInflater.from(this).inflate(R.layout.menu_layout, null);
        root.addView(guillotineMenu);
        toolbar_menuImage = (ImageView) toolbar.findViewById(R.id.toolbar_pages_logo);
        new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findViewById(R.id.menu_layout_image), toolbar_menuImage)
                .setStartDelay(RIPPLE_DURATION)
                .setActionBarViewForAnimation(toolbar)
                .setClosedOnStart(true)
                .build();
        // RecyclerView
        cat_recyclerView.setLayoutManager(mLayoutManager);
        cat_recyclerView.setHasFixedSize(true);

        // Retrofit //////////
        Retrofit_ApiInterface apiInterface = Retrofit_ApiClient.getClient().create(Retrofit_ApiInterface.class);
        Call&lt;R_CatModelResponse&gt; call = apiInterface.getCatResponse(catID);

        call.enqueue(new Callback&lt;R_CatModelResponse&gt;() {
            @Override
            public void onResponse(Call&lt;R_CatModelResponse&gt; call, Response&lt;R_CatModelResponse&gt; response) {
                List&lt;R_CatModel&gt; models = response.body().getCat_posts();

                mAdapter = new CategoryAdapter(context, cat_recyclerView, models);
                cat_recyclerView.setAdapter(mAdapter);

                Toast.makeText(Category_page.this, "Response", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onFailure(Call&lt;R_CatModelResponse&gt; call, Throwable t) {

                Toast.makeText(Category_page.this, "Error", Toast.LENGTH_SHORT).show();

            }
        });
</code></pre>

<p>I send category_id with below code from one adapter :            </p>

<pre><code>mContext.startActivity(new Intent(v.getContext(), Category_page.class)
        .putExtra("categoryTitle", model.getTitle())
        .putExtra("categoryID", model.getId()));
</code></pre>

<p>and receive this data with below code : </p>

<pre><code>// Receive Data
bundle = getIntent().getExtras();
catID = bundle.getInt("categoryID");
</code></pre>

<p>But <strong>Error message</strong> (<code>Toast</code>) instead of <strong>category posts</strong>!</p>

<p>show error toast from :         </p>

<pre><code>@Override
public void onFailure(Call&lt;R_CatModelResponse&gt; call, Throwable t) {
    Toast.makeText(Category_page.this, "Error", Toast.LENGTH_SHORT).show();
}
</code></pre>

<p><strong>Update :</strong> <br>
This is the error I get, : </p>

<pre><code>E/CatResponseError: Error : com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 48 path $.category
</code></pre>

<p><strong>Update #2 :</strong> <br>
Added my POJO class : </p>

<pre><code>public class R_CatModelResponse {

    @SerializedName("status")
    public String Cat_status;
    @SerializedName("count")
    public int Cat_count;
    @SerializedName("pages")
    public int Cat_pages;
    @SerializedName("category")
    public List&lt;Retrofit_ColoniesModel&gt; category;
    @SerializedName("posts")
    public List&lt;R_CatModel&gt; Cat_posts;

    public String getCat_status() {
        return Cat_status;
    }

    public void setCat_status(String cat_status) {
        Cat_status = cat_status;
    }

    public int getCat_count() {
        return Cat_count;
    }

    public void setCat_count(int cat_count) {
        Cat_count = cat_count;
    }

    public int getCat_pages() {
        return Cat_pages;
    }

    public void setCat_pages(int cat_pages) {
        Cat_pages = cat_pages;
    }

    public List&lt;Retrofit_ColoniesModel&gt; getCategory() {
        return category;
    }

    public void setCategory(List&lt;Retrofit_ColoniesModel&gt; category) {
        this.category = category;
    }

    public List&lt;R_CatModel&gt; getCat_posts() {
        return Cat_posts;
    }

    public void setCat_posts(List&lt;R_CatModel&gt; cat_posts) {
        Cat_posts = cat_posts;
    }
}
</code></pre>

<p>How can I fix this?</p>

<p>Please help me. Thanks in advance.</p>