コード例 #1
0
ファイル: PropertyDialog.cs プロジェクト: MassVOiD/FamiStudio
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var info = FamiStudioForm.Instance != null ? FamiStudioForm.Instance.ActiveDialog as PropertyDialogActivityInfo : null;

            if (savedInstanceState != null || info == null)
            {
                Finish();
                return;
            }

            dlg = info.Dialog;
            dlg.CloseRequested += Dlg_CloseRequested;

            var appBarLayoutParams = new AppBarLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, DroidUtils.GetSizeAttributeInPixel(this, Android.Resource.Attribute.ActionBarSize));

            appBarLayoutParams.ScrollFlags = 0;

            toolbar = new AndroidX.AppCompat.Widget.Toolbar(new ContextThemeWrapper(this, Resource.Style.ToolbarTheme));
            toolbar.LayoutParameters = appBarLayoutParams;
            toolbar.SetTitleTextAppearance(this, Resource.Style.LightGrayTextMediumBold);
            SetSupportActionBar(toolbar);

            ActionBar actionBar = SupportActionBar;

            if (actionBar != null)
            {
                actionBar.SetDisplayHomeAsUpEnabled(true);
                actionBar.SetHomeButtonEnabled(true);
                actionBar.SetHomeAsUpIndicator(Android.Resource.Drawable.IcMenuCloseClearCancel);
                actionBar.Title = dlg.Title;
            }

            appBarLayout = new AppBarLayout(this);
            appBarLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            appBarLayout.AddView(toolbar);

            fragmentView = new FragmentContainerView(this);
            fragmentView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            fragmentView.Id = FragmentViewId;

            var scrollViewLayoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            scrollViewLayoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior(this, null);

            scrollView = new NestedScrollView(new ContextThemeWrapper(this, Resource.Style.DarkBackgroundStyle));
            scrollView.LayoutParameters = scrollViewLayoutParams;
            scrollView.AddView(fragmentView);

            coordLayout = new CoordinatorLayout(this);
            coordLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            coordLayout.AddView(appBarLayout);
            coordLayout.AddView(scrollView);

            SetContentView(coordLayout);

            SupportFragmentManager.BeginTransaction().SetReorderingAllowed(true).Add(fragmentView.Id, dlg.Properties, "PropertyDialog").Commit();
        }
コード例 #2
0
ファイル: MainActivity.cs プロジェクト: mmdmine/Unfollow
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            _appBar          = FindViewById <Toolbar>(Resource.Id.main_appbar);
            _navBar          = FindViewById <BottomNavigationView>(Resource.Id.main_navbar);
            _mainContainer   = FindViewById <FragmentContainerView>(Resource.Id.main_container);
            _loadingView     = FindViewById(Resource.Id.main_loading_view);
            _emptyView       = FindViewById(Resource.Id.main_empty_view);
            _errorView       = FindViewById(Resource.Id.main_error_view);
            _currentPackage  = PackageManager?.GetPackageInfo(PackageName, 0);
            _retryButton     = FindViewById <Button>(Resource.Id.fragment_recyclerview_error_retry);
            _emptyTextView   = FindViewById <TextView>(Resource.Id.fragment_recyclerview_empty_text);
            _errorTextView   = FindViewById <TextView>(Resource.Id.fragment_recyclerview_error_text);
            _loadingTextView = FindViewById <TextView>(Resource.Id.fragment_recyclerview_loading_textview);
            _emptyImageView  = FindViewById <ImageView>(Resource.Id.fragment_recyclerview_empty_image);
            _errorImageView  = FindViewById <ImageView>(Resource.Id.fragment_recyclerview_error_image);

            SetSupportActionBar(_appBar);
            SupportFragmentManager.BackStackChanged += OnBackStackChanged;
            _navBar.NavigationItemSelected          += Navbar_NavigationItemSelected;
            _retryButton.Click += RetryButton_Click;

            // Work around for white icons on white background
            // on status bar and navigation bar on older versions of Android
            if (Build.VERSION.SdkInt < BuildVersionCodes.M)
            {
                Window?.SetStatusBarColor(Color.Black);
            }
            if (Build.VERSION.SdkInt < BuildVersionCodes.OMr1)
            {
                Window?.SetNavigationBarColor(Color.Black);
            }

            var accountsDir = ((IDataStorage)this).GetAccountsDir();
            var cacheDir    = ((IDataStorage)this).GetCacheDir();

            if (accountsDir == null ||
                cacheDir == null)
            {
                // TODO: Panic
                return;
            }

            _accounts = new Accounts(accountsDir, cacheDir);

            _client = new HttpClient();

            if (savedInstanceState != null)
            {
                // TODO: Load Accounts Data

                if (SupportFragmentManager.BackStackEntryCount > 0)
                {
                    SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                    _navBar.Visibility = ViewStates.Gone;
                }

                ((IFragmentContainer)this).ShowContentView();

                return;
            }

            BeginTransition();
            SupportFragmentManager
            .BeginTransaction()
            .Add(Resource.Id.main_container, _accountsFragment)
            .Commit();
        }