private void SetMaterialHeight() { //get the MaterialViewPagerAnimator attached to this activity //to retrieve the declared header height //and set it as current view height (+10dp margin) MaterialViewPagerAnimator animator = MaterialViewPagerHelper.GetAnimator(Context); if (animator != null) { ViewGroup.LayoutParams param = LayoutParameters; param.Height = (int)Math.Round(Utils.DpToPx(animator.GetHeaderHeight() + 10, Context)); LayoutParameters = param; } }
protected override void OnRestoreInstanceState(IParcelable state) { SavedState ss = (SavedState)state; base.OnRestoreInstanceState(ss.SuperState); Settings = ss.Settings; if (HeaderBackground != null) { HeaderBackground.SetBackgroundColor(new Color(Settings.Color)); } MaterialViewPagerAnimator animator = MaterialViewPagerHelper.GetAnimator(Context); //-1*ss.yOffset restore to 0 animator.RestoreScroll(-1 * ss.YOffset, ss.Settings); MaterialViewPagerHelper.Register(Context, animator); }
/** * Have to be called from WebView.WebViewClient.onPageFinished * ex : mWebView.setWebViewClient(new WebViewClient() { onPageFinished(WebView view, String url) { [HERE] }}); * Inject a header to a webview : add a margin-top="**dpx" * Had to have a transparent background with a placeholder on top * So inject js for placeholder and setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); for transparency * TODO : inject JavaScript for Pre-Lolipop with loadUrl("js:...") * * @param webView * @param withAnimation if true, disapear with a fadein */ public static void InjectHeader(WebView webView, bool withAnimation) { if (webView != null) { MaterialViewPagerAnimator animator = GetAnimator(webView.Context); if (animator != null) { WebSettings webSettings = webView.Settings; #pragma warning disable 618 webSettings.SetRenderPriority(WebSettings.RenderPriority.High); #pragma warning restore 618 webSettings.CacheMode = CacheModes.NoCache; webSettings.JavaScriptEnabled = true; webSettings.DomStorageEnabled = true; if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { //transparent background webView.SetLayerType(LayerType.Software, null); } { //inject margin top int marginTop = animator.GetHeaderHeight() + 10; string js = string.Format("document.body.style.marginTop= \"{0}px\"", marginTop); WebViewLoadJs(webView, js); } { string js = "document.body.style.backround-color= white"; WebViewLoadJs(webView, js); } if (withAnimation) { webView.PostDelayed(() => { webView.Visibility = ViewStates.Visible; ObjectAnimator.OfFloat(webView, "alpha", 0, 1).Start(); }, 400); } } } }
public AnimatorListener(MaterialViewPagerAnimator materialViewPagerAnimator) { _animator = materialViewPagerAnimator; }
public RecyclerViewScrollListener(MaterialViewPagerAnimator materialViewPagerAnimator, RecyclerView.OnScrollListener onScrollListener) { _animator = materialViewPagerAnimator; _onScrollListener = onScrollListener; }
public ObservableScrollViewCallbacks(MaterialViewPagerAnimator materialViewPagerAnimator, ObservableScrollView.ObservableScrollView scrollView, IObservableScrollViewCallbacks observableScrollViewCallbacks) { _animator = materialViewPagerAnimator; _scrollView = scrollView; _observableScrollViewCallbacks = observableScrollViewCallbacks; }
/** * Register an MaterialViewPagerAnimator attached to an activity into the ConcurrentHashMap * * @param context the context * @param animator the current MaterialViewPagerAnimator */ public static void Register(Context context, MaterialViewPagerAnimator animator) { _hashMap.TryAdd(context, animator); }