Hi,
Previously I was using unbind() method but now in v8 of ButterKnife, there's no such method and just the binding method returns an Unbinder which will help with that. But the question, what is the correct way to do that? Is it recommended in fragments?
Create a field in your fragment as
Unbinder unbinder;
in onCreateView you call
unbinder = Butterknife.bind(this, root);
and in onDestroyView you need to call
unbinder.unbind();
thats it you're done.
@lkishor Thanks man. Is it recommended to unbind?
Yes it is, It will set your bindings to null, freeing up memory...take a look at
BINDING RESET at
http://jakewharton.github.io/butterknife/
@lkishor Thanks so much man.
Sorry to ask this, but why the change from the simple Butterknife.unbind()?
Warm regards,
_A user who just upgraded from previous version_
So listeners can be cleared
On Thu, Sep 1, 2016 at 11:47 PM Aiman B [email protected] wrote:
Sorry to ask this, but why the change from the simple Butterknife.unbind()
?Warm regards,
_A user who just upgraded from previous version_—
You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub
https://github.com/JakeWharton/butterknife/issues/585#issuecomment-244276337,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEVF99TB6Xo-aw14UVCnx8AAcGWtZks5ql5xNgaJpZM4IjUP_
.
Is it really necessary that Butterknife throws an exception when the target object is null while unbinding (throw new IllegalStateException("Bindings already cleared."))? Could it not just do nothing? With the exception thrown I have to catch it always preventively and cannot do anything about it anyway.
I agree with @semaphore3000 . Is there a better way to handle this @JakeWharton
Most helpful comment
Create a field in your fragment as
Unbinder unbinder;in onCreateView you call
unbinder = Butterknife.bind(this, root);and in onDestroyView you need to call
unbinder.unbind();thats it you're done.