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

code-cleanup #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LeventYADIRGA
Copy link

  1. ViewSwitcher Orientation Feature:
    Change: Removed orientation property from ViewSwitcher.
    Reason: This property was unused and caused confusion, so it was removed to simplify the code.

  2. showSnackbar Function:
    Change: Changed the access level of showSnackbar from internal to protected.
    Reason: The function was only accessible to classes within the same module when it was internal. However, this function can only be used by subclasses of the SdkFragment class. Making it protected ensures that the function can only be accessed by subclasses of SdkFragment.

  3. InboxViewer Class Lifecycle Functions:
    Change: Super calls were made first in the onResume, onDestroy, and onViewCreated functions.
    Reason: This change ensures that the class is protected from unexpected behavior by performing the default actions of the lifecycle functions first, and also increases overall compatibility.

  4. Inbox Class Date Format:
    Change: Proposed that the date format in the Inbox class be set according to locale.
    Reason: It is suggested that the date format be determined according to the user's locale to improve the user experience. This way, users can view dates in a format that they are more familiar with.

@@ -52,6 +52,7 @@ class InboxViewer : Fragment() {
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

super.onResume()
webView.onResume()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

super.onDestroy()
webView.destroy()
Copy link
Contributor

Choose a reason for hiding this comment

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

This one, however, is not correct. The application's onDestroy might rely on something that is torn down in the super class. Google's recommendation is to call super first when creating/starting things, but last when pausing/stopping things.

@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair.

companion object {
val DATE_FORMAT: DateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH)
}
private val dateFormat: DateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.getDefault())
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair.

@@ -64,7 +64,7 @@ abstract class SdkFragment : Fragment() {
}
}

internal fun String.showSnackbar(length: Int = Snackbar.LENGTH_SHORT) {
protected fun String.showSnackbar(length: Int = Snackbar.LENGTH_SHORT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair.

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