-
-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unregister Receiver #652
Unregister Receiver #652
Conversation
@mhutti1 Could you please take a look into this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing the same things in the onPause
and onStop
? You should do it only once.
super.getActivity().unbindService(mConnection.downloadServiceInterface); | ||
mBound = false; | ||
} | ||
if (isReceiverRegistered){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add proper space before {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. just a question. The logic of unregistering should be done in onStop right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed it. Can you review it again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srv-twry take a look at it
@srv-twry I have changed the code and adjusted the spaces. can you take a look into it? |
@hjoshi123 Yes, looking at it again but please don't ping multiple times for it. You did it in the review comments as well. |
@@ -45,6 +46,7 @@ | |||
import javax.inject.Inject; | |||
|
|||
import static org.kiwix.kiwixmobile.utils.StyleUtils.dialogStyle; | |||
import static org.kiwix.kiwixmobile.zim_manager.library_view.LibraryFragment.DownloadServiceConnection.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we need these imports. You have just removed a method. Why add these ? May be you were trying out things but make sure to optimize imports before sending the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srv-twry I wanted to ask about that. Could we like write a gradle script or something so that we don't need to remove those manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android studio has a shortcut ctrl + alt + o
. I haven't seen anyone writing the gradle script for it.
public void onDetach() { | ||
if (mBound && super.getActivity() != null) { | ||
super.getActivity().unbindService(mConnection.downloadServiceInterface); | ||
mBound = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onDetach
gets called everytime the fragment is recreated inside the Activity. If you're unbinding the service in the onDetach
then you don't need to do it onStop
i.e. it should only be in one method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh Yeah. Sorry for that mistake. Lemme correct it.
@srv-twry Give it a look again. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, unregistering receiver in the onStop
should solve the problem
@hjoshi123 Please update the branch. |
@kelson42 Can you give a look into it and merge this? |
@mhutti1 Can you please review that PR as downloading related crash are massive and quite annoying to leave in 2.4? |
Fixes #600
Changes: Added unregisterReceiver() in LibraryFragment to stop the crash.