title: context null reference issue
body: <p>Super hard one to explain.</p>
  
  <p>This is the error I get in my reporting:</p>
  
  <pre><code>Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
  </code></pre>
  
  <p>This seems to happen intermittently when you go into and out of the fragment. The error seems to happen in the adaptor.</p>
  
  <p>This is where it is called:</p>
  
  <pre><code>    @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
          getActivity().setTitle("Shipments");
  
          myView = inflater.inflate(R.layout.shipments_out_layout, container, false);
  
          listView = myView.findViewById(R.id.listView);
  
          fetchShipments();
  
          return myView;
      }
  
      /**
       * Fetch shipments
       */
      public void fetchShipments()
      {
          shipmentsService.fetchFromServer(getActivity());
      }
  
      /**
       * Show shipments
       */
      public void showShipments(){
          RealmResults&lt;Shipment&gt; savedShipments = shipmentsService.all();
  
          ShipmentsAdaptor adaptor = new ShipmentsAdaptor(savedShipments, this.getContext());
  
          listView.setAdapter(adaptor);
      }
  </code></pre>
  
  <p>And this is where the error is in the adaptor:</p>
  
  <pre><code>public class ShipmentsAdaptor extends ArrayAdapter&lt;Shipment&gt; {
  
  private RealmResults&lt;Shipment&gt; dataSet;
  Context mContext;
  
  // View lookup cache
  private static class ViewHolder {
      TextView stockItemId;
      TextView technicianName;
      TextView shipmentDate;
  }
  
  public ShipmentsAdaptor(RealmResults&lt;Shipment&gt; data, Context context){
      super(context, R.layout.shipments_out_row_item, data);
      this.dataSet = data;
      this.mContext = context;
  }
  </code></pre>
  
  <p>It's this line specifically: <code>super(context, R.layout.shipments_out_row_item, data);</code></p>
  
  <p>I thought it may be something to do with the way we are inserting the context into the adaptor and then changing the page before its finished but that proved inconclusive.</p>
  
  <p>Paste bin with adaptor:<a href="https://pastebin.com/dWNQnq05" rel="nofollow noreferrer">Adaptor</a></p>
  
  <p><a href="https://i.stack.imgur.com/CX8Lz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CX8Lz.png" alt="enter image description here"></a></p>