Search in sources :

Example 21 with ObservableScrollViewCallbacks

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTabScrollViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scrollview, container, false);
    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    Activity parentActivity = getActivity();
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        // Scroll to the specified offset after layout
        Bundle args = getArguments();
        if (args != null && args.containsKey(ARG_SCROLL_Y)) {
            final int scrollY = args.getInt(ARG_SCROLL_Y, 0);
            ScrollUtils.addOnGlobalLayoutListener(scrollView, new Runnable() {

                @Override
                public void run() {
                    scrollView.scrollTo(0, scrollY);
                }
            });
        }
        // TouchInterceptionViewGroup should be a parent view other than ViewPager.
        // This is a workaround for the issue #117:
        // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
        scrollView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));
        scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) Bundle(android.os.Bundle) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View)

Example 22 with ObservableScrollViewCallbacks

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTab2WebViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_webview, container, false);
    final ObservableWebView webView = (ObservableWebView) view.findViewById(R.id.scroll);
    webView.loadUrl("file:///android_asset/lipsum.html");
    Activity parentActivity = getActivity();
    webView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        webView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
Also used : ObservableWebView(com.github.ksoichiro.android.observablescrollview.ObservableWebView) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) View(android.view.View) ObservableWebView(com.github.ksoichiro.android.observablescrollview.ObservableWebView)

Example 23 with ObservableScrollViewCallbacks

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTabFragmentScrollViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scrollview_noheader, container, false);
    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    Fragment parentFragment = getParentFragment();
    ViewGroup viewGroup = (ViewGroup) parentFragment.getView();
    if (viewGroup != null) {
        scrollView.setTouchInterceptionViewGroup((ViewGroup) viewGroup.findViewById(R.id.container));
        if (parentFragment instanceof ObservableScrollViewCallbacks) {
            scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentFragment);
        }
    }
    return view;
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) ViewGroup(android.view.ViewGroup) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) Fragment(android.support.v4.app.Fragment)

Example 24 with ObservableScrollViewCallbacks

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTab2ScrollViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_scrollview_noheader, container, false);
    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    Activity parentActivity = getActivity();
    scrollView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View)

Example 25 with ObservableScrollViewCallbacks

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks in project Android-ObservableScrollView by ksoichiro.

the class ViewPagerTab2WebViewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_webview, container, false);
    final ObservableWebView webView = (ObservableWebView) view.findViewById(R.id.scroll);
    webView.loadUrl("file:///android_asset/lipsum.html");
    Activity parentActivity = getActivity();
    webView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.container));
    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        webView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
Also used : ObservableWebView(com.github.ksoichiro.android.observablescrollview.ObservableWebView) Activity(android.app.Activity) ObservableScrollViewCallbacks(com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks) View(android.view.View) ObservableWebView(com.github.ksoichiro.android.observablescrollview.ObservableWebView)

Aggregations

View (android.view.View)26 ObservableScrollViewCallbacks (com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks)26 Activity (android.app.Activity)21 Bundle (android.os.Bundle)11 ObservableScrollView (com.github.ksoichiro.android.observablescrollview.ObservableScrollView)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 ObservableListView (com.github.ksoichiro.android.observablescrollview.ObservableListView)6 ObservableRecyclerView (com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView)6 Fragment (android.support.v4.app.Fragment)5 ViewGroup (android.view.ViewGroup)5 ObservableGridView (com.github.ksoichiro.android.observablescrollview.ObservableGridView)4 ObservableWebView (com.github.ksoichiro.android.observablescrollview.ObservableWebView)3 ViewTreeObserver (android.view.ViewTreeObserver)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 RecyclerView (android.support.v7.widget.RecyclerView)1 FrameLayout (android.widget.FrameLayout)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 TintImageView (com.bilibili.magicasakura.widgets.TintImageView)1 ArrayList (java.util.ArrayList)1