Originally I want to create a library to easily change locale without having to recreate activity for changes to take effect.
For that purpose I want to store the resId of setText(int resId) method in a variable to re-set text by this ID from another locale.
The problem is that setText(int resId) is final in a TextVIew.
So my question is if there is a way to override final method (i think no), or add some hook so I'll be able to get this resId whenever this method will be called?
Let me also add what I've tried:
First I thought about using an InvocationHandler, so I could create an instance of aTextViewas a field of my class, and pass all the calls to it exceptsetText. But Unfortunately I can't return anything in the constructor.View
Then I've thought about implementing a Decorator Pattern by creating a class, which extends, and has all the methods, which aTextViewhas, and creating an instance of aTextView` as a field of my class, and same way passing all methods calls to it, but it should not work for 2 reasons:
- methods, which require an instance of a TextViewwon't work, as my class won't extend a TextView
- TextView's implementation is 11969 lines long, and it would take hell of a time to copy all methods.
 
Aucun commentaire:
Enregistrer un commentaire