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

Support another Application() and Activity() #44

Closed
julienherrero opened this issue Dec 20, 2021 · 4 comments
Closed

Support another Application() and Activity() #44

julienherrero opened this issue Dec 20, 2021 · 4 comments

Comments

@julienherrero
Copy link
Contributor

Hi @zsmb13,

After being "stucked" with Dialogs and BottomSheets, I'm stucked with another problem today : deal with other libraries that already overrides Application and Activity.

The lib I want to integrate is https://github.com/akexorcist/Localization, which implement its own LocalizationApplication and LocalizationActivity.

I suppose it's out of the RainbowCake's scope, but maybe if we cannot integrate it completely we can at least expose modules rainbow-cake-core-localization & rainbow-cake-dagger-localization, as an alternative ? And of course make it for other libraries if needed.
You can see my commit here with the current modules, just take it as Proof of concept for modules described above.

If you're not interested, is it ok to you if I publish my fork to Jitpack ?

Open to discuss with pleasure,
Thanks!

@zsmb13
Copy link
Member

zsmb13 commented Dec 20, 2021

This kind of conflict between base classes required by different libraries is definitely annoying. Unfortunately, I haven't found a nice way of removing the base class requirement from RainbowCake.

However, the Localization library you've linked actually allows you to avoid subclassing, by calling into its LocalizationApplicationDelegate and LocalizationActivityDelegate classes manually, as described in their README. That should work insice a RainbowCakeApplication or RainbowCakeActivity. You can also create your own base class subclassing the RainbowCake classes that include those Localization integrations if needed.

@julienherrero
Copy link
Contributor Author

julienherrero commented Dec 20, 2021

Using delegates was my first idea, but I encountered some errors when I set a new language (activity is recreated) :

Caused by: java.lang.IllegalStateException: The Dagger based getViewModelFromFactory function requires an Application that inherits from RainbowCakeApplication
at com.tabesto.kiosk.ui.start.StartFragment.provideViewModel(StartFragment.kt:289)
at com.tabesto.kiosk.ui.start.StartFragment.provideViewModel(StartFragment.kt:51)

I thought maybe by overriding baseApplicationContext (even with a delegate), my Application is not recognized anymore as a RainbowCakeApplication.
But maybe my mistake is elsewhere, I continue my investigations !

@julienherrero
Copy link
Contributor Author

I confirm : it seems not to work with Localization Delegate methods.
But it's working with my fork, I tested with local .aar files.

@julienherrero
Copy link
Contributor Author

Ok my bad, after some hours I figured out : Delegates are OK, I just forgot to override one method I think...

Thanks for your time, you helped me to not drop this delegate clue.
I close the issue, and I hope not to have to integrate a lib with a base classe (without delegate) in the future !

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

No branches or pull requests

2 participants