Based on the idea that you should not pass and Android view's or other pure Android components to ViewModel
, or have android imports there, consider the next use case:
From my Fragment
I want to launch some sort of image processing action and for that I need to initialize my object with the current xml view where I want to show the result. So I create it on the ``Fragment side with the view component and then pass that object over to ViewModel
.
My problems are:
I'm passing to
ViewModel
an object with already reference to an Android views.The logic in
ViewModel
creates aBitmap
and after processing it return that bitmap to the Fragment that observes it, as a result I have reference to some Android Bitmap libraries inside myViewModel
How to avoid referencing Android stuff in ViewModel
if I need the work to be done there?