switched from declaring class to enclosing class to handle anonymous classes appropriately and added recursive class adapter resolution to account for any level of class nesting