protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_style_fungame_hitblock);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            toolbar.NavigationClick += (sender, e) => { Finish(); };

            var refreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout;

            if (isFirstEnter)
            {
                isFirstEnter = false;
                refreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果
            }

            mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            mToolbar.NavigationClick += (sender, e) => { Finish(); };

            mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout;
            if (isFirstEnter)
            {
                isFirstEnter = false;
                mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果
            }

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            recyclerView.SetItemAnimator(new DefaultItemAnimator());
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            recyclerView.AddItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.Vertical));
            recyclerView.SetAdapter(new CustomBaseRecyclerAdapter(Item.List, Android.Resource.Layout.SimpleListItem2, this));
        }
Beispiel #2
0
        public void OnItemClick(AdapterView parent, View view, int position, long id)
        {
            ActivityInfo item = ActivityInfo.List[position];

            if (Class.FromType(typeof(Android.App.Activity)).IsAssignableFrom(item.Clazz))
            {
                StartActivity(new Intent(Context, item.Clazz));
            }
            else if (Class.FromType(typeof(IRefreshHeader)).IsAssignableFrom(item.Clazz))
            {
                try {
                    Constructor    constructor = item.Clazz.GetConstructor(Context.Class);
                    IRefreshHeader header      = (IRefreshHeader)constructor.NewInstance(Context);
                    IRefreshLayout layout      = (IRefreshLayout)View.FindViewById(Resource.Id.refreshLayout);
                    layout.SetRefreshHeader(header);
                    if (!(header is ClassicsHeader))
                    {
                        layout.SetPrimaryColorsId(Resource.Color.colorPrimary, Android.Resource.Color.White);
                    }
                    layout.AutoRefresh();
                } catch (Exception e) {
                    e.PrintStackTrace();
                }
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_style_delivery);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) // 21
            {
                Window.SetStatusBarColor(new Android.Graphics.Color(0xf0f0f0));
            }
            if (Build.VERSION.SdkInt >= BuildVersionCodes.M) // 23
            {
                SystemUiFlags systemUiVisibility = (SystemUiFlags)Window.DecorView.SystemUiVisibility;
                systemUiVisibility |= SystemUiFlags.LightStatusBar;
                Window.DecorView.SystemUiVisibility = (StatusBarVisibility)systemUiVisibility;
            }

            mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            mToolbar.NavigationClick += (sender, e) => { Finish(); };

            mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout;
            if (isFirstEnter)
            {
                isFirstEnter = false;
                mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果
            }

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            recyclerView.SetItemAnimator(new DefaultItemAnimator());
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            recyclerView.AddItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.Vertical));
            recyclerView.SetAdapter(new CustomBaseRecyclerAdapter(Item.List, Resource.Layout.listitem_style_delivery, this));
        }
Beispiel #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_practice_webview);

            var mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            mToolbar.NavigationClick += (sender, e) => { Finish(); };


            mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout;
            mRefreshLayout.SetOnRefreshListener(new CustomOnRefreshListener(this));
            mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果

            webView = FindViewById <WebView>(Resource.Id.webView);
            webView.Settings.JavaScriptEnabled = true;

            webView.SetWebViewClient(new CustomWebViewClient(this));

            //状态栏透明和间距处理
            StatusBarUtil.immersive(this);
            StatusBarUtil.setPaddingSmart(this, webView);
            StatusBarUtil.setPaddingSmart(this, mToolbar);
            StatusBarUtil.setMargin(this, FindViewById(Resource.Id.header));
            StatusBarUtil.setPaddingSmart(this, FindViewById(Resource.Id.blurview));
        }
Beispiel #5
0
 public override void OnStateChanged(IRefreshLayout refreshLayout, RefreshState oldState, RefreshState newState)
 {
     if (oldState == RefreshState.LoadFinish && newState == RefreshState.None)
     {
         refreshLayout.AutoRefresh();
         refreshLayout.SetOnMultiPurposeListener(null);
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_style_taurus);


            mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            mToolbar.NavigationClick += (sender, e) => { Finish(); };

            mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout;
            if (isFirstEnter)
            {
                isFirstEnter = false;
                mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果
            }

            mAppBarLayout  = FindViewById <AppBarLayout>(Resource.Id.app_bar);
            mToolbarLayout = FindViewById <CollapsingToolbarLayout>(Resource.Id.toolbar_layout);

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            recyclerView.SetItemAnimator(new DefaultItemAnimator());
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            recyclerView.AddItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.Vertical));
            recyclerView.SetAdapter(new CustomBaseRecyclerAdapter(Item.List, Android.Resource.Layout.SimpleListItem2, this));

            // 监听 AppBarLayout 的关闭和开启 给 FlyView(纸飞机) 和 ActionButton 设置关闭隐藏动画
            mActionButton = FindViewById <FloatingActionButton>(Resource.Id.fab);
            mAppBarLayout.OffsetChanged += (sender, e) => {
                var   appBarLayout   = e.AppBarLayout;
                var   verticalOffset = e.VerticalOffset;
                int   scrollRange    = appBarLayout.TotalScrollRange;
                float fraction       = 1f * (scrollRange + verticalOffset) / scrollRange;
                if (fraction < 0.1 && misAppbarExpand)
                {
                    misAppbarExpand = false;
                    mActionButton.Animate().ScaleX(0).ScaleY(0);
                }
                if (fraction > 0.8 && !misAppbarExpand)
                {
                    misAppbarExpand = true;
                    mActionButton.Animate().ScaleX(1).ScaleY(1);
                }
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_fly_refresh);

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            toolbar.NavigationClick += (sender, e) => { Finish(); };

            /************************************************************
            * 关键代码-开始
            ************************************************************/

            mFlyView          = FindViewById <FlyView>(Resource.Id.flyview);
            mScenceView       = FindViewById <MountanScenceView>(Resource.Id.mountan);
            mFlyRefreshHeader = FindViewById <FlyRefreshHeader>(Resource.Id.flyrefresh);
            mFlyRefreshHeader.SetUp(mScenceView, mFlyView);                      //绑定场景和纸飞机
            mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout;
            mRefreshLayout.SetReboundInterpolator(new ElasticOutInterpolator()); //设置回弹插值器,会带有弹簧震动效果
            mRefreshLayout.SetReboundDuration(800);                              //设置回弹动画时长
            mRefreshLayout.SetOnRefreshListener(new CustomOnRefreshListener(this));

            //设置 让 AppBarLayout 和 RefreshLayout 的滚动同步 并不保持 toolbar 位置不变
            appBar = FindViewById <AppBarLayout>(Resource.Id.app_bar);
            mRefreshLayout.SetOnMultiPurposeListener(new CustomOnMultiPurposeListener(this));

            /************************************************************
            * 关键代码-结束
            ************************************************************/

            mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout;
            if (isFirstEnter)
            {
                isFirstEnter = false;
                mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果
            }

            /**
             * 初始化列表数据
             */
            initDataSet();
            mAdapter       = new ItemAdapter(this);
            mLayoutManager = new LinearLayoutManager(this);
            mListView      = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            mListView.SetLayoutManager(mLayoutManager);
            mListView.SetAdapter(mAdapter);
            mListView.SetItemAnimator(new SampleItemAnimator());
            mToolbarLayout = FindViewById <CollapsingToolbarLayout>(Resource.Id.toolbar_layout);
            mActionButton  = FindViewById <FloatingActionButton>(Resource.Id.fab);
            //设置点击 ActionButton 时候触发自动刷新 并改变主题颜色
            mActionButton.Click += (sender, e) => {
                updateTheme();
                mRefreshLayout.AutoRefresh();
            };

            // 监听 AppBarLayout 的关闭和开启 给 FlyView(纸飞机) 和 ActionButton 设置关闭隐藏动画
            appBar.OffsetChanged += (sender, e) => {
                var   appBarLayout   = e.AppBarLayout;
                var   verticalOffset = e.VerticalOffset;
                int   scrollRange    = appBarLayout.TotalScrollRange;
                float fraction       = 1f * (scrollRange + verticalOffset) / scrollRange;
                if (fraction < 0.1 && misAppbarExpand)
                {
                    misAppbarExpand = false;
                    mActionButton.Animate().ScaleX(0).ScaleY(0);
                    mFlyView.Animate().ScaleX(0).ScaleY(0);
                    ValueAnimator animator = ValueAnimator.OfInt(mListView.PaddingTop, 0);
                    animator.SetDuration(300);
                    animator.Update += (senderr, ee) => {
                        mListView.SetPadding(0, (int)ee.Animation.AnimatedValue, 0, 0);
                    };
                    animator.Start();
                }
                if (fraction > 0.8 && !misAppbarExpand)
                {
                    misAppbarExpand = true;
                    mActionButton.Animate().ScaleX(1).ScaleY(1);
                    mFlyView.Animate().ScaleX(1).ScaleY(1);
                    ValueAnimator animator = ValueAnimator.OfInt(mListView.PaddingTop, DensityUtil.Dp2px(25));
                    animator.SetDuration(300);
                    animator.Update += (senderr, ee) => {
                        mListView.SetPadding(0, (int)ee.Animation.AnimatedValue, 0, 0);
                    };
                    animator.Start();
                }
            };

            //状态栏透明和间距处理
            StatusBarUtil.immersive(this);
            StatusBarUtil.setPaddingSmart(this, toolbar);
            //        StatusBarUtil.setPaddingSmart(this, findViewById(R.id.profile));
            //        StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurview));
        }