Im developing an app using eclipse and retrofit that is designed to get a JSON array of objects and present it in a listview. My webservice works fine.I am using retrofit2 to get POJO class as follows:
public static UnicsAgencyApi getUnicsAgencyApi() {
        if (sUnicsAgencyApi == null) {
            retrofit = new Retrofit.Builder().baseUrl(ENDPOINT_URL).addConverterFactory(GsonConverterFactory.create())
                    .build();
            sUnicsAgencyApi = retrofit.create(UnicsAgencyApi.class);
        }
        return sUnicsAgencyApi;
    }
    public interface UnicsAgencyApi {
        @GET("api/uconnectservice/AllAgency")
        Call<ArrayList<AgencyModel>> getStreams();
    }
and here is where i call:
public void ShowAllUnicsAgencyInfo() {
        // get prompts.xml view
        LayoutInflater layoutInflater = LayoutInflater.from(Homepage.this);
        final View promptView = layoutInflater.inflate(R.layout.view_agency_list, null);
        listView2 = (ListView) promptView.findViewById(R.id.list);
        // GET DATA FROM WEBSERVICE
        ArrayList<AgencyModel> AgencyList = null;
        AgencyList = DownloadAgencyData();
        **AgencyListAdapter mAdapter = new AgencyListAdapter(this, AgencyList);**
        listView2.setAdapter(mAdapter);
        // ListView Item Click Listener
        listView2.setOnItemSelectedListener(new CustomOnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
                Toast.makeText(parent.getContext(),
                        "OnItemSelectedListener : " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_SHORT)
                        .show();
            }
        });
        final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(Homepage.this);
        alertDialogBuilder.setView(promptView);
        // setup a dialog window
        alertDialogBuilder.setCancelable(false).setNeutralButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
            }
        });
        // create an alert dialog
        AlertDialog alert = alertDialogBuilder.create();
        alert.show();
    }
    public ArrayList<AgencyModel> DownloadAgencyData() {
        RestApi.getUnicsAgencyApi().getStreams().enqueue(new Callback<ArrayList<AgencyModel>>() {
            @Override
            public void onFailure(Call<ArrayList<AgencyModel>> arg0, Throwable arg1) {
                // TODO Auto-generated method stub
                Log.e("Error in parsing", arg0.toString());
            }
            @Override
            public void onResponse(Call<ArrayList<AgencyModel>> AgencyModelData,
                    Response<ArrayList<AgencyModel>> response) {
                // TODO Auto-generated method stub
                mstreamData = new ArrayList<AgencyModel>();
                // ADD TO List here!!!!!!!!
                // Log.e("Response", "" + response.body().size());
                **mstreamData.addAll(response.body());**
            }
        });
        return mstreamData;
    }
However the error i keep getting is from custom array adapter getCount() method via following Logcat:
 01-03 02:48:41.615: E/test(30453): Exception
    01-03 02:48:41.635: E/AndroidRuntime(30453): FATAL EXCEPTION: main
    01-03 02:48:41.635: E/AndroidRuntime(30453): Process: com.nickSoft.unics_alpha, PID: 30453
    01-03 02:48:41.635: E/AndroidRuntime(30453): java.lang.NullPointerException
    01-03 02:48:41.635: E/AndroidRuntime(30453):    at com.nickSoft.unics_alpha.AgencyListAdapter.getCount(AgencyListAdapter.java:26)
    01-03 02:48:41.635: E/AndroidRuntime(30453):    at android.widget.ListView.setAdapter(ListView.java:480)
    01-03 02:48:41.635: E/AndroidRuntime(30453):    at com.nickSoft.unics_alpha.Homepage.ShowAllUnicsAgencyInfo(Homepage.java:546)
Please i can't seem to identify where i went wrong,any guidance as to what could be the error or better way of solving this prob is greatly appreciated,cheers
 
     
    