title: Problem with Adapter class, no crash, but page freezes and reloads
body: <p>In my CommentAdapter.java class I have the following code. When a user leaves a comment on a certain post the image icon has to change from the black chat icon to the yellow chat icon. Works fine. The problem arises when a user deleted the comment that they left on the post. If they delete their comment and there are no other comments from that user for that post the chat icon should be changed back from yellow to black. </p>
  
  <p>It works and I get the desired result, but for some reason it throws a null pointer, the page freezes, reloads, and then it takes me back to the home page with desired result. I need for the entire process to run smoother obviously without any null pointers. </p>
  
  <p>And yes, obviously I know what null pointers are and how to fix them, but here I can't understand why I am getting it. Chat icon exists and all.</p>
  
  <p>Crash line marked with arrow below.</p>
  
  <p><strong>CommentAdapter</strong></p>
  
  <pre><code>public class CommentAdapter extends RecyclerView.Adapter&lt;CommentAdapter.ViewHolder&gt; {
  
      ImageView mImageView;
  
      private Context mContext;
      private List&lt;Comment&gt; mComment;
      private String postid;
      private FirebaseUser mFirebaseUser;
  
      public CommentAdapter(Context mContext, List&lt;Comment&gt; mComment, String postid) {
          this.mContext = mContext;
          this.mComment = mComment;
          this.postid = postid;
      }
  
      @NonNull
      @Override
      public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(mContext).inflate(R.layout.comment_item, parent, false);
          return new CommentAdapter.ViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
  
          mFirebaseUser = FirebaseAuth.getInstance().getCurrentUser();
          final Comment comment = mComment.get(position);
  
          holder.comment.setText(comment.getComment());
          getUserInfo(holder.image_profile, holder.username, comment.getPublisher());
  
   holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
              @Override
              public boolean onLongClick(final View v) {
                  if (comment.getPublisher().equals(mFirebaseUser.getUid())) {
  
                      AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
                      alertDialog.setTitle("Do you want to delete this comment?");
                      alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "No",
                              new DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialog, int which) {
                                      dialog.dismiss();
                                  }
                              });
                      alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Yes",
                              new DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialog, int which) {
                                      Log.d("POSTID -&gt;", postid);
                                      FirebaseDatabase.getInstance().getReference("Comments").child(postid).child(comment.getCommentid())
                                              .setValue(null).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() {
                                          @Override
                                          public void onComplete(@NonNull Task&lt;Void&gt; task) {
                                              if (task.isSuccessful()) {
     -------------------------------------------&gt; mImageView.setImageResource(R.drawable.ic_chat_black);
                                                  Toast.makeText(mContext, "Your comment has been deleted", Toast.LENGTH_SHORT).show();
                                              }
                                          }
                                      });
                                      dialog.dismiss();
                                  }
                              });
                      alertDialog.show();
                  }
                  return true;
              }
          });
  
   public static class ViewHolder extends RecyclerView.ViewHolder {
  
          ImageView image_profile, imageView;
          public TextView username, comment;
  
          ViewHolder(@NonNull View itemView) {
              super(itemView);
  
              image_profile = itemView.findViewById(R.id.image_profile);
              comment = itemView.findViewById(R.id.comment);
              username = itemView.findViewById(R.id.username);
              imageView = itemView.findViewById(R.id.commentPost);
          }
      }
  </code></pre>
  
  <p><strong>Logcat</strong></p>
  
  <p>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.e.events, PID: 18463
      java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference
          at com.e.events.Adapter.CommentAdapter$3$2$1.onComplete(CommentAdapter.java:110)
          at com.google.android.gms.tasks.zzj.run(Unknown Source:4)
          at android.os.Handler.handleCallback(Handler.java:907)
          at android.os.Handler.dispatchMessage(Handler.java:105)
          at android.os.Looper.loop(Looper.java:216)
          at android.app.ActivityThread.main(ActivityThread.java:7625)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)</p>