0

I'm trying to filter the content from FirebaseDatabase based on time and for that I have created a method and am calling it from the FastAdapter's bindView() of the RecyclerView.

I'm subtracting currentTime from the startTime using this code:

holder.now = System.currentTimeMillis() / 1000;
holder.startTimeDateInEpochLong = Long.parseLong(holder.startDateTimeInEpoch.getText().toString());
holder.diff = holder.startTimeDateInEpochLong - holder.now;
Log.d("log1", String.valueOf(holder.diff));

and then using the holder.diff to do the logic in the method of the MainActivity and calling that method from the bindView() like this:

MainActivity.filterButton.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                if(holder.mContext instanceof MainActivity){
                    ((MainActivity)holder.mContext).filterRequests(holder.diff);
                    Log.d("log2", String.valueOf(holder.diff));
                }
                return true;
            }
        });

The problem is that log1 shows all the values of holder.diff but log2 shows only the last fetched value and do the logic using it only.

How can I make sure that .filterRequests(holder.diff) do the logic using all the values of holder.diff?

Please let me know.

Hammad Nasir
  • 2,889
  • 7
  • 52
  • 133

1 Answers1

0

Try using TimeStamp data type rather than long. Hope it will work.

rohit
  • 51
  • 3