Search in sources :

Example 1 with ObservableWebViewWithHeader

use of com.manuelpeinado.fadingactionbar.view.ObservableWebViewWithHeader in project FadingActionBar by ManuelPeinado.

the class FadingActionBarHelperBase method createView.

public final View createView(LayoutInflater inflater) {
    //
    // Prepare everything
    mInflater = inflater;
    if (mContentView == null) {
        mContentView = inflater.inflate(mContentLayoutResId, null);
    }
    if (mHeaderView == null) {
        mHeaderView = inflater.inflate(mHeaderLayoutResId, null, false);
    }
    //
    // See if we are in a ListView, WebView or ScrollView scenario
    ListView listView = (ListView) mContentView.findViewById(android.R.id.list);
    View root;
    if (listView != null) {
        root = createListView(listView);
    } else if (mContentView instanceof ObservableWebViewWithHeader) {
        root = createWebView();
    } else {
        root = createScrollView();
    }
    if (mHeaderOverlayView == null && mHeaderOverlayLayoutResId != 0) {
        mHeaderOverlayView = inflater.inflate(mHeaderOverlayLayoutResId, mMarginView, false);
    }
    if (mHeaderOverlayView != null) {
        mMarginView.addView(mHeaderOverlayView);
    }
    // Use measured height here as an estimate of the header height, later on after the layout is complete 
    // we'll use the actual height
    int widthMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.MATCH_PARENT, MeasureSpec.EXACTLY);
    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(LayoutParams.WRAP_CONTENT, MeasureSpec.EXACTLY);
    mHeaderView.measure(widthMeasureSpec, heightMeasureSpec);
    updateHeaderHeight(mHeaderView.getMeasuredHeight());
    root.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            int headerHeight = mHeaderContainer.getHeight();
            if (!mFirstGlobalLayoutPerformed && headerHeight != 0) {
                updateHeaderHeight(headerHeight);
                mFirstGlobalLayoutPerformed = true;
            }
        }
    });
    return root;
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) AbsListView(android.widget.AbsListView) ObservableScrollView(com.manuelpeinado.fadingactionbar.view.ObservableScrollView) View(android.view.View) ListView(android.widget.ListView) ObservableWebViewWithHeader(com.manuelpeinado.fadingactionbar.view.ObservableWebViewWithHeader)

Example 2 with ObservableWebViewWithHeader

use of com.manuelpeinado.fadingactionbar.view.ObservableWebViewWithHeader in project FadingActionBar by ManuelPeinado.

the class FadingActionBarHelperBase method createWebView.

private View createWebView() {
    ViewGroup webViewContainer = (ViewGroup) mInflater.inflate(R.layout.fab__webview_container, null);
    ObservableWebViewWithHeader webView = (ObservableWebViewWithHeader) mContentView;
    webView.setOnScrollChangedCallback(mOnScrollChangedListener);
    webViewContainer.addView(webView);
    mHeaderContainer = (FrameLayout) webViewContainer.findViewById(R.id.fab__header_container);
    initializeGradient(mHeaderContainer);
    mHeaderContainer.addView(mHeaderView, 0);
    mMarginView = new FrameLayout(webView.getContext());
    mMarginView.setBackgroundColor(Color.TRANSPARENT);
    mMarginView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    webView.addView(mMarginView);
    return webViewContainer;
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) LayoutParams(android.view.ViewGroup.LayoutParams) ObservableWebViewWithHeader(com.manuelpeinado.fadingactionbar.view.ObservableWebViewWithHeader)

Aggregations

ObservableWebViewWithHeader (com.manuelpeinado.fadingactionbar.view.ObservableWebViewWithHeader)2 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 LayoutParams (android.view.ViewGroup.LayoutParams)1 OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)1 AbsListView (android.widget.AbsListView)1 FrameLayout (android.widget.FrameLayout)1 ListView (android.widget.ListView)1 ObservableScrollView (com.manuelpeinado.fadingactionbar.view.ObservableScrollView)1