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

Move to kotlin #12

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

DouiriAli
Copy link
Contributor

No description provided.

@DouiriAli DouiriAli changed the title Convert PreferencesHelper to kotlin Move to kotlin Jun 3, 2020
Copy link

@mosadialiou mosadialiou left a comment

Choose a reason for hiding this comment

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

Well done! LGTM but there are some minor changes.

app/build.gradle Outdated Show resolved Hide resolved
app/src/main/java/covid/trace/morocco/LocaleHelper.kt Outdated Show resolved Hide resolved
const val FRENCH = "fr"
const val ARABIC = "ar"

private var sharedPreferences: SharedPreferences? = null

Choose a reason for hiding this comment

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

a lateinit sharedPreferences should be more appropriate. don't you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sharedPreferences can be null if a class calls a method (for example the method setLocaleIfNeeded(@language language: String)) without initiating sharedPreferences via the method init(context: Context?)

Copy link

@mosadialiou mosadialiou Jun 5, 2020

Choose a reason for hiding this comment

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

OK I see BUT calling init is mandatory. It's a prerequisite to use LocaleHelper. As you can see init is called only once here https://github.com/Wiqaytna-app/wiqaytna_android/pull/12/files#diff-72d398151f1a0977873d51d832bb38f2R33

Choose a reason for hiding this comment

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

What do you think about my previous comment?!

const val ARABIC = "ar"

private var sharedPreferences: SharedPreferences? = null
var currentLocale: String? = null

Choose a reason for hiding this comment

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

non optional currentLocale here

Copy link
Contributor Author

@DouiriAli DouiriAli Jun 5, 2020

Choose a reason for hiding this comment

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

currentLocale can be null if a class does not call the method init(context: Context?), but it should be private

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.

2 participants