The choice of using a named or an anonymous interface implementation depends on several things:
- Are you planning to reuse some of the logic in the implementation? - If the answer is "yes", use the first approach; otherwise, use the second approach.
- Do you need to implement complex logic with lots of external interactions? - If the answer is "yes", use the first approach; otherwise, use the second approach.
- Does your interface have multiple methods, some of which may meaningfully do nothing? - If the answer is "yes", use the first approach, or make a "default" class with all implementations doing nothing; otherwise, use the second approach.
In the end, the biggest difference between these two approaches is mostly non-technical: it has to do with readability of your resultant code. After all, anonymous classes are a little more than "syntactic sugar" - you can perfectly implement your system with only named classes. If you think that a named implementation reads better, use the first approach; if you think that an anonymous one works better, use the second approach.