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);
}
}
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();
}
});
}
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();
}
});
}
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);
});
}
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);
}
}
Aggregations