Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Anti Pattern in Connectivity View #423

Open
Cefigueredo opened this issue May 19, 2022 · 0 comments
Open

Anti Pattern in Connectivity View #423

Cefigueredo opened this issue May 19, 2022 · 0 comments

Comments

@Cefigueredo
Copy link

Cefigueredo commented May 19, 2022

In the following video, the feature that redirects the user to an explorer without first checking if the user has a connection fails, so the user gets the default chrome connectivity error view. The correct way to deal with this anti pattern could be to notify the user that he doesn't have a connection and try again when it is back.

Video of the Anti pattern: https://drive.google.com/file/d/1OfRvDKO8-EyGn39aJtpfk6YfVdCwcVGy/view?usp=sharing

This is found in the next path: mobile>java>com.google.samples.apps.iosched>ui>codelabs>CodelabsFragments

We propose the following changes. First, check if there is connectivity. If it is true, it calls the URL. Otherwise, return a message informing the user about the issue.

     override fun startCodelab(codelab: Codelab) {
            val connectionManager: ConnectivityManager = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
             val activeNetwork: NetworkInfo? = connectionManager.activeNetworkInfo
             val isConnected: Boolean = activeNetwork?.isConnectedOrConnecting == true
             if (isConnected) {
                 if (codelab.hasUrl()) {
                     openWebsiteUri(
                         requireContext(),
                         addCodelabsAnalyticsQueryParams(codelab.codelabUrl)
                     )
                     analyticsHelper.logUiEvent(
                         "Start codelab "${codelab.title}"",
                         AnalyticsActions.CLICK
                     )
                 }
             }
             else{
                 val builder = AlertDialog.Builder(this)
                 builder.setTitle("Error")
                 builder.setMessage("There is no network connection. Please check and try again")
                 builder.setPositiveButton("Accept",null)
                 val dialog: AlertDialog = builder.create()
                 dialog.show()
             }
         }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant