Search in sources :

Example 1 with CircularProgressIndicator

use of com.google.android.material.progressindicator.CircularProgressIndicator in project edx-app-android by openedx.

the class WebViewActivity method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);
    super.setToolbarAsActionBar();
    // Check if the activity was opened due to a broadcast for which we have an IntentFilter
    // for this activity in AndroidManifest.xml
    final Uri intentData = getIntent().getData();
    if (intentData != null && AppConstants.APP_URI_SCHEME.startsWith(intentData.getScheme())) {
        final String title = intentData.getHost();
        final String url = intentData.getQueryParameter(PARAM_INTENT_FILE_LINK);
        getIntent().putExtra(ARG_URL, url).putExtra(ARG_TITLE, title);
    }
    final CircularProgressIndicator progress = (CircularProgressIndicator) findViewById(R.id.loading_indicator);
    progress.setVisibility(View.GONE);
    webView = (WebView) findViewById(R.id.webView);
    final URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(this, webView, false, null);
    client.setPageStatusListener(new URLInterceptorWebViewClient.IPageStatusListener() {

        @Override
        public void onPageStarted() {
            progress.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished() {
            progress.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, int errorCode, String description, String failingUrl) {
            progress.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, boolean isMainRequestFailure) {
            if (isMainRequestFailure) {
                progress.setVisibility(View.GONE);
            }
        }

        @Override
        public void onPageLoadProgressChanged(WebView view, int progressPercent) {
            if (progressPercent > AppConstants.PAGE_LOAD_THRESHOLD)
                progress.setVisibility(View.GONE);
        }
    });
    webView.loadUrl(getIntent().getStringExtra(ARG_URL));
    final String title = getIntent().getStringExtra(ARG_TITLE);
    if (!TextUtils.isEmpty(title)) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle(title);
    }
}
Also used : WebResourceRequest(android.webkit.WebResourceRequest) WebResourceResponse(android.webkit.WebResourceResponse) WebView(android.webkit.WebView) Uri(android.net.Uri) CircularProgressIndicator(com.google.android.material.progressindicator.CircularProgressIndicator) URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient) AndroidEntryPoint(dagger.hilt.android.AndroidEntryPoint)

Example 2 with CircularProgressIndicator

use of com.google.android.material.progressindicator.CircularProgressIndicator in project ods-android by Orange-OpenSource.

the class ProgressIndicatorDeterminateDemoFragment method initialize.

public void initialize(@NonNull View view) {
    List<LinearProgressIndicator> linearProgressIndicatorList = DemoUtils.findViewsWithType(view, LinearProgressIndicator.class);
    List<CircularProgressIndicator> circularProgressIndicatorList = DemoUtils.findViewsWithType(view, CircularProgressIndicator.class);
    Slider slider = view.findViewById(R.id.slider);
    Button showButton = view.findViewById(R.id.show_button);
    Button hideButton = view.findViewById(R.id.hide_button);
    slider.addOnChangeListener((sliderObj, value, fromUser) -> {
        for (LinearProgressIndicator indicator : linearProgressIndicatorList) {
            indicator.setProgressCompat((int) value, true);
        }
        for (CircularProgressIndicator indicator : circularProgressIndicatorList) {
            indicator.setProgressCompat((int) value, true);
        }
    });
    showButton.setOnClickListener(v -> {
        for (LinearProgressIndicator indicator : linearProgressIndicatorList) {
            indicator.show();
        }
        for (CircularProgressIndicator indicator : circularProgressIndicatorList) {
            indicator.show();
        }
    });
    hideButton.setOnClickListener(v -> {
        for (LinearProgressIndicator indicator : linearProgressIndicatorList) {
            indicator.hide();
        }
        for (CircularProgressIndicator indicator : circularProgressIndicatorList) {
            indicator.hide();
        }
    });
}
Also used : Slider(com.google.android.material.slider.Slider) Button(android.widget.Button) LinearProgressIndicator(com.google.android.material.progressindicator.LinearProgressIndicator) CircularProgressIndicator(com.google.android.material.progressindicator.CircularProgressIndicator)

Example 3 with CircularProgressIndicator

use of com.google.android.material.progressindicator.CircularProgressIndicator in project ods-android by Orange-OpenSource.

the class ProgressIndicatorIndeterminateDemoFragment method initialize.

private void initialize(View view) {
    List<LinearProgressIndicator> linearProgressIndicatorList = DemoUtils.findViewsWithType(view, LinearProgressIndicator.class);
    List<CircularProgressIndicator> circularProgressIndicatorList = DemoUtils.findViewsWithType(view, CircularProgressIndicator.class);
    EditText progressInput = view.findViewById(R.id.progress_input);
    Button updateButton = view.findViewById(R.id.update_button);
    Button showButton = view.findViewById(R.id.show_button);
    Button hideButton = view.findViewById(R.id.hide_button);
    updateButton.setOnClickListener(v -> {
        int progress;
        try {
            progress = Integer.parseInt(progressInput.getEditableText().toString());
        } catch (NumberFormatException e) {
            progress = 0;
        }
        for (LinearProgressIndicator indicator : linearProgressIndicatorList) {
            updateLinearProgressIndicator(indicator, progress);
        }
        for (CircularProgressIndicator indicator : circularProgressIndicatorList) {
            updateCircularProgressIndicator(indicator, progress);
        }
    });
    showButton.setOnClickListener(v -> {
        for (LinearProgressIndicator indicator : linearProgressIndicatorList) {
            resetLinearProgressIndicator(indicator);
            indicator.show();
        }
        for (CircularProgressIndicator indicator : circularProgressIndicatorList) {
            resetCircularProgressIndicator(indicator);
            indicator.show();
        }
    });
    hideButton.setOnClickListener(v -> {
        for (LinearProgressIndicator indicator : linearProgressIndicatorList) {
            indicator.hide();
        }
        for (CircularProgressIndicator indicator : circularProgressIndicatorList) {
            indicator.hide();
        }
    });
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) LinearProgressIndicator(com.google.android.material.progressindicator.LinearProgressIndicator) CircularProgressIndicator(com.google.android.material.progressindicator.CircularProgressIndicator)

Example 4 with CircularProgressIndicator

use of com.google.android.material.progressindicator.CircularProgressIndicator in project ods-android by Orange-OpenSource.

the class ProgressIndicatorMainDemoFragment method initialize.

public void initialize(@NonNull View view) {
    LinearProgressIndicator linearDeterminate = view.findViewById(R.id.linear_determinate);
    CircularProgressIndicator circularDeterminate = view.findViewById(R.id.circular_determinate);
    EditText progressInput = view.findViewById(R.id.progress_input);
    Button updateButton = view.findViewById(R.id.update_button);
    updateButton.setOnClickListener(v -> {
        int progress;
        try {
            progress = Integer.parseInt(progressInput.getEditableText().toString());
        } catch (Exception e) {
            progress = 0;
        }
        linearDeterminate.setProgressCompat(progress, true);
        circularDeterminate.setProgressCompat(progress, true);
    });
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) LinearProgressIndicator(com.google.android.material.progressindicator.LinearProgressIndicator) CircularProgressIndicator(com.google.android.material.progressindicator.CircularProgressIndicator)

Example 5 with CircularProgressIndicator

use of com.google.android.material.progressindicator.CircularProgressIndicator in project edx-app-android by edx.

the class WebViewActivity method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);
    super.setToolbarAsActionBar();
    // Check if the activity was opened due to a broadcast for which we have an IntentFilter
    // for this activity in AndroidManifest.xml
    final Uri intentData = getIntent().getData();
    if (intentData != null && AppConstants.APP_URI_SCHEME.startsWith(intentData.getScheme())) {
        final String title = intentData.getHost();
        final String url = intentData.getQueryParameter(PARAM_INTENT_FILE_LINK);
        getIntent().putExtra(ARG_URL, url).putExtra(ARG_TITLE, title);
    }
    final CircularProgressIndicator progress = (CircularProgressIndicator) findViewById(R.id.loading_indicator);
    progress.setVisibility(View.GONE);
    webView = (WebView) findViewById(R.id.webView);
    final URLInterceptorWebViewClient client = new URLInterceptorWebViewClient(this, webView, false, null);
    client.setPageStatusListener(new URLInterceptorWebViewClient.IPageStatusListener() {

        @Override
        public void onPageStarted() {
            progress.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished() {
            progress.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, int errorCode, String description, String failingUrl) {
            progress.setVisibility(View.GONE);
        }

        @Override
        public void onPageLoadError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse, boolean isMainRequestFailure) {
            if (isMainRequestFailure) {
                progress.setVisibility(View.GONE);
            }
        }

        @Override
        public void onPageLoadProgressChanged(WebView view, int progressPercent) {
            if (progressPercent > AppConstants.PAGE_LOAD_THRESHOLD)
                progress.setVisibility(View.GONE);
        }
    });
    webView.loadUrl(getIntent().getStringExtra(ARG_URL));
    final String title = getIntent().getStringExtra(ARG_TITLE);
    if (!TextUtils.isEmpty(title)) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle(title);
    }
}
Also used : WebResourceRequest(android.webkit.WebResourceRequest) WebResourceResponse(android.webkit.WebResourceResponse) WebView(android.webkit.WebView) Uri(android.net.Uri) CircularProgressIndicator(com.google.android.material.progressindicator.CircularProgressIndicator) URLInterceptorWebViewClient(org.edx.mobile.view.custom.URLInterceptorWebViewClient) AndroidEntryPoint(dagger.hilt.android.AndroidEntryPoint)

Aggregations

CircularProgressIndicator (com.google.android.material.progressindicator.CircularProgressIndicator)9 Button (android.widget.Button)3 LinearProgressIndicator (com.google.android.material.progressindicator.LinearProgressIndicator)3 Uri (android.net.Uri)2 ContextThemeWrapper (android.view.ContextThemeWrapper)2 View (android.view.View)2 WebResourceRequest (android.webkit.WebResourceRequest)2 WebResourceResponse (android.webkit.WebResourceResponse)2 WebView (android.webkit.WebView)2 EditText (android.widget.EditText)2 FrameLayout (android.widget.FrameLayout)2 TextView (android.widget.TextView)2 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)2 PlayerView (com.google.android.exoplayer2.ui.PlayerView)2 AndroidEntryPoint (dagger.hilt.android.AndroidEntryPoint)2 URLInterceptorWebViewClient (org.edx.mobile.view.custom.URLInterceptorWebViewClient)2 Slider (com.google.android.material.slider.Slider)1