Search in sources :

Example 1 with ObservableWebViewWithHeader

use of com.marshalchen.common.uimodule.fadingactionbar.view.ObservableWebViewWithHeader in project UltimateAndroid by cymcsg.

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 LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    webView.addView(mMarginView);
    return webViewContainer;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) ObservableWebViewWithHeader(com.marshalchen.common.uimodule.fadingactionbar.view.ObservableWebViewWithHeader)

Example 2 with ObservableWebViewWithHeader

use of com.marshalchen.common.uimodule.fadingactionbar.view.ObservableWebViewWithHeader in project UltimateAndroid by cymcsg.

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.marshalchen.common.uimodule.fadingactionbar.view.ObservableScrollView) View(android.view.View) ListView(android.widget.ListView) ObservableWebViewWithHeader(com.marshalchen.common.uimodule.fadingactionbar.view.ObservableWebViewWithHeader)

Aggregations

ObservableWebViewWithHeader (com.marshalchen.common.uimodule.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.marshalchen.common.uimodule.fadingactionbar.view.ObservableScrollView)1