Skip to content
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

Merged
merged 2 commits into from
Apr 21, 2018
Merged

Unregister Receiver #652

merged 2 commits into from
Apr 21, 2018

Conversation

hjoshi123
Copy link
Contributor

Fixes #600

Changes: Added unregisterReceiver() in LibraryFragment to stop the crash.

@hjoshi123
Copy link
Contributor Author

@mhutti1 Could you please take a look into this?

@hjoshi123 hjoshi123 requested a review from mhutti1 March 22, 2018 11:58
Copy link
Contributor

@dr0pdb dr0pdb left a 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){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add proper space before {

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

@hjoshi123
Copy link
Contributor Author

@srv-twry I have changed the code and adjusted the spaces. can you take a look into it?

@dr0pdb
Copy link
Contributor

dr0pdb commented Mar 23, 2018

@hjoshi123 Yes, looking at it again but please don't ping multiple times for it. You did it in the review comments as well.
I know you want it done quickly but give reviewers some time 😄

@@ -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.*;
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@hjoshi123
Copy link
Contributor Author

@srv-twry Give it a look again. :)

dr0pdb
dr0pdb previously approved these changes Mar 24, 2018
Copy link
Contributor

@dr0pdb dr0pdb left a 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

@dr0pdb dr0pdb requested a review from rashiq March 24, 2018 09:43
@dr0pdb
Copy link
Contributor

dr0pdb commented Mar 24, 2018

@hjoshi123 Please update the branch.

@hjoshi123
Copy link
Contributor Author

@rashiq @kelson42 Can you merge this PR?

@hjoshi123 hjoshi123 requested a review from kelson42 April 2, 2018 13:05
@hjoshi123
Copy link
Contributor Author

@kelson42 Can you give a look into it and merge this?

@kelson42
Copy link
Collaborator

@mhutti1 Can you please review that PR as downloading related crash are massive and quite annoying to leave in 2.4?

@kelson42 kelson42 added this to the 2.4 milestone Apr 19, 2018
@mhutti1 mhutti1 merged commit 0b3887e into kiwix:master Apr 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants