Gouse Mohiddin
Gouse Mohiddin

Reputation: 41

My posts not updating in my RSS APP

I created an android app to read feed from my blog, but when I added a new post in the blog it is not changing in the app after refresh action.

This is my refresh menu button code, it is working fine but giving the same old data no mater how many times I hit refresh.

@Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if(item.getItemId()== R.id.menu_refresh) {
        mdialog = new ProgressDialog(this);
        mdialog.setMessage("Loading Content Please Wait...");
        mdialog.show();

        JsonParse();

//I even specified DatasetChanged(); and still it is not working

        itemsAdapter.notifyDataSetChanged();

        mqueue.addRequestFinishedListener(new 
        RequestQueue.RequestFinishedListener<String>() {
            @Override
            public void onRequestFinished(Request request) {
                mdialog.dismiss();
            }
        });



    }

    return true;
}

This is my Volley JSON Parsing Code

private void JsonParse() {

String url = "https://api.rss2json.com/v1/api.json?rss_url=http://itzmydarz.blogspot.com/atom.xml";
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {


        @Override
        public void onResponse(JSONObject response) {
            try {
                JSONArray jsonArray = response.getJSONArray("items");
                for(int i =0; i<jsonArray.length();i++){
                    JSONObject items = jsonArray.getJSONObject(i);
                    String title = items.getString("title");
                    String date = items.getString("pubDate");
                    String data= items.getString("description");
                   // String imageurl= items.getString("url");
                    webPageItemsList.add(new WebPageItems(data,title,date));

                }

itemsAdapter = new ItemsAdapter(MainActivity.this,webPageItemsList);
                recyclerView.setAdapter(itemsAdapter);


            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
        }
    });

    mqueue.add(request);

}

}

Upvotes: 0

Views: 264

Answers (1)

Irfan Momin
Irfan Momin

Reputation: 11

because your Jsonparse not call that's why

Upvotes: 1

Related Questions