Output not showing when the firebase ui upgrade to 3.2.2

前端 未结 1 1929
忘掉有多难
忘掉有多难 2021-01-29 02:00

When i upgrade my firebase-ui version to 3.2.2 the firebaserecycleradapter doesn\'t show any output the code of mine. at first when i got multidex error then i upgrade all libra

1条回答
  •  醉梦人生
    2021-01-29 02:41

    In order to make your code work, please consider using the following steps.

    1. Remove the static from the declaration of your UsersViewHolder class. Should be only:

      public class UsersViewHolder extends RecyclerView.ViewHolder {/* ... */}
      
    2. Remove the static keyword also from the mView field and all your methods. Your holder class should look like this:

      public class UsersViewHolder extends RecyclerView.ViewHolder {
          private View mView;
          private CircleImageView mUserView;
      
          public UsersViewHolder(View itemView) {
              super(itemView);
              mView = itemView;
          }
      
          public void setName(String name){
              TextView userNameView = (TextView) mView.findViewById(R.id.user_single_name);
              userNameView.setText(name);
          }
          public void setStatus(String status){
              TextView userStatusView = (TextView) mView.findViewById(R.id.user_single_status);
              userStatusView.setText(status);
          }
          public void setRIDNo(String ridno){
              TextView userRIDNoView = (TextView) mView.findViewById(R.id.user_single_ridno);
              userRIDNoView.setText(ridno);
          }
          public void setUserImage(String thumb_image, Context ctx){
              CircleImageView userImageView = (CircleImageView) mView.findViewById(R.id.user_single_image);
              Picasso.with(ctx).load(thumb_image).placeholder(R.drawable.default_avatar).into(userImageView);
          }
      }
      
    3. Move all the code from the onStart() method inside onCreate() method except this line of code:

      super.onStart();
      
    4. Make your firebaseRecyclerAdapter varaible global:

      private FirebaseRecyclerAdapter firebaseRecyclerAdapter;
      
    5. Remove FirebaseRecyclerAdapter from the onCreate() method.

    6. Add the following lines of code in the onStart() and onStop() methods.

      @Override
      protected void onStart() {
          super.onStart();
          firebaseRecyclerAdapter.startListening();
      }
      
      @Override
      protected void onStop() {
          super.onStop();
          if(firebaseRecyclerAdapter != null) {
              firebaseRecyclerAdapter.stopListening();
          }
      }
      
    7. If you are using authentication, please also don't forget to add this line of code inside onStart() method:

      firebaseAuth.addAuthStateListener(authStateListener);
      

    0 讨论(0)
提交回复
热议问题