title: Getting Record from Firebase with AsyncTask?
body: <p>I would like to get a object I have stored on fire-base with async task. i am passing an object array-list that will fill the ui with the adapter, array-list of string, books i want to retrieve, and an adapter that i would like to update the ui with, but the Im stuck with async within async and Im not sure what to do. since the firebase calls of retrieving the data is done after asynctask post-execute is done.</p>
  
  <p>i would like to call this with a </p>
  
  <pre><code>new FetchBookWithList(bookList,bookIdList,adapter).execute()
  </code></pre>
  
  <p>some of my code:</p>
  
  <pre><code>protected ArrayList&lt;Book&gt; doInBackground(String... strings) {
          try{
              DatabaseReference bookReference = FirebaseDatabase.getInstance().getReference().child("books");
              bookReference.addValueEventListener(new ValueEventListener() {
                  @Override
                  public void onDataChange(DataSnapshot dataSnapshot) {
                      if(dataSnapshot.exists()) {
                          try {
                              for (DataSnapshot books : dataSnapshot.getChildren()) {
                                  if(bookListID.contains(books.child("bookID").getValue())) {
                                      Book book = books.getValue(Book.class);
                                      bookList.add(book);
                                  }
                              }
                          } catch (Exception e){
                              e.printStackTrace();
                          }
                      }
                  }
                  @Override
                  public void onCancelled(@NonNull DatabaseError databaseError) {
                      Log.w("testing","Error: ", databaseError.toException());
                  }
              });
          } catch (Exception e) {
              e.printStackTrace();
          }
          return bookList;
      }
  @Override
      protected void onPostExecute(ArrayList&lt;Book&gt; s){
          super.onPostExecute(s);
          try {
              if(this.bookAdapter != null) {
                  this.bookAdapter.notifyDataSetChanged();
              }
          } catch (Exception e){
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>my full for class code: <a href="https://www.codepile.net/pile/YKYMXMK7" rel="nofollow noreferrer">https://www.codepile.net/pile/YKYMXMK7</a></p>