Architecture-components-samples: question about AutoClearedValue

Created on 19 Sep 2017  路  4Comments  路  Source: android/architecture-components-samples

in all documents and articles says don't need to set null for class field of activity or fragment when destroyed because GC cleared them automatically for release memory, but this examples google use a simple helper (AutoClearedValue) for release memory of DataBinding and adapter fields for fragment, i want to know it is necessary ?

Most helpful comment

@DJafari @JakeWoki Look at this workflow, you have Activity and Fragment A and then you add another Fragment B with replace using addToBackStack() metod when you are doing transaction to replace Fragment A. For Fragment A method onFragmentViewDestroyed will be called because it's not visible anymore but it will not be destroyed.

All 4 comments

I want to know too.BasicSample don't used AutoClearedValue

@JakeWoki it is only exist in github example

@DJafari @JakeWoki Look at this workflow, you have Activity and Fragment A and then you add another Fragment B with replace using addToBackStack() metod when you are doing transaction to replace Fragment A. For Fragment A method onFragmentViewDestroyed will be called because it's not visible anymore but it will not be destroyed.

Thanks, @goransipic
I wondered for a while why!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prabinshrestha picture prabinshrestha  路  3Comments

juanpmarin picture juanpmarin  路  4Comments

amunozg picture amunozg  路  3Comments

prabinshrestha picture prabinshrestha  路  5Comments

PascalTang picture PascalTang  路  3Comments