There are questions with a similar title, but them all about Context that you get in constructor.
There are RecyclerView with items and some other v
You should decouple view (mPlayPauseButton) from that functionality to avoid leaks. To do this, you can implement a listener pattern. The easier way in that code could be passing a "listener" object as a parameter instead directly the view reference...
Do not put widgets in static
fields.
Options include:
Delete this class. Move all of this logic into the activity (or fragment), where you have direct access to the widgets.
Use an event bus (LocalBroadcastManager
, greenrobot's EventBus, etc.). Have your code here post messages on the bus when the state changes. Have your UI (activity or fragment) subscribe for messages on the bus and update the widgets.
Have your activity/fragment hold an instance of CommentsAudioPlayer
, and make the fields in CommentsAudioPlayer
non-static
.
Of the three, the first option would be simpler, cleaner, less memory-intensive, and faster to execute.