Search in sources :

Example 26 with ObservableScrollView

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollView 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 27 with ObservableScrollView

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollView in project UltimateAndroid by cymcsg.

the class ViewPagerTabActivity method adjustToolbarForScrollViews.

private void adjustToolbarForScrollViews(ScrollState scrollState, View view) {
    int toolbarHeight = mToolbarView.getHeight();
    final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
    if (scrollView == null) {
        return;
    }
    if (scrollState == ScrollState.UP) {
        if (toolbarHeight < scrollView.getCurrentScrollY()) {
            hideToolbar();
        } else if (scrollView.getCurrentScrollY() < toolbarHeight) {
            showToolbar();
        }
    } else if (scrollState == ScrollState.DOWN) {
        if (toolbarHeight < scrollView.getCurrentScrollY()) {
            showToolbar();
        }
    }
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView)

Example 28 with ObservableScrollView

use of com.github.ksoichiro.android.observablescrollview.ObservableScrollView in project UltimateAndroid by cymcsg.

the class FlexibleSpaceToolbarScrollViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.observable_scroll_view_activity_flexiblespacetoolbarscrollview);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mFlexibleSpaceView = findViewById(R.id.flexible_space);
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setText(getTitle());
    setTitle(null);
    mToolbarView = findViewById(R.id.toolbar);
    final ObservableScrollView scrollView = (ObservableScrollView) findViewById(R.id.scroll);
    scrollView.setScrollViewCallbacks(this);
    mFlexibleSpaceHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_height);
    int flexibleSpaceAndToolbarHeight = mFlexibleSpaceHeight + getActionBarSize();
    findViewById(R.id.body).setPadding(0, flexibleSpaceAndToolbarHeight, 0, 0);
    mFlexibleSpaceView.getLayoutParams().height = flexibleSpaceAndToolbarHeight;
    ViewTreeObserver vto = mTitleView.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                mTitleView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                mTitleView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
            updateFlexibleSpaceText(scrollView.getCurrentScrollY());
        }
    });
}
Also used : ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

ObservableScrollView (com.github.ksoichiro.android.observablescrollview.ObservableScrollView)28 View (android.view.View)14 ObservableScrollViewCallbacks (com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks)7 Activity (android.app.Activity)6 Bundle (android.os.Bundle)5 Fragment (android.support.v4.app.Fragment)5 ActionBar (android.support.v7.app.ActionBar)2 ViewTreeObserver (android.view.ViewTreeObserver)2 FrameLayout (android.widget.FrameLayout)2 TextView (android.widget.TextView)2 Toolbar (android.support.v7.widget.Toolbar)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 ViewGroup (android.view.ViewGroup)1 WebView (android.webkit.WebView)1 ImageButton (android.widget.ImageButton)1 SaveListener (cn.bmob.v3.listener.SaveListener)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 Feedback (com.nightonke.saver.model.Feedback)1