title: Null Pointer in Adapters when Data Transmission INterupted
body: <p>I get <code>null</code> Force Closes on my Android App when the user interrupts transmission to a data feed.  Or sometimes if the internet is slow and it seems to stall I get <code>null</code></p>
  
  <p>Here is how I handle the http code:</p>
  
  <pre><code>        HttpClient httpClient = new DefaultHttpClient();
          HttpPost httpPost = new HttpPost(url_select);
  
          try {
              httpPost.setEntity(new UrlEncodedFormEntity(param));
              HttpResponse httpResponse = httpClient.execute(httpPost);
              HttpEntity httpEntity = httpResponse.getEntity();
  
              // read content
              is = httpEntity.getContent();
  
          } catch (Exception e) {
  
              Log.e("log_tag", "Error in http connection " + e.toString());
          }
          try {
              BufferedReader br = new BufferedReader(
                      new InputStreamReader(is));
              StringBuilder sb = new StringBuilder();
              String line = "";
              while ((line = br.readLine()) != null) {
                  sb.append(line + "\n");
              }
              is.close();
              result = sb.toString();
  
          } catch (Exception e) {
              Log.e("log_tag", "Error converting result " + e.toString());
          }
  
          return null;
      }
  </code></pre>
  
  <p>Then in <code>onPostExecute</code> of the <code>AsyncTask</code>, null is returned here as seen in the LogCat below:</p>
  
  <pre><code>adapter = new ReviewAdapter(getActivity(), r, tf); // Line 1164
  </code></pre>
  
  <p>I assume <code>r</code> is what is <code>null</code> that kills it?    (<code>tf</code> is a TrueType Font I pass in)</p>
  
  <p>Here is the <code>r</code> code:</p>
  
  <pre><code>        for (String i : reviews) {
              r[index] = new Review(reviews.get(index),
                      datelist.get(index), userlist.get(index),
                      itemlist.get(index), ratings.get(index),
                      helpfulCount.get(index), chatCounts.get(index),
                      catlist.get(index), titlelist.get(index));
              index++;
          }
  </code></pre>
  
  <p>These <code>ArrayLists</code> are populated through <code>JSON</code> Parsing from <code>PHP</code>, etc.</p>
  
  <p>So my question is:  How do I handle this popularly?  Is there away to avoid null? Or how can I gracefully throw a error rather than forceclose?</p>
  
  <p>Here is Logcat:</p>
  
  <pre><code>02-19 12:15:12.012: E/AndroidRuntime(32116): FATAL EXCEPTION: main
  02-19 12:15:12.012: E/AndroidRuntime(32116): java.lang.NullPointerException
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.widget.ArrayAdapter.&lt;init&gt;(ArrayAdapter.java:128)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at com.---.---.ReviewAdapter.&lt;init&gt;(ReviewAdapter.java:42)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at com.---.---.RateFragmentActivity$ReviewFragment$ReviewTask.onPostExecute(RateFragmentActivity.java:1164)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at com.---.---.RateFragmentActivity$ReviewFragment$ReviewTask.onPostExecute(RateFragmentActivity.java:1)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.os.AsyncTask.finish(AsyncTask.java:631)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.os.AsyncTask.access$600(AsyncTask.java:177)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.os.Handler.dispatchMessage(Handler.java:99)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.os.Looper.loop(Looper.java:137)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at android.app.ActivityThread.main(ActivityThread.java:5193)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at java.lang.reflect.Method.invokeNative(Native Method)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at java.lang.reflect.Method.invoke(Method.java:511)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
  02-19 12:15:12.012: E/AndroidRuntime(32116):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>