As suggested in this Stackoverflow Link by @Alex Mamo,
To check if the data is from cache or from Firestore servers, you can use the following line of code:
String source = querySnapshot.getMetadata().isFromCache() ? "Local Cache" : "Firebase >Server";
Also have a look at this Stackoverflow Link by @Frank Van Puffelen, To detect if the results came from the local cache vs which came straight from the server by checking the metadata.
Also take a look at this Document and Link which might be helpful.