title: Why repository doesn't notify viewmodel about updated value of variable in spite of implementing LiveData?
body: <p>I am fetching data from Cloud Firestore and displaying in a recyclerview using MVVM architecture along with LiveData. When I observe the changes in viewmodel and notify the adapter about the dataset change, the changed data isn't updating in the recyclerview.</p>
  
  <p>Do you see anything wrong in the code?</p>
  
  <p>UPDATE: I have updated code as suggested my the first answer. But still no success. I observed that even after the repository fetches the data from firestore, it doesn't updates the viewmodel about it. I have added the repository class too. Do you see any problem there?</p>
  
  <p>HomeActivity.java</p>
  
  <pre><code>public class HomeActivity extends AppCompatActivity {
  
      RecyclerView recyclerView;
      StandardPlansAdapter adapter;
      HomeActivityViewModel viewModel;
  
      @Override
      protected void onCreate(final Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          recyclerView = findViewById(R.id.recyclerViewHome);
  
          viewModel = new ViewModelProvider(this).get(HomeActivityViewModel.class);
          adapter = new StandardPlansAdapter(viewModel.getStandardPlans().getValue());
          recyclerView.setHasFixedSize(true);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
          recyclerView.setAdapter(adapter);
  
          viewModel.getStandardPlans().observe(this, plans -&gt; {
              adapter.setStandardPlans(plans);
              adapter.notifyDataSetChanged();
          });
      }
  }
  </code></pre>
  
  <p>StandardPlansAdapter.java</p>
  
  <pre><code>public class StandardPlansAdapter extends RecyclerView.Adapter&lt;StandardPlansAdapter.StandardPlansViewHolder&gt; {
  
      private ArrayList&lt;Plan&gt; standardPlans;
  
      public StandardPlansAdapter(ArrayList&lt;Plan&gt; standardPlans) {
          this.standardPlans = standardPlans;
      }
  
      @NonNull
      @Override
      public StandardPlansViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.home_rv_layout, parent, false);
          return new StandardPlansViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(@NonNull StandardPlansViewHolder holder, int position) {
          Plan plan = standardPlans.get(position);
          holder.textView.setText(plan.getName());
      }
  
      @Override
      public int getItemCount() {
          return standardPlans.size();
      }
  
      class StandardPlansViewHolder extends RecyclerView.ViewHolder {
  
          TextView textView;
  
          public StandardPlansViewHolder(@NonNull View itemView) {
              super(itemView);
              textView = itemView.findViewById(R.id.tvPlanName);
          }
      }
  
      public void setStandardPlans(ArrayList&lt;Plan&gt; standardPlans) {
          this.standardPlans = standardPlans;
      }
  
  }
  </code></pre>
  
  <p>HomeActivityViewModel.java</p>
  
  <pre><code>public class HomeActivityViewModel extends ViewModel {
  
      private StandardPlansRepository repository;
      private MutableLiveData&lt;ArrayList&lt;Plan&gt;&gt; standardPlans;
  
      public HomeActivityViewModel() {
          super();
          repository = StandardPlansRepository.getInstance();
          standardPlans = repository.getStandardPlans();
      }
  
      public LiveData&lt;ArrayList&lt;Plan&gt;&gt; getStandardPlans() {
          return standardPlans;
      }
  }
  </code></pre>
  
  <p>StandardPlansRepository.java</p>
  
  <pre><code>public class StandardPlansRepository {
  
      private static StandardPlansRepository instance;
      private ArrayList&lt;Plan&gt; standardPlans = new ArrayList&lt;&gt;();
  
      public static StandardPlansRepository getInstance() {
          if (instance == null) {
              instance = new StandardPlansRepository();
          }
          return instance;
      }
  
      public MutableLiveData&lt;ArrayList&lt;Plan&gt;&gt; getStandardPlans() {
          setStandardPlans();
          MutableLiveData&lt;ArrayList&lt;Plan&gt;&gt; plans = new MutableLiveData&lt;&gt;();
          plans.setValue(standardPlans);
          return plans;
      }
  
      private void setStandardPlans() {
          documentReference.get().addOnSuccessListener(documentSnapshot -&gt; {
              if (documentSnapshot.exists()) {
                  StandardPlans plans = documentSnapshot.toObject(StandardPlans.class);
                  if (plans != null) {
                      standardPlans = plans.getStandard_plans();
                  }
              } else {
                  Log.e("rahul", "Document doesn't exist");
              }
          }).addOnFailureListener(e -&gt; {
              Log.e("rahul", e.getMessage());
              e.printStackTrace();
          });
      }
  }
  </code></pre>