title: How to get int value from one method to another
body: <p>I need to carry my int value from one method to another, but I didnt find any solution. One method counts number of objects and the number needs to be "delivered" to another and check, if the count equals to something.</p>
  
  <p>Do you have any idea, how to do it?</p>
  
  <p>Check my codes below:</p>
  
  <pre><code>@Override
  protected void onPostExecute(Void result) {
      ParseQuery&lt;Animal&gt; query = ParseQuery.getQuery(Animal.class);
      query.countInBackground(callcount = new CountCallback(){
          public void done(int count, ParseException e) {
              if (e == null) {
                  Log.v("count is" + count, "count is");                           
                  //I need to export int count from "done" method to another                
              } else {
              }
          }
      }); 
  }
  </code></pre>
  
  <p>And the secont method, which has to recieve that value and use it:</p>
  
  <pre><code>@Override
  public void onScrollStateChanged(AbsListView view, int scrollState) {
      //i need to set int count from method above here
      int threshold = 1;
      int counter = mListView.getCount();
  
      if (scrollState == SCROLL_STATE_IDLE) {
  
      if (mListView.getLastVisiblePosition() &gt;= counter - threshold) {
          updateData();                   
      }
  }
  </code></pre>
  
  <p>Whole code:</p>
  
  <pre><code>public class Fragment1 extends Fragment {
      static ListView mListView;
      static AnimalAdapter mAdapter;
      static ProgressBar mProgressBar;
      static EditText mEditText;
      static LayoutInflater inflater;
      CountCallback callcount;
      int g_count = 0;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          final View rootView = inflater.inflate(R.layout.animalsfrag, container, false);
          mListView = (ListView)rootView.findViewById(R.id.animal_list);
  
          View header = getActivity().getLayoutInflater().inflate(R.layout.header, null);
  
          header.setPadding(2, 8, 4, 2);
          mListView.setVisibility(View.INVISIBLE);
          mListView.requestFocus();
          mListView.addHeaderView(header); 
  
          View footie = getActivity().getLayoutInflater().inflate(R.layout.footer, null);
          mListView.addFooterView(footie);
          footie.setVisibility(View.INVISIBLE);
  
  
          mProgressBar = (ProgressBar) rootView.findViewById (R.id.loading_animals);
          mProgressBar.setVisibility(View.VISIBLE);
  
          RemoteDataTask task = new RemoteDataTask();
          task.execute();
  
  
  
  
          return rootView;
      }
  
  
  
      public void updateData() {
           mListView = (ListView)getView().findViewById(R.id.animal_list);     
     final ParseQuery&lt;Animal&gt; query = ParseQuery.getQuery(Animal.class);
      query.setCachePolicy(CachePolicy.NETWORK_ONLY);
      query.orderByAscending("animal");
      query.setLimit(mListView.getCount() + 5);
  
      Log.v("updateData", "uploading data from Parse.com");
      query.findInBackground(new FindCallback&lt;Animal&gt;() {
  
          @Override
            public void done(List&lt;Animal&gt; animals, ParseException error) {
  
                if(animals != null){
                  mAdapter.clear();
                  mProgressBar = (ProgressBar) getView().findViewById (R.id.loading_animals);
                 mProgressBar.setVisibility(View.INVISIBLE);
               RelativeLayout footie = (RelativeLayout) getView().findViewById(R.id.footerview);  
              footie.setVisibility(View.VISIBLE);
  
                mAdapter.clear();
              for (int i = 0; i &lt; animals.size(); i++) {
  
                        mAdapter.add(animals.get(i));
  
                      }  
  
                }  
              }
           }); }
  
  
  
  
  
  
       private class RemoteDataTask extends AsyncTask&lt;Void, Void, Void&gt; {
  
  
  
           @Override
              protected void onPreExecute() {
                  super.onPreExecute();  }
  
           @Override
              protected Void doInBackground(Void... params) {
  
                  return null;
  
  
  
           }
  
  
           @Override
              protected void onPostExecute(Void result) {
               ParseQuery&lt;Animal&gt; query = ParseQuery.getQuery(Animal.class);
               query.countInBackground(callcount = new CountCallback(){
                   public void done(int count, ParseException e) {
                          if (e == null) {
                              Log.v("count is" + count, "count is");
                           if (mListView.getCount() == count) {
                               Log.v("all loaded", "executed");
                               g_count=count;
                           }
                          } else {
                            // The request failed
                          }
                        }
                      }); 
  
                  Log.v("onpostexecute", "executing");
                 mListView = (ListView) getView().findViewById(R.id.animal_list);
                 if(mListView.getCount() == 0){
                      updateData();
  
                  }
  
  
                 mEditText = (EditText) getView().findViewById(R.id.search_animal);
  
                 mAdapter = new AnimalAdapter(getActivity(), new ArrayList&lt;Animal&gt;());
  
                 mListView.setVisibility(View.VISIBLE);
                 mListView.setTextFilterEnabled(true);
                 mListView.setAdapter(mAdapter);
  
  
  
  
                 mListView.setOnScrollListener(new OnScrollListener() {
  
                      @Override
                      public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                              int totalItemCount) {
                      }
  
  
                      @Override
                      public void onScrollStateChanged(AbsListView view,
                              int scrollState) {
  
                          int threshold = 1;
                          int counter = mListView.getCount();
  
                          if (scrollState == SCROLL_STATE_IDLE) {
  
                              if (mListView.getLastVisiblePosition() &gt;= counter
                                      - threshold){
  
                                  updateData();
  
                                  Log.v("count", "count is" + g_count);
  
                                  }
                              }
  
  
                          if (SCROLL_STATE_TOUCH_SCROLL == scrollState) {
                              View currentFocus = getActivity().getCurrentFocus();
                              if(currentFocus != null) {
                                  currentFocus.clearFocus();
                              }
                          }
  
  
  
                      }
  
                  });
  
  
                  mEditText.addTextChangedListener(new TextWatcher(){
  
                      @Override
                      public void afterTextChanged(Editable s) {}
  
                      @Override
                      public void beforeTextChanged(CharSequence s,
                              int start, int count, int after) {}
  
                      @Override
                      public void onTextChanged(CharSequence s, int start,
                              int before, int count) {
  
                          System.out.println("Text ["+s+"]");
                          mAdapter.getFilter().filter(s.toString());  
                          }
                  });
  
                 }
  
              }
           }
  </code></pre>
  
  <p>I'd be glad for any advice.
  Thanks in advance.</p>