title: Attempt to invoke virtual method 'java.util.UUID..' on a null object refrence when using Swip To Dismiss RecyclerView
body: <p>I'm trying using <em>Swip To Dismiss RecyclerView</em>, i used this <a href="https://www.learn2crack.com/2016/02/custom-swipe-recyclerview.html/" rel="nofollow noreferrer">tutorial</a></p>
  
  <p>but when i'm trying to delete item in my <code>FragmentOne</code> by <code>swipeToDelete</code> method, it shows this <code>Error</code>:</p>
  
  <pre><code>    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.UUID com.drgnme.listhamrah.Detail.getId()' on a null object reference
  at com.drgnme.listhamrah.DetailLab.deleteDetail(DetailLab.java:82)
  at com.drgnme.listhamrah.FragmentOne$DetailAdapter.swipeToDelete(FragmentOne.java:396)
  at com.drgnme.listhamrah.ItemSwipeHelper.onSwiped(ItemSwipeHelper.java:43)
  at android.support.v7.widget.helper.ItemTouchHelper$4.run(ItemTouchHelper.java:681)
  at android.os.Handler.handleCallback(Handler.java:739)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:148)
  at android.app.ActivityThread.main(ActivityThread.java:5451)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p>i used <code>this</code> in another place in this <code>Fragment</code> for <code>Delete</code> item and it's work just fine, don't know what's the problem here..</p>
  
  <p><strong><code>this</code></strong> :</p>
  
  <pre><code>DetailLab.get(getActivity()).deleteDetail(mDetail);
  updateUI();
  updateNumbers();
  </code></pre>
  
  <p>and here is my <code>FragmentOne</code>:</p>
  
  <pre><code>public class FragmentOne extends Fragment {
  private static final String
          SAVED_NUMBER_VISIBLE = "number";
  
  private RecyclerView mDetailRecyclerView;
  private DetailAdapter mAdapter;
  private boolean mNumberVisible;
  
  private View view;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setHasOptionsMenu(true);
  }
  
  
  @Override
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container,
                           Bundle savedInstanceState) {
      view = inflater.inflate(R.layout.fragment_one_layout,
              container, false);
  
      mDetailRecyclerView = (RecyclerView) view.findViewById(R.id.detail_recycler_view);
  
      LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
      layoutManager.setReverseLayout(true); //This will reverse the data order but not scroll the RecyclerView to the last item
      layoutManager.setStackFromEnd(true); //For keeping data order same and simply scrolling the RecyclerView to the last item
      mDetailRecyclerView.setLayoutManager(layoutManager);
  
      if (savedInstanceState != null) {
          mNumberVisible =
                  savedInstanceState.getBoolean(SAVED_NUMBER_VISIBLE);
      }
  
      updateUI();
  
  
      return view;
  }
  
  @Override
  public void onResume() {
      super.onResume();
      updateUI();
  }
  
  @Override
  public void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
      outState.putBoolean(SAVED_NUMBER_VISIBLE, mNumberVisible);
  }
  ..
  ..    
  
  
  protected void updateUI() {
      DetailLab detailLab = DetailLab.get(getActivity());
      List&lt;Detail&gt; details = detailLab.getDetails();
      if (details.size() == 0) {
          LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.empty_view);
          linearLayout.setVisibility(View.VISIBLE);
      } else {
          LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.empty_view);
          linearLayout.setVisibility(View.GONE);
      }
  
      if (mAdapter == null) {
          mAdapter = new DetailAdapter(details);
          mDetailRecyclerView.setAdapter(mAdapter);
  
      } else {
          mAdapter.setDetails(details);
          mAdapter.notifyDataSetChanged();
      }
  
      updateNumbers();
  }
  
  private class DetailHolder extends RecyclerView.ViewHolder
          implements View.OnClickListener, View.OnLongClickListener {
      private TextView mTitleTextView;
      //        private TextView mDateTextView;
      private Detail mDetail;
      private RatingBar mRatingBar;
  
      public DetailHolder(LayoutInflater inflater, ViewGroup parent) {
          super(inflater.inflate(R.layout.list_item_detail,
                  parent, false));
  
          itemView.setOnClickListener(this);
          itemView.setOnLongClickListener(this);
          mTitleTextView = (TextView) itemView.findViewById(R.id.detail_title);
          mRatingBar = (RatingBar) itemView.findViewById(R.id.ratingBar);
      }
  
      public void bind(Detail detail) {
          mDetail = detail;
          mTitleTextView.setText(mDetail.getTitle());
          mRatingBar.setRating(mDetail.getRate());
      }
  
      @Override
      public void onClick(View view) {
          Intent intent = DetailPagerActivity.newIntent(getActivity(),
                  mDetail.getId());
          startActivity(intent);
      }
  
      @Override
      public boolean onLongClick(View v) {
  
          AlertDialog.Builder alert = new AlertDialog.Builder(
                  getActivity());
          alert.setMessage(R.string.alert);
          alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  DetailLab.get(getActivity()).deleteDetail(mDetail);
                  updateUI();
                  updateNumbers();
                  dialog.dismiss();
              }
          });
          alert.setNegativeButton("No", new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
              }
          });
          alert.show();
          return true;
      }
  }
  
  
  private class DetailAdapter extends RecyclerView.Adapter&lt;DetailHolder&gt; implements ItemTouchHelperAdapter {
      private List&lt;Detail&gt; mDetails;
      private Detail mDetail;
  
      public DetailAdapter(List&lt;Detail&gt; details) {
          mDetails = details;
      }
  
      @Override
      public DetailHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          LayoutInflater layoutInflater =
                  LayoutInflater.from(getActivity());
  
          return new DetailHolder(layoutInflater, parent);
      }
  
      @Override
      public void onBindViewHolder(DetailHolder holder, int position) {
          Detail detail = mDetails.get(position);
          holder.bind(detail);
      }
  
      @Override
      public int getItemCount() {
          return mDetails.size();
      }
  
      public void setDetails(final List&lt;Detail&gt; details) {
          mDetails = details;
  
  
          ItemTouchHelper.Callback itemTouchCallBack=new ItemSwipeHelper(Direction.RIGHT, mAdapter);
          ItemTouchHelper swipeToDismissTouchHelper =new ItemTouchHelper(itemTouchCallBack);
          swipeToDismissTouchHelper.attachToRecyclerView(mDetailRecyclerView);
  
      }
  
  
      @Override
      public void swipeToDelete(int position) {
  
      DetailLab.get(getActivity()).deleteDetail(mDetail);
      updateUI();
      updateNumbers();
  
      }
  }
  }
  </code></pre>