I have a TextureView which displays a live video from a third-party SDK. I am fetching the bitmap from the TextureView using the getBitmap() method at regular intervals. I want to pass this Bitmap to a Mediator class which forwards it to multiple different classes, say Operation1.kt, Operation2.kt that have their own functionalities and apply their own set of operations to this Bitmap.
Hence, I was thinking of defining a flow in my Mediator class and my activity class would use and update it to emit the Bitmap. This flow would be collected in the same Mediator class and then pass it ahead to the other classes who need this Bitmap.
I know I can pass the object of the TextureView to my Mediator class and then fetch Bitmaps in the Mediator Class itself or make my TextureView static, but I am aware that both these approaches are bad as they might cause memory leaks.
The other approach I can go with is using EventBus, but I want to use it as a last option.
So, is it a good practice to emit a flow from an activity class and collect it in a non-activity class? Are there any disadvantages/side-effects of doing so? I am curious to know this because I have not come across any example/tutorial which has done this.