Search in sources :

Example 1 with NestedScrollView

use of androidx.core.widget.NestedScrollView in project materialistic by hidroh.

the class OfflineWebActivity method onCreate.

@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String url = getIntent().getStringExtra(EXTRA_URL);
    if (TextUtils.isEmpty(url)) {
        finish();
        return;
    }
    setTitle(url);
    setContentView(R.layout.activity_offline_web);
    final NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.nested_scroll_view);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setOnClickListener(v -> scrollView.smoothScrollTo(0, 0));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setSubtitle(R.string.offline);
    final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
    final WebView webView = (WebView) findViewById(R.id.web_view);
    webView.setBackgroundColor(Color.TRANSPARENT);
    webView.setWebViewClient(new AdBlockWebViewClient(Preferences.adBlockEnabled(this)) {

        @Override
        public void onPageFinished(WebView view, String url) {
            setTitle(view.getTitle());
        }
    });
    webView.setWebChromeClient(new CacheableWebView.ArchiveClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            progressBar.setVisibility(View.VISIBLE);
            progressBar.setProgress(newProgress);
            if (newProgress == 100) {
                progressBar.setVisibility(View.GONE);
                webView.setBackgroundColor(Color.WHITE);
                webView.setVisibility(View.VISIBLE);
            }
        }
    });
    AppUtils.toggleWebViewZoom(webView.getSettings(), true);
    webView.loadUrl(url);
}
Also used : AdBlockWebViewClient(io.github.hidroh.materialistic.widget.AdBlockWebViewClient) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) NestedScrollView(androidx.core.widget.NestedScrollView) CacheableWebView(io.github.hidroh.materialistic.widget.CacheableWebView) WebView(android.webkit.WebView) ProgressBar(android.widget.ProgressBar) Toolbar(androidx.appcompat.widget.Toolbar)

Example 2 with NestedScrollView

use of androidx.core.widget.NestedScrollView in project RxBinding by JakeWharton.

the class RxNestedScrollViewTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ScrollView scrollView = new ScrollView(this);
    nestedScrollView = new NestedScrollView(this);
    emptyView = new FrameLayout(this);
    LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
    LayoutParams emptyParams = new LayoutParams(50000, 50000);
    nestedScrollView.addView(emptyView, emptyParams);
    scrollView.addView(nestedScrollView, scrollParams);
    setContentView(scrollView, scrollParams);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ScrollView(android.widget.ScrollView) NestedScrollView(androidx.core.widget.NestedScrollView) FrameLayout(android.widget.FrameLayout) NestedScrollView(androidx.core.widget.NestedScrollView)

Example 3 with NestedScrollView

use of androidx.core.widget.NestedScrollView in project collect by opendatakit.

the class RankingWidgetDialog method setUpRankingLayout.

private NestedScrollView setUpRankingLayout() {
    LinearLayout rankingLayout = new LinearLayout(getContext());
    rankingLayout.setOrientation(LinearLayout.HORIZONTAL);
    rankingLayout.addView(setUpPositionsLayout());
    rankingLayout.addView(setUpRecyclerView());
    rankingLayout.setPadding(10, 0, 10, 0);
    NestedScrollView scrollView = new NestedScrollView(getContext());
    scrollView.addView(rankingLayout);
    return scrollView;
}
Also used : NestedScrollView(androidx.core.widget.NestedScrollView) LinearLayout(android.widget.LinearLayout)

Example 4 with NestedScrollView

use of androidx.core.widget.NestedScrollView in project SmoothRefreshLayout by dkzwm.

the class ScrollCompat method flingCompat.

public static void flingCompat(View view, int velocityY) {
    if (view instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) view;
        scrollView.fling(velocityY);
    } else if (view instanceof WebView) {
        WebView webView = (WebView) view;
        webView.flingScroll(0, velocityY);
    } else if (view instanceof NestedScrollView) {
        NestedScrollView scrollView = (NestedScrollView) view;
        scrollView.fling(velocityY);
    } else if (view instanceof AbsListView) {
        AbsListView listView = (AbsListView) view;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            listView.fling(velocityY);
        }
    } else if (ViewCatcherUtil.isRecyclerView(view)) {
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.fling(0, velocityY);
    }
}
Also used : NestedScrollView(androidx.core.widget.NestedScrollView) ScrollView(android.widget.ScrollView) AbsListView(android.widget.AbsListView) RecyclerView(androidx.recyclerview.widget.RecyclerView) WebView(android.webkit.WebView) NestedScrollView(androidx.core.widget.NestedScrollView)

Example 5 with NestedScrollView

use of androidx.core.widget.NestedScrollView in project SmoothRefreshLayout by dkzwm.

the class ScrollCompat method stopFling.

public static void stopFling(View view) {
    if (view instanceof ScrollView) {
        ScrollView scrollView = (ScrollView) view;
        scrollView.smoothScrollBy(0, 0);
    } else if (view instanceof WebView) {
        WebView webView = (WebView) view;
        webView.flingScroll(0, 0);
    } else if (view instanceof NestedScrollView) {
        NestedScrollView scrollView = (NestedScrollView) view;
        scrollView.smoothScrollBy(0, 0);
    } else if (view instanceof AbsListView) {
        AbsListView listView = (AbsListView) view;
        listView.smoothScrollBy(0, 0);
    } else if (ViewCatcherUtil.isRecyclerView(view)) {
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.stopScroll();
    }
}
Also used : NestedScrollView(androidx.core.widget.NestedScrollView) ScrollView(android.widget.ScrollView) AbsListView(android.widget.AbsListView) RecyclerView(androidx.recyclerview.widget.RecyclerView) WebView(android.webkit.WebView) NestedScrollView(androidx.core.widget.NestedScrollView)

Aggregations

NestedScrollView (androidx.core.widget.NestedScrollView)7 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 WebView (android.webkit.WebView)3 ScrollView (android.widget.ScrollView)3 Bundle (android.os.Bundle)2 View (android.view.View)2 AbsListView (android.widget.AbsListView)2 TextView (android.widget.TextView)2 Toolbar (androidx.appcompat.widget.Toolbar)2 MainActivity (app.insti.activity.MainActivity)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 AlertDialog (android.app.AlertDialog)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Color (android.graphics.Color)1 Point (android.graphics.Point)1