Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Converted classes to Kotlin #2405

Merged
merged 2 commits into from
Apr 3, 2018

Conversation

sriramr98
Copy link
Contributor

First steps for issues #2357

Changes: Converted classes to Kotlin.

@open-event-bot
Copy link

Hi @sriramr98!

It looks like one or more of your builds have failed.
I've added the relevant info below to save you some time.

@sriramr98
Copy link
Contributor Author

@iamareebjamal is JCenter down again?

@@ -85,15 +85,15 @@ object Utils {
if (isBaseUrlEmpty) {
swipeRefreshLayout.isEnabled = false
} else {
StrategyRegistry.instance.eventBusStrategy!!.eventBus.register(`object`)
StrategyRegistry.instance.eventBusStrategy?.getEventBus()?.register(`object`)
Copy link
Member

Choose a reason for hiding this comment

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

Why not ?.eventBus

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I could not set a default getter implementation because the getter referenced the eventBus and that turned into infinite recursion. So I had to create an explicit getEventBus method

Copy link
Member

Choose a reason for hiding this comment

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

Why would it recur? That doesn't make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, accessing the property from inside the getter calls the getter again.

Copy link
Member

@iamareebjamal iamareebjamal Mar 31, 2018

Choose a reason for hiding this comment

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

Why are you accessing it inside getter, of course it will recur that way

It's like saying

int getAge() {
  return getAge();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, android studio showed the error. But I found a solution using the 'field' naming.

Copy link
Member

Choose a reason for hiding this comment

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

Why are you using that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Becuase we need to do this
if (field == null) {
field = Bus()
}
return field

Copy link
Member

Choose a reason for hiding this comment

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

use lazy delegator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need the lazy approach here. We can just use the field attribute.


StrategyRegistry.instance
.eventBusStrategy!!
.postEventOnUIThread(BookmarkChangedEvent())
Copy link
Member

Choose a reason for hiding this comment

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

SYIF

@iamareebjamal iamareebjamal merged commit 2d259b7 into fossasia:development Apr 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants