Проблема отображения Recycler View

столкнулся с проблемой при работе с Recycler View,в логах пишет W/RecyclerView: No adapter attached; skipping layout

Post.java

    public class Post {
    private String title;
    private String username;
    private String postImage;
    private String tag;
    private String userId;
    private String userPick;
    private String description;
    private String location;
    private String wallet;
    private Object time_stamp;


    private String postKey;



    public Post(String title, String username, String postImage, String tag, String userId, String userPick, String description, String location, String wallet) {
        this.username = username;
        this.title = title;
        this.tag = tag;
        this.userId = userId;
        this.userPick = userPick;
        this.description = description;
        this.wallet = wallet;
        this.postImage = postImage;
        this.location = location;



    }

    public Post() {
    }


    public String getPostKey() {
        return postKey;
    }

    public void setPostKey(String postKey) {
        this.postKey = postKey;
    }

    public String getTitle() {
        return title;
    }

    public String getUsername() {
        return username;
    }

    public String getPostImage() {
        return postImage;
    }

    public String getTag() {
        return tag;
    }

    public String getUserId() {
        return userId;
    }

    public String getUserPick() {
        return userPick;
    }



    public String getDescription() {
        return description;
    }

    public String getLocation() {
        return location;
    }

    public String getWallet() {
        return wallet;
    }



    public void setTitle(String title) {
        this.title = title;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPostImage(String postImage) {
        this.postImage = postImage;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setUserPick(String userPick) {
        this.userPick = userPick;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public void setWallet(String wallet) {
        this.wallet = wallet;
    }

}

PostAdapter.java

    public  class  PostAdapter extends RecyclerView.Adapter<PostAdapter.MyViewHolder>{


    Context mContext;
    List<Post> mData;
    public PostAdapter(Context mContext, List<Post> mData) {
        this.mContext = mContext;
        this.mData = mData;
        notifyDataSetChanged();
    }

    @NonNull
    @NotNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
        View row = LayoutInflater.from(mContext).inflate(R.layout.row_signle_post,parent,true);

        return new MyViewHolder(row);
    }

    @Override
    public void onBindViewHolder(@NonNull @NotNull MyViewHolder holder, int position) {
        holder.tvTitle.setText(mData.get(position).getTitle());
        holder.tvTitle.setText(mData.get(position).getUsername());
        Glide.with(mContext).load(mData.get(position).getUserPick()).into(holder.imgUserPick);
        Glide.with(mContext).load(mData.get(position).getPostImage()).into(holder.imgPost);
;
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }


    public class MyViewHolder extends RecyclerView.ViewHolder {

        TextView tvTitle;
        TextView tvName;
        ImageView imgPost;
        TextView tag;
        CircleImageView imgUserPick;


        public MyViewHolder(@NonNull @NotNull View itemView) {
            super(itemView);


            tvTitle = itemView.findViewById(R.id.title);
            tvName = itemView.findViewById(R.id.username);
            tag = itemView.findViewById(R.id.tag);
            imgPost = itemView.findViewById(R.id.imgPost);
            imgUserPick = itemView.findViewById(R.id.userPick);





        }
    }
}

Homeactivity.java

     public class HomeActivity extends AppCompatActivity {
      FirebaseAuth mAuth;
      private FloatingActionButton fab;
      private MaterialCardView PostCard;
      private MaterialToolbar topAppBar;
      private NavigationView nav_view;
      private LottieAnimationView serach;
      private TextView userName, userLogin;
      private RecyclerView PostRV;
      private DrawerLayout drawerLayout;
      Context context;
      PostAdapter adapter;
      private ImageView userPick;
      DatabaseReference db;
      FirebaseDatabase firebaseDatabase;
      FirebaseStorage fs;
      StorageReference sr;
      FirebaseUser currentUser;
      List<Post> postList;


      @Override
      protected void onStart() {
          super.onStart();
          db.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull @NotNull DataSnapshot snapshot) {
                  postList = new ArrayList<>();
                  for (DataSnapshot postsnap : snapshot.getChildren()) {
                      Post post = postsnap.getValue(Post.class);
                      postList.add(post);
                  }

                  adapter = new PostAdapter(context,postList);
                  PostRV.setAdapter(adapter);
              }


              @Override
              public void onCancelled(@NonNull @NotNull DatabaseError error) {

              }
          });
      }



      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

          setContentView(R.layout.activity_home);


          PostRV = (RecyclerView)

                  findViewById(R.id.PostRV);

          nav_view = (NavigationView)

                  findViewById(R.id.nav_view);

          drawerLayout = (DrawerLayout)

                  findViewById(R.id.drawerLayout);



          topAppBar = (MaterialToolbar)

                  findViewById(R.id.topAppBar);


          PostRV.setLayoutManager(new

                  LinearLayoutManager(HomeActivity.this));
          firebaseDatabase = FirebaseDatabase.getInstance();
          db = firebaseDatabase.getReference("Posts");







          topAppBar.setNavigationOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  drawerLayout.openDrawer(GravityCompat.START);
              }
          });


          nav_view.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
              @Override
              public boolean onNavigationItemSelected(@NonNull @NotNull MenuItem item) {
                  switch (item.getItemId()){
                      case R.id.settings:
                          Intent intent = new Intent(HomeActivity.this, SettingsActivity.class);
                          startActivity(intent);
                          finish();

                      case R.id.faq:
                          Intent intent1 = new Intent(HomeActivity.this, ActivityFaq.class);
                          startActivity(intent1);
                          finish();
                  }
                  return false;
              }
          });


          mAuth = FirebaseAuth.getInstance();
          currentUser = mAuth.getCurrentUser();


          FirebaseStorage fr = FirebaseStorage.getInstance();


          mAuth = FirebaseAuth.getInstance();
          currentUser = mAuth.getCurrentUser();



      }
  }

Ответы (0 шт):