I am currently developing an app that has a function like a simple news feed which displays news etc. In it, i have a fragment which contains a Recyclerview populated by Firebase' ValueEventListener.
When a user clicks an item, it opens an Activity (Detail Activity) containing the additional details of the clicked Recyclerview item. The contents of the Activity is populated using Value Event Listener that listens to a specific location in the database(items in the recylcerview).
The problem is, sometimes when i delete an item in the recyclerview, an NPE will be triggered by the DetailActivty's ValueEventListener mainly due to binding items in some views.
My suspicion is that after i delete an item in the recyclerview, the ValueEventListener in the DetailActivity still listens to the item's firebase reference, hence causing NPE.
I could use a database reference if it's only fetching data, but i also want to listen to data changes that's why i used a ValueEventListener.
I'd like to know what seems to be the problem and possible fix in this question.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…