Esempio n. 1
0
        // Inicializa o itemUtilizador e o cabecalhoDrawer cabeçalho do "drawer" lateral.
        private void InicializarCabecalho(string email, Bundle estadoGravado)
        {
            itemUtilizador = new ProfileDrawerItem();
            itemUtilizador.WithName(email.Equals("") ? "Não Autenticado" : "Email");
            itemUtilizador.WithIcon(Resource.Drawable.profile3);
            itemUtilizador.WithIdentifier(email.Equals("") ? PERFIL_NAO_AUTENTICADO : AUTENTICADO);
            if (!email.Equals(""))
            {
                itemUtilizador.WithEmail(email);
            }

            cabecalhoDrawer = new AccountHeaderBuilder()
                              .WithActivity(this)
                              .WithHeaderBackground(Resource.Drawable.header)
                              .AddProfiles(itemUtilizador)
                              .WithSelectionListEnabledForSingleProfile(false)
                              .WithOnAccountHeaderListener(this)
                              .WithSavedInstance(estadoGravado)
                              .Build();
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            receiver = new NetworkBroadcastReceiver(this);
            receiver.SetListener(this);
            intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
            RegisterReceiver(receiver, intentFilter);

            tvNetworkNotification = (TextView)FindViewById(Resource.Id.network_notification);
            ConnectivityManager cm = (ConnectivityManager)this.GetSystemService(Context.ConnectivityService);

            if (cm.ActiveNetworkInfo == null)
            {
                var ad = new Android.Support.V7.App.AlertDialog.Builder(this);
                ad.SetTitle("No Connection");
                ad.SetMessage("Looks like there's a problem with your network connection. Try again later.");
                ad.SetCancelable(false);
                ad.SetPositiveButton("OK", this);
                Android.Support.V7.App.AlertDialog dialog = ad.Create();
                dialog.Show();
            }
            else
            {
                MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.googlemap);
                mapFragment.GetMapAsync(this);

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

                // Deserialize the member object
                ISharedPreferences pref = GetSharedPreferences(GetString(Resource.String.PreferenceFileName), FileCreationMode.Private);
                var member = pref.GetString(GetString(Resource.String.PreferenceSavedMember), "");
                user = JsonConvert.DeserializeObject <Member>(member);

                var profile = new ProfileDrawerItem();
                profile.WithName(user.username);
                profile.WithIdentifier(100);

                headerResult = new AccountHeaderBuilder()
                               .WithActivity(this)
                               .WithHeaderBackground(Resource.Drawable.profilebackground)
                               .WithSelectionListEnabledForSingleProfile(false)
                               .AddProfiles(profile)
                               .WithOnAccountHeaderListener(this)
                               .WithSavedInstance(bundle)
                               .Build();

                var header = new PrimaryDrawerItem();
                header.WithName(Resource.String.Drawer_Item_Trips);
                header.WithIcon(GoogleMaterial.Icon.GmdDirectionsCar);
                header.WithIdentifier(1);

                var logoutDrawer = new SecondaryDrawerItem();
                logoutDrawer.WithName(Resource.String.Drawer_Item_Logout);
                logoutDrawer.WithIcon(GoogleMaterial.Icon.GmdSettingsPower);
                logoutDrawer.WithIdentifier(4);

                //create the drawer and remember the `Drawer` result object
                Drawer result = new DrawerBuilder()
                                .WithActivity(this)
                                .WithToolbar(toolbar)
                                .WithAccountHeader(headerResult)
                                .AddDrawerItems(
                    header,
                    new DividerDrawerItem(),
                    logoutDrawer
                    )
                                .WithOnDrawerItemClickListener(this)
                                .Build();

                originAutocompleteFragment = (PlaceAutocompleteFragment)
                                             FragmentManager.FindFragmentById(Resource.Id.place_autocomplete_origin_fragment);
                originAutocompleteFragment.SetHint("Enter the origin");
                originAutocompleteFragment.PlaceSelected += OnOriginSelected;

                destAutocompleteFragment = (PlaceAutocompleteFragment)
                                           FragmentManager.FindFragmentById(Resource.Id.place_autocomplete_destination_fragment);
                destAutocompleteFragment.SetHint("Enter the destination");
                destAutocompleteFragment.PlaceSelected += OnDestinationSelected;

                progress = new ProgressDialog(this);
                progress.Indeterminate = true;
                progress.SetProgressStyle(ProgressDialogStyle.Spinner);
                progress.SetMessage("Getting location...");
                progress.SetCancelable(false);
                RunOnUiThread(() =>
                {
                    progress.Show();
                });

                // Request Update request
                locationManager = (LocationManager)GetSystemService(Context.LocationService);
                IList <string> providers    = locationManager.AllProviders;
                Criteria       criteria     = new Criteria();
                string         bestProvider = locationManager.GetBestProvider(criteria, true);
                locationManager.RequestLocationUpdates(bestProvider, MIN_TIME, MIN_DISTANCE, this);
            }
        }
        private async void BuildDrawer()
        {
            var builder = new DrawerBuilder().WithActivity(this);
            builder.WithSliderBackgroundColorRes(Resource.Color.BrushHamburgerBackground);
            builder.WithStickyFooterShadow(true);


            var animeButton = GetBasePrimaryItem();
            animeButton.WithName("Anime list");
            animeButton.WithIdentifier((int)PageIndex.PageAnimeList);
            animeButton.WithIcon(Resource.Drawable.icon_list);

            var searchButton = GetBasePrimaryItem();
            searchButton.WithName("Anime search");
            searchButton.WithIdentifier((int)PageIndex.PageSearch);
            searchButton.WithIcon(Resource.Drawable.icon_search);

            var seasonalButton = GetBasePrimaryItem();
            seasonalButton.WithName("Seasonal anime");
            seasonalButton.WithIdentifier((int)PageIndex.PageSeasonal);
            seasonalButton.WithIcon(Resource.Drawable.icon_seasonal);

            var recomButton = GetBasePrimaryItem();
            recomButton.WithName("Recommendations");
            recomButton.WithIdentifier((int)PageIndex.PageRecomendations);
            recomButton.WithIcon(Resource.Drawable.icon_recom);

            var topAnimeButton = GetBasePrimaryItem();
            topAnimeButton.WithName("Top anime");
            topAnimeButton.WithIdentifier((int)PageIndex.PageTopAnime);
            topAnimeButton.WithIcon(Resource.Drawable.icon_fav_outline);

            var calendarButton = GetBasePrimaryItem();
            calendarButton.WithName("Calendar");
            calendarButton.WithIdentifier((int)PageIndex.PageCalendar);
            calendarButton.WithIcon(Resource.Drawable.icon_calendar);

            //

            var mangaListButton = GetBaseSecondaryItem();
            mangaListButton.WithName("Manga list");
            mangaListButton.WithIdentifier((int)PageIndex.PageMangaList);
            mangaListButton.WithIcon(Resource.Drawable.icon_books);

            var mangaSearchButton = GetBaseSecondaryItem();
            mangaSearchButton.WithName("Manga search");
            mangaSearchButton.WithIdentifier((int)PageIndex.PageMangaSearch);
            mangaSearchButton.WithIcon(Resource.Drawable.icon_search);

            var topMangaButton = GetBaseSecondaryItem();
            topMangaButton.WithName("Top manga");
            topMangaButton.WithIdentifier((int)PageIndex.PageTopManga);
            topMangaButton.WithIcon(Resource.Drawable.icon_fav_outline);

            //

            IDrawerItem accountButton;
            if (Credentials.Authenticated)
            {
                var btn = new ProfileDrawerItem();
                btn.WithName("Account");
                btn.WithTextColorRes(Resource.Color.BrushText);
                btn.WithSelectedColorRes(Resource.Color.BrushAnimeItemBackground);
                btn.WithSelectedTextColorRes(Resource.Color.AccentColour);
                btn.WithIdentifier((int)PageIndex.PageProfile);
                btn.WithIcon(Resource.Drawable.icon_account);
                accountButton = btn;
            }
            else
            {
                var btn = GetBaseSecondaryItem();
                btn.WithName("Sign in");
                btn.WithIdentifier((int)PageIndex.PageLogIn);
                btn.WithIcon(Resource.Drawable.icon_login);
                accountButton = btn;
            }

            var settingsButton = GetBaseSecondaryItem();
            settingsButton.WithName("Settings & more");
            settingsButton.WithIdentifier((int)PageIndex.PageSettings);
            settingsButton.WithIcon(Resource.Drawable.icon_settings);



            builder.AddStickyDrawerItems(accountButton, settingsButton);


            //

            var mangaSubHeader = new SectionDrawerItem();
            mangaSubHeader.WithName("Manga");
            mangaSubHeader.WithDivider(true);
            mangaSubHeader.WithTextColorRes(Resource.Color.BrushText);

            builder.WithDrawerItems(new List<IDrawerItem>()
            {
                animeButton,
                searchButton,
                seasonalButton,
                recomButton,
                topAnimeButton,
                calendarButton,
                mangaSubHeader,//
                mangaListButton,
                mangaSearchButton,
                topMangaButton,
            });

            _drawer = builder.Build();
            _drawer.StickyFooter.SetBackgroundColor(new Color(ResourceExtension.BrushAnimeItemInnerBackground));

            if (Credentials.Authenticated)
            {
                var bmp = await ImageService.Instance.LoadUrl(
                        $"https://myanimelist.cdn-dena.com/images/userimages/4952914.jpg")
                    .AsBitmapDrawableAsync();
                var btn = accountButton as ProfileDrawerItem;
                btn.WithIcon(bmp);
                _drawer.UpdateStickyFooterItem(btn);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_sample_dark_toolbar);

            var toolbar = this.FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            this.SetSupportActionBar(toolbar);

            // Create a few sample profile
            // NOTE you have to define the loader logic too. See the CustomApplication for more details

            var profile = new ProfileDrawerItem();

            profile.WithName("Mike Penz");
            profile.WithEmail("*****@*****.**");
            profile.WithIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460");
            profile.WithIdentifier(100);

            var profile2 = new ProfileDrawerItem();

            profile2.WithName("Bernat Borras");
            profile2.WithEmail("*****@*****.**");
            profile2.WithIcon(Uri.Parse("https://avatars3.githubusercontent.com/u/887462?v=3&s=460"));
            profile2.WithIdentifier(101);

            var profile3 = new ProfileDrawerItem();

            profile3.WithName("Max Muster");
            profile3.WithEmail("*****@*****.**");
            profile3.WithIcon(Resource.Drawable.profile2);
            profile3.WithIdentifier(102);

            var profile4 = new ProfileDrawerItem();

            profile4.WithName("Felix House");
            profile4.WithEmail("*****@*****.**");
            profile4.WithIcon(Resource.Drawable.profile3);
            profile4.WithIdentifier(103);

            var profile5 = new ProfileDrawerItem();

            profile5.WithName("Mr. X");
            profile5.WithEmail("*****@*****.**");
            profile5.WithIcon(Resource.Drawable.profile4);
            profile5.WithIdentifier(104);

            var profile6 = new ProfileDrawerItem();

            profile6.WithName("Batman");
            profile6.WithEmail("*****@*****.**");
            profile6.WithIcon(Resource.Drawable.profile5);
            profile6.WithIdentifier(105);

            var profileSettingItem = new ProfileSettingDrawerItem();

            profileSettingItem.WithName("Add Account");
            profileSettingItem.WithDescription("Add new GitHub Account");
            profileSettingItem.WithIcon(new IconicsDrawable(this, GoogleMaterial.Icon.GmdPlusOne).ActionBar().PaddingDp(5).ColorRes(Resource.Color.material_drawer_primary_text));
            profileSettingItem.WithIdentifier(PROFILE_SETTING);

            headerResult = new AccountHeaderBuilder()
                           .WithActivity(this)
                           .WithHeaderBackground(Resource.Drawable.header)
                           .AddProfiles(
                profile,
                profile2,
                profile3,
                profile4,
                profile5,
                profile6,
                //don't ask but google uses 14dp for the add account icon in gmail but 20dp for the normal icons (like manage account)
                profileSettingItem,
                new ProfileSettingDrawerItem()
                .WithName("Manage Account")
                .WithIcon(GoogleMaterial.Icon.GmdSettings)
                )
                           .WithOnAccountHeaderListener(this)
                           .WithSavedInstance(savedInstanceState)
                           .Build();

            var item1 = new PrimaryDrawerItem();

            item1.WithName(Resource.String.drawer_item_compact_header);
            item1.WithIcon(GoogleMaterial.Icon.GmdWbSunny);
            item1.WithIdentifier(1);
            item1.WithSelectable(false);
//
            var item2 = new PrimaryDrawerItem();

            item2.WithName(Resource.String.drawer_item_action_bar_drawer);
            item2.WithIcon(FontAwesome.Icon.FawHome);
            item2.WithIdentifier(2);
            item2.WithSelectable(false);
//
            var item10 = new SecondaryDrawerItem();

            item10.WithName(Resource.String.drawer_item_open_source);
            item10.WithIcon(FontAwesome.Icon.FawGithub);
            item10.WithIdentifier(20);
            item10.WithSelectable(false);
//
            var item11 = new SecondaryDrawerItem();

            item11.WithName(Resource.String.drawer_item_contact);
            item11.WithIcon(GoogleMaterial.Icon.GmdFormatColorFill);
            item11.WithIdentifier(10);
            item11.WithTag("Bullhorn");

//
            result = new DrawerBuilder()
                     .WithActivity(this)
                     .WithToolbar(toolbar)
                     .WithAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
                     .AddDrawerItems(
                item1,
                item2,
                new SectionDrawerItem().WithName(Resource.String.drawer_item_section_header),
                item10,
                item11,
                new DividerDrawerItem()
                ) // add the items we want to use With our Drawer
                     .WithOnDrawerItemClickListener(this)
                     .WithSavedInstance(savedInstanceState)
                     .WithShowDrawerOnFirstLaunch(true)
                     .Build();

            //if you have many different types of DrawerItems you can magically pre-cache those items to get a better scroll performance
            //make sure to init the cache after the DrawerBuilder was created as this will first clear the cache to make sure no old elements are in
            RecyclerViewCacheUtil.Instance.WithCacheSize(2).Init(result);

            //only set the active selection or active profile if we do not recreate the activity
            if (savedInstanceState == null)
            {
                // set the selection to the item with the identifier 11
                result.SetSelection(21, false);

                //set the active profile
                headerResult.SetActiveProfile(profile3, false);
            }

            result.UpdateBadge(4, new StringHolder(10 + ""));
        }
Esempio n. 5
0
        private async void BuildDrawer()
        {
            var builder = new DrawerBuilder().WithActivity(this);

            builder.WithSliderBackgroundColorRes(ResourceExtension.BrushHamburgerBackgroundRes);
            builder.WithStickyFooterShadow(true);
            builder.WithDisplayBelowStatusBar(true);


            var animeButton = GetBasePrimaryItem();

            animeButton.WithName("Anime list");
            animeButton.WithIdentifier((int)PageIndex.PageAnimeList);
            animeButton.WithIcon(Resource.Drawable.icon_list);

            var searchButton = GetBasePrimaryItem();

            searchButton.WithName("Anime search");
            searchButton.WithIdentifier((int)PageIndex.PageSearch);
            searchButton.WithIcon(Resource.Drawable.icon_search);

            var seasonalButton = GetBasePrimaryItem();

            seasonalButton.WithName("Seasonal anime");
            seasonalButton.WithIdentifier((int)PageIndex.PageSeasonal);
            seasonalButton.WithIcon(Resource.Drawable.icon_seasonal);

            var recomButton = GetBasePrimaryItem();

            recomButton.WithName("Recommendations");
            recomButton.WithIdentifier((int)PageIndex.PageRecomendations);
            recomButton.WithIcon(Resource.Drawable.icon_recom);

            var topAnimeButton = GetBasePrimaryItem();

            topAnimeButton.WithName("Top anime");
            topAnimeButton.WithIdentifier((int)PageIndex.PageTopAnime);
            topAnimeButton.WithIcon(Resource.Drawable.icon_fav_outline);

            var calendarButton = GetBasePrimaryItem();

            calendarButton.WithName("Calendar");
            calendarButton.WithIdentifier((int)PageIndex.PageCalendar);
            calendarButton.WithIcon(Resource.Drawable.icon_calendar);

            //

            var mangaListButton = GetBaseSecondaryItem();

            mangaListButton.WithName("Manga list");
            mangaListButton.WithIdentifier((int)PageIndex.PageMangaList);
            mangaListButton.WithIcon(Resource.Drawable.icon_books);

            var topMangaButton = GetBaseSecondaryItem();

            topMangaButton.WithName("Top manga");
            topMangaButton.WithIdentifier((int)PageIndex.PageTopManga);
            topMangaButton.WithIcon(Resource.Drawable.icon_fav_outline);

            var articlesButton = GetBaseSecondaryItem();

            articlesButton.WithName("Articles & News");
            articlesButton.WithIdentifier((int)PageIndex.PageArticles);
            articlesButton.WithIcon(Resource.Drawable.icon_newspaper);

            var videoButton = GetBaseSecondaryItem();

            videoButton.WithName("Promotional Videos");
            videoButton.WithIdentifier((int)PageIndex.PagePopularVideos);
            videoButton.WithIcon(Resource.Drawable.icon_video);

            var feedsButton = GetBaseSecondaryItem();

            feedsButton.WithName("Friends Feeds");
            feedsButton.WithIdentifier((int)PageIndex.PageFeeds);
            feedsButton.WithIcon(Resource.Drawable.icon_feeds);

            var forumsButton = GetBaseSecondaryItem();

            forumsButton.WithName("Friends Feeds");
            forumsButton.WithIdentifier((int)PageIndex.PageForumIndex);
            forumsButton.WithIcon(Resource.Drawable.icon_feeds);

            //

            IDrawerItem accountButton;

            if (Credentials.Authenticated)
            {
                var btn = new ProfileDrawerItem();
                btn.WithName("Account");
                btn.WithTextColorRes(ResourceExtension.BrushTextRes);
                btn.WithSelectedColorRes(ResourceExtension.BrushAnimeItemBackgroundRes);
                btn.WithSelectedTextColorRes(Resource.Color.AccentColour);
                btn.WithIdentifier((int)PageIndex.PageProfile);
                btn.WithIcon(Resource.Drawable.icon_account);
                accountButton = btn;
            }
            else
            {
                var btn = GetBaseSecondaryItem();
                btn.WithName("Sign in");
                btn.WithIdentifier((int)PageIndex.PageLogIn);
                btn.WithIcon(Resource.Drawable.icon_login);
                accountButton = btn;
            }

            var settingsButton = GetBaseSecondaryItem();

            settingsButton.WithName("Settings & more");
            settingsButton.WithIdentifier((int)PageIndex.PageSettings);
            settingsButton.WithIcon(Resource.Drawable.icon_settings);



            builder.AddStickyDrawerItems(accountButton, settingsButton);
            //
            var mangaSubHeader = new SectionDrawerItem();

            mangaSubHeader.WithName("Manga");
            mangaSubHeader.WithDivider(true);
            mangaSubHeader.WithTextColorRes(ResourceExtension.BrushTextRes);


            var othersSubHeader = new SectionDrawerItem();

            othersSubHeader.WithName("Other");
            othersSubHeader.WithDivider(true);
            othersSubHeader.WithTextColorRes(ResourceExtension.BrushTextRes);


            builder.WithDrawerItems(new List <IDrawerItem>()
            {
                animeButton,
                searchButton,
                seasonalButton,
                recomButton,
                topAnimeButton,
                calendarButton,
                mangaSubHeader,//
                mangaListButton,
                topMangaButton,
                othersSubHeader,//
                articlesButton,
                videoButton,
                feedsButton,
                forumsButton
            });

            _drawer = builder.Build();
            _drawer.StickyFooter.SetBackgroundColor(new Color(ResourceExtension.BrushAnimeItemInnerBackground));

            if (Credentials.Authenticated)
            {
                var bmp = await ImageService.Instance.LoadUrl(
                    $"https://myanimelist.cdn-dena.com/images/userimages/{Credentials.Id}.jpg")
                          .AsBitmapDrawableAsync();

                var btn = accountButton as ProfileDrawerItem;
                btn.WithIcon(bmp);
                _drawer.UpdateStickyFooterItem(btn);
            }
        }