I am trying to organize my code and move repetitive functions to a single class. This line of code works fine inside a class that extends activity:
getWindow
You shall not keep references around as suggested in the accepted answer. This works, but may cause memory leaks.
Use this instead from your view:
((Activity) getContext()).getWindow()...
You have a managed reference to your activity in your view, which you can retrieve using getContext(). Cast it to Activity and use any methods from the activity, such as getWindow().