title: Is running a for loop in a Volley response listener okay?
body: <p>I'm getting this in my logcat: <code>skipped X frames! The application may be doing too much work on its main thread</code> where X is usually between 40 and 60.</p>
  
  <p>I'm new to android development and I'm not sure how much Volley does with AsyncTasks. In my fragment, I send a request to the server for JSON like such: </p>
  
  <pre><code>{ "networks" : [ { "name" : "a name", "external_id" : "an external_id" }, ... ] }
  </code></pre>
  
  <p>The <code>...</code> is just a place holder for elements that are of the same form as the first one I showed in the array.</p>
  
  <p>I do basically all of the work in the <code>onActivityCreated</code> function in my Fragment.</p>
  
  <p>Here is the code and I'm not sure if I'm doing anything wrong. Also, the point of the for loop is to loop through the JSONArray and turn each element into its own model which I then pass to an ArrayList which ultimately gets adapted for the UI via an Adapter.</p>
  
  <pre><code>@Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
  
      mSessionPreferences = this.getActivity().getSharedPreferences(
              getString(R.string.session_shared_preferences_key), Context.MODE_PRIVATE);
  
      networks = getListView();
  
      networkItems = new ArrayList&lt;Network&gt;();
      listAdapter = new NetworksListAdapter(getActivity(), networkItems);
      networks.setAdapter(listAdapter);
  
      JSONObject params = new JSONObject();
      params.put("user_id", mSessionPreferences.getString(getString(R.string.user_id_key), null))
            .put("auth_token", mSessionPreferences.getString(getString(R.string.user_auth_token_key), null));
  
      Response.Listener&lt;JSONObject&gt; listener = new Response.Listener&lt;JSONObject&gt;() {
          @Override
          public void onResponse(JSONObject response) {
              JSONArray jsonNetworks = response.optJSONArray("networks");
              int len = jsonNetworks.length();
              for (int i = 0; i &lt; len; i++) {
                  JSONObject jsonNetwork = jsonNetworks.optJSONObject(i);
                  Network network = new Network(jsonNetwork.optString("external_id"),
                              jsonNetwork.optString("name");
  
                  networkItems.add(network);
              }
  
              listAdapter.notifyDataSetChanged();
          }
      };
  
      Response.ErrorListener errorListener = new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              VolleyErrorHandler volleyError = new VolleyErrorHandler(error);
  
              Log.v("Sigh", volleyError.getMessage(), "nope"));
          }
      };
  
      APIRequestManager.getInstance().doRequest().getNetworks(params, listener, errorListener);
  }
  </code></pre>
  
  <p>The last line takes care of having Volley send the request. </p>
  
  <p>Is there anything that looks suspicious? Note, this isn't on an emulator, it is on my actual device. I was under the impression that it handles the Async stuff. Should I be doing things with my listeners in the background explicitly? If so, how would I do that?</p>