Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

WebView using redirect URL

[ Edited ]

Iam loading a url which is having a redirection in it.Iam loading this in a webView.In Z 10.1 device webView loading seems to be very slow.So Iam trying to put a progessBar showing the loading status of the url.

 

My problem is:

As Iam giving this url with redirection the loading status first goes to 'start; then 'succeded'.Them again it goes to 'start' then 'succeeded'.Because of this my progress bar appears 2 times.

 

Below is my code

import bb.cascades 1.0

Page {
    Container {
        layout: DockLayout {}

        ScrollView {
            id: scrollView
            scrollViewProperties {
                scrollMode: ScrollMode.Both
                pinchToZoomEnabled: true
            }

            WebView {
                url: "https://www.facebook.com/dialog/oauth?client_id=515788691819676 &redirect_uri=http://www.google.com &response_type=token&scope=publish_actions"


                settings.viewport: {
                    "width": "device-width",
                    "initial-scale": 1.0
                }

                onLoadProgressChanged: {
                    // Update the ProgressBar while loading.
                    progressIndicator.value = loadProgress / 100.0
                }


                onLoadingChanged: {

                    if (loadRequest.status == WebLoadStatus.Started) 
                    {                     
                          
                            progressIndicator.opacity = 1.0
                          

                    } 
                    else if (loadRequest.status == WebLoadStatus.Succeeded) 
                    {
                       
                        progressIndicator.opacity = 0.0
                       
                    } 
                    else if (loadRequest.status == WebLoadStatus.Failed)
                    {
                        progressIndicator.opacity = 0.0
                    }
                }

                                onNavigationRequested:
                                        {

                    if (! shouldAcceptNavigationToUrl(request.url)) {
                        request.action = WebNavigationRequestAction.Ignore
                    }
                                 
                                       }

        } // ScrollView

        // A progress indicator that is used to show the loading status
        Container {
            bottomPadding: 25
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Bottom

//            ProgressIndicator {
//                id: progressIndicator
//                opacity: 0
//            } 

        }
    } //Container
}// Page

 Is there any solution to show the progess bar correctly until the web page has been loaded completely.Plz PLz help me out

Contributor
Posts: 31
Registered: ‎03-26-2013
My Device: Z10 Dev Edition
My Carrier: Celcom

Re: WebView using redirect URL

i usually will use this

DataSource {
            id: myDataSource
          source: "http://www.thestar.com.my/RSS/Editors-Choice/Main.aspx"
            query: "/rss/channel/item"
            type: DataSourceType.Xml
            onDataLoaded: {
                //Activity indicator
                dataLoadIndicator.stop();//eol
                myDataModel.clear();
                myDataModel.insertList(data)
            }
            
        },
    ComponentDefinition {
        id: detailsPage
        Page {
            property alias htmlContent: detailsView.url
            Container {
                layout: DockLayout {
                }
                Container {
                    ScrollView {
                        scrollViewProperties.scrollMode: ScrollMode.Both
                        scrollViewProperties {
                            pinchToZoomEnabled: true
                                    maxContentScale: 5
                                    minContentScale: 1
                        }
                        WebView {
                            id: detailsView
                            settings.zoomToFitEnabled: true
                            settings.activeTextEnabled: true
                            onLoadProgressChanged: {
                                // Update the ProgressBar while loading.
                                progressIndicator.value = loadProgress / 100.0
                            }
                                onLoadingChanged: {
                                    if (loadRequest.status == WebLoadStatus.Started) {
                                    // Show the ProgressBar when loading started.
                                        progressIndicator.opacity = 1.0
                                    } else if (loadRequest.status == WebLoadStatus.Succeeded) {
                                    // Hide the ProgressBar when loading is complete.
                                        progressIndicator.opacity = 0.0
                                    } else if (loadRequest.status == WebLoadStatus.Failed) {
                                    // If loading failed
                                        html = "<html><head><title>Loading Failed</title></head> 
                                                <body>Check Internet connection?</body></html>"
                                       progressIndicator.opacity = 0.0
                                    }
                                }
                            }
                        }
                    }
                    Container {
                        bottomPadding: 25
                        horizontalAlignment: HorizontalAlignment.Center
                        verticalAlignment: VerticalAlignment.Top
                        ProgressIndicator {
                                id: progressIndicator
                                opacity: 1
                                            }
                                        }
                                    }
                                }
                            }
    ]    
    onCreationCompleted: {
        myDataSource.load();
        //Activity Indicator
        dataLoadIndicator.start();//eol
        
        OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
    }
    

 

Developer
Posts: 148
Registered: ‎04-08-2013
My Device: Blackberry 10
My Carrier: Blackberry

Re: WebView using redirect URL

Hi,

 Thanks for your reply.But I dont need any dataSource.The progress bar is displaying accordingly.But my problem is as the url that I gave contains a redirection the progress bar is appearing twice.Hope you understood my problem and give me answer accordingly.