I have implemented the Android-PullToRefresh in the application. Everything works fine but the pull to refresh keeps on loading after data is loaded in the Listview.
list = (PullToRefreshListView) findViewById(R.id.stored_location);
alertLocationList = list.getRefreshableView();
list.setMode(Mode.PULL_FROM_END);
list.setOnRefreshListener((new PullToRefreshBase.OnRefreshListener< ListView>() {
@Override
public void onRefresh(PullToRefreshBase<ListView> refreshView) {
list.onRefreshComplete();
if (Integer.valueOf(totalCount)==Integer.valueOf(endcount)) {
// list.onRefreshComplete();
Log.e(TAG,"----Loaded in listener---");
}
else {
Log.e(TAG,"----calling next data---");
stored_List_Call();
}
}
}));
and below is my post execute method that I have used
@Override
protected void onPostExecute(String result)
{
dialog.dismiss();
switch (asynctaskEnum)
{
case storedLocationList:
try
{
if(result==null)
{
Log.e("result", "result is null");
return;
}
JSONObject header_Object=new JSONObject(result);
if(header_Object.getJSONObject("header").getString("status").equals("1")) {
response_Data(result); //this method parse the Json response and added it to the array list
if(userLocationsAdapter==null) {
Log.e(TAG,"list size--->"+storedUserLocationList.size());
userLocationsAdapter = new StoredLocationAdapter(storedUserLocationList, Activity.this);
alertLocationList.setAdapter(userLocationsAdapter);
}else
{
Log.e(TAG, "list size in else--->" + storedUserLocationList.size());
list.onRefreshComplete();
userLocationsAdapter.notifyDataSetChanged();
}
}
else {
Toast.makeText(Activity.this, "Please try again...", Toast.LENGTH_SHORT).show();
return;
}
}
catch (Exception e) {
e.printStackTrace();
}
break;
default:
break;
}
super.onPostExecute(result);
}
Anyone tell me where I have missed the thing. I have spent a whole day to find this issue. Please help me out.
Thanks in advance.