RadioDroid icon indicating copy to clipboard operation
RadioDroid copied to clipboard

WIP: RFC: Some thoughts on the approach

Open andrewshadura opened this issue 5 years ago • 4 comments

As I mentioned in #901, I’m attempting to gradually work on the conversion from Java to Kotlin, in a bottom-to-top fashion.

My first attempt was station.live.ShoutcastInfo/station.live.StreamLiveInfo, but it turned out @Parcelize is currently broken in Kotlin, so those classes aren’t worth porting, since it’s @Parcelize that would reduce the amount of boilerplate the most.

So I decided to try converting other bits. station.live.metadata.* was mostly easy, but e.g. service.PlayerServiceUtil is tricky. I don’t like flipping multiple nullables as the Java code does, so I attempted to bring a pattern I learnt from Rust, so I’ve put two parts of the state into an Rust-enum-like type.

Please let me know what you think about it.

P.S. I have not yet tested this.

cc @werman

andrewshadura avatar Oct 15 '20 16:10 andrewshadura

Regarding @Parcelize, I think we don't need to use AIDL; it only complicates things and adds indirection. It's just that no one got to remove it.

For our case (service in the same process as application) Android documentation recommends extending IBinder interface and use it directly https://developer.android.com/guide/components/bound-services#Creating. This should be much simpler. And most of PlayerServiceUtil would be gone.

werman avatar Oct 15 '20 17:10 werman

Right, that part is well outside of my Android knowledge at the moment. I guess it will take some time for me to learn about it :slightly_smiling_face:

andrewshadura avatar Oct 15 '20 17:10 andrewshadura

However, I’m still interested to hear about the pattern I used.

andrewshadura avatar Oct 15 '20 17:10 andrewshadura

I don’t like flipping multiple nullables as the Java code does, so I attempted to bring a pattern I learnt from Rust, so I’ve put two parts of the state into an Rust-enum-like type.

I agree here with you and it is more safe.

werman avatar Oct 15 '20 19:10 werman

in WIP too long, closing

segler-alex avatar Oct 16 '23 11:10 segler-alex