Refactored some duplicated code in GdxView.