Android leak pattern: subscriptions in views
Py ⚔

If I’m not wrong you could also solve the problem by using a WeakReference for your usernameView (inside the anonymous class).

Anyway as a good practice I would say that you should avoid anonymous classes as much as possible. You should try to use static inner classes specially if you are working with an activity context or views.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.