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

First issue: Fixed errors/warnings in FailedUploadFragments.kt #6000

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

KYash03
Copy link

@KYash03 KYash03 commented Dec 6, 2024

Hey, this is my first PR here. I worked on #5996

Made a few changes:

  • Changed onCreateView from View? to View
  • Removed if (contributionsList != null) checks
  • Made lines shorter (<100)
  • Changed contributionsList, initAdapter, and initRecyclerView to private
  • Changed contributionsList from var to val since it's never reassigned
  • Removed unnecessary this
  • Replaced String.format with direct getString calls (only where formatting wasn't required!)
  • Used list.isEmpty() instead of list.size == 0
  • Removed the redundant setting of the adapter inside the else block in initRecyclerView

Would appreciate any sort of feedback. Thanks!

@nicolas-raoul
Copy link
Member

I am getting this crash when uploading a file, can you try?

kotlin.UninitializedPropertyAccessException: lateinit property pendingUploadsPresenter has not been initialized
at fr.free.nrw.commons.upload.FailedUploadsFragment.getPendingUploadsPresenter(FailedUploadsFragment.kt:42)
at fr.free.nrw.commons.upload.FailedUploadsFragment.onCreateView(FailedUploadsFragment.kt:66)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2963)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:518)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)

Thanks!

@neeldoshii
Copy link
Contributor

Hi @KYash03, thanks a lot for contributing.
When I tried to click on upload an image I faced this issue. Not sure whether this is related to your PR or not. It happened only on your pull, I will try to investigate if its on main or lead by something else on this PR. Probably not related to your PR I believe askUserToAllowLocationAccess(ContributionController.java:191) but still the crash is something I believe needs to be handled.

FATAL EXCEPTION: Thread-9
Process: fr.free.nrw.commons.beta, PID: 32423
java.lang.RuntimeException: Can't create handler inside thread Thread[Thread-9,5,main] that has not called Looper.prepare()
	at android.os.Handler.<init>(Handler.java:205)
	at android.os.Handler.<init>(Handler.java:118)
	at android.app.Dialog.<init>(Dialog.java:137)
	at android.app.AlertDialog.<init>(AlertDialog.java:1343)
	at android.app.AlertDialog$Builder.create(AlertDialog.java:1147)
	at fr.free.nrw.commons.utils.DialogUtil.createAndShowDialogSafely(DialogUtil.kt:184)
	at fr.free.nrw.commons.utils.DialogUtil.showAlertDialog(DialogUtil.kt:108)
	at fr.free.nrw.commons.contributions.ContributionController.askUserToAllowLocationAccess(ContributionController.java:191)
	at fr.free.nrw.commons.contributions.ContributionController.lambda$initiateCameraPick$0(ContributionController.java:80)
	at fr.free.nrw.commons.contributions.ContributionController.$r8$lambda$RpHdy36F_H32tm6qBgKaVMh9Tgg(Unknown Source:0)
	at fr.free.nrw.commons.contributions.ContributionController$$ExternalSyntheticLambda3.run(D8$$SyntheticClass:0)
	at java.lang.Thread.run(Thread.java:764)
ACRA caught a RuntimeException for fr.free.nrw.commons.beta

* functionality for the user to retry or cancel failed uploads.
*/
class FailedUploadsFragment :
CommonsDaggerSupportFragment(),
PendingUploadsContract.View,
FailedUploadsAdapter.Callback {
@Inject
lateinit var pendingUploadsPresenter: PendingUploadsPresenter
Copy link
Contributor

@neeldoshii neeldoshii Dec 6, 2024

Choose a reason for hiding this comment

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

Any particular reason in removing this? I don't see any lint/warnings over this.

@nicolas-raoul
Copy link
Member

@KYash03 Did you get a chance to read our comments? Feel free to fix only 1 or 2 errors at first. Thanks! :-)

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

Discussion above

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.

3 participants