Beispiel #1
0
        public FavoritesTests()
        {
            TestsData testsData = TestsData.Create(nameof(FavoritesTests));

            fillTestDbHelper = testsData.FillTestDbHelper;
            favoritesService = testsData.AppServiceProvider.FavoritesService;
        }
Beispiel #2
0
        public async Task <ActionResult> UpdateFavourite(int id, string returnUrl, [FromServices] IFavoritesService _favoriteService)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(Redirect("/Identity/Account/Errors/AccessDenied"));
            }

            if (!(await _favoriteService.isInFavourite(user, PostType.Company, id)))
            {
                await _favoriteService.AddToFavourite(user, PostType.Company, id.ToString());
            }
            else
            {
                await _favoriteService.RemoveFromFavourite(user, PostType.Company, id.ToString());
            }

            if (!String.IsNullOrEmpty(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
 public FavoritesViewModel(IFavoritesService favoritesService, IDialogService dialogService, INavigationService navigationService)
 {
     _favoritesService = favoritesService;
     _dialogService = dialogService;
     _navigationService = navigationService;
     Init();
 }
Beispiel #4
0
 public PatternDetailViewModel(IPatternClient client, IFavoritesService favoritesService, IImageService imageService, IMvxMessenger messenger)
 {
     _client           = client;
     _favoritesService = favoritesService;
     _imageService     = imageService;
     _messenger        = messenger;
 }
Beispiel #5
0
 public LikeOfferCommand(IFavoritesService favoritesService, IMapper mapper, INotifier notifier, IHubManager <NotifierHub> hubManager)
 {
     this.favoritesService = favoritesService;
     this.mapper           = mapper;
     this.notifier         = notifier;
     this.hubManager       = hubManager;
 }
        public ContestantsController(
            IHttpContextAccessor httpContext,
            UserManager <User> userManager,
            IBaseService baseService,
            ICipherService chipherService,
            INotificationService notifyService,
            IContestantsService contestantsService,
            ICategoriesService categoriesService,
            ISkillsService skillsService,
            ILocationService locationService,
            ILanguageService langService,
            IFavoritesService favoriteService)
        {
            _httpcontext    = httpContext;
            _userManager    = userManager;
            _baseService    = baseService;
            _chipherService = chipherService;

            _notifyService      = notifyService;
            _contestantsService = contestantsService;
            _categoriesService  = categoriesService;

            _skillsService   = skillsService;
            _locationService = locationService;
            _langService     = langService;
            _favoriteService = favoriteService;
        }
Beispiel #7
0
 public PhotoFavorite(
     IFavoritesService favoritesService,
     UserManager <User> userManager)
 {
     this.favoritesService = favoritesService;
     this.userManager      = userManager;
 }
Beispiel #8
0
 public JobsController(
     FeaturesDbContext context,
     UserManager <User> userManager,
     IBaseService baseService,
     IJobsService jobsService,
     ICategoriesService categoriesService,
     ILocationService locationService,
     ISkillsService skillsService,
     ILanguageService langService,
     ICompanyService companyService,
     IFavoritesService favoriteService,
     INotificationService notifyService,
     IToastNotification toastNotification,
     IResumeService resumeService)
 {
     _context           = context;
     _userManager       = userManager;
     _baseService       = baseService;
     _jobsService       = jobsService;
     _locationService   = locationService;
     _skillsService     = skillsService;
     _langService       = langService;
     _categoriesService = categoriesService;
     _companyService    = companyService;
     _favoriteService   = favoriteService;
     _notifyService     = notifyService;
     _toastNotification = toastNotification;
     _resumeService     = resumeService;
 }
Beispiel #9
0
 public FavoritesController(
     IFavoritesService favoritesService,
     UserManager <ApplicationUser> userManager)
 {
     this.favoritesService = favoritesService;
     this.userManager      = userManager;
 }
Beispiel #10
0
 public FavoritesViewModel(IFavoritesService favoritesService, IDialogService dialogService, INavigationService navigationService)
 {
     _favoritesService  = favoritesService;
     _dialogService     = dialogService;
     _navigationService = navigationService;
     Init();
 }
        public FavoritesViewModel(IFavoritesService favoritesService, IMvxMessenger messenger)
        {
            _favoritesService = favoritesService;
            _messenger        = messenger;
            _token            = messenger.Subscribe <FavoritesChangedMessage>(ServiceOnFavoritesSessionsChanged);

            Load();
        }
Beispiel #12
0
 public FavoritesController(IFavoritesService favoritesService,
                            IFavoritesValidationService favoritesValidationService,
                            IDiscountValidationService discountValidationService)
 {
     _favoritesService           = favoritesService;
     _favoritesValidationService = favoritesValidationService;
     _discountValidationService  = discountValidationService;
 }
 public ArticleController(IArticleService artService, IUserService uService, IFavoritesService favoritesService, ICommentService commentService, ICustomCategoryService customCategoryService, ICategoryService categoryService)
 {
     userService                = uService;
     articleService             = artService;
     base.commentService        = commentService;
     base.favoritesService      = favoritesService;
     base.customCategoryService = customCategoryService;
     base.categoryService       = categoryService;
 }
Beispiel #14
0
        public void Favorites_TestIdListInput_ReturnsFavoritesListWithSameCountAsInput()
        {
            mockService.Setup(fp => fp.getFavorites(testFavoriteIdList)).Returns(getFavorites(testFavoriteIdList));
            favoritesService = mockService.Object;

            FavoritesModel favoritesModel = new FavoritesModel(favoritesService, testFavoriteIdList);
            List<Favorite> favoritesList = favoritesModel.Favorites;
            Assert.AreEqual(testFavoriteIdList.Length, favoritesList.Count);
        }
Beispiel #15
0
 public ProductsController(IProductService productService, IMapper mapper,
                           IClientService clientService, IFavoritesService favoritesService, ICategoryService categoryService)
 {
     this.productService   = productService;
     _mapper               = mapper;
     this.clientService    = clientService;
     this.favoritesService = favoritesService;
     this.categoryService  = categoryService;
 }
 public ShellModuleService([ServiceDependency] IFavoritesService favoritesService, [ServiceDependency] IAuthorizationService authorizationService, [ServiceDependency] IUserSessionService userSessionService)
 {
     _modelDictionary      = new Dictionary <IShellModule, IShellPresentationModel>();
     _workItemDictionary   = new Dictionary <IShellModule, WorkItem>();
     _config               = ConfigurationManager.GetSection(ShellConfigurationSection.SectionKey) as ShellConfigurationSection;
     _favoritesService     = favoritesService;
     _authorizationService = authorizationService;
     _userSessionService   = userSessionService;
 }
Beispiel #17
0
        public async Task AddToFavoritesAsync_WithAdAlreadyInFavorites_ShouldThrowAnInvalidOperationException()
        {
            //Arrange
            var expectedErrorMessage = "The given ad is already added to favorites!";
            var context = InitializeContext.CreateContextForInMemory();

            var moqUserService = new Mock <IUsersService>();

            moqUserService.Setup(x => x.GetCurrentUserAsync())
            .ReturnsAsync(new SellMeUser
            {
                Id       = Guid.NewGuid().ToString(),
                UserName = "******",
                SellMeUserFavoriteProducts = new List <SellMeUserFavoriteProduct>
                {
                    new SellMeUserFavoriteProduct
                    {
                        AdId = 1
                    }
                }
            });

            favoritesService = new FavoritesService(context, moqUserService.Object);
            var testingAd = new Ad
            {
                Id                = 1,
                Title             = "Iphone 6s",
                Description       = "PerfectCondition",
                ActiveFrom        = DateTime.UtcNow,
                ActiveTo          = DateTime.UtcNow.AddDays(30),
                AvailabilityCount = 1,
                Price             = 120,
                Condition         = new Condition {
                    Name = "Brand New"
                },
                Address = new Address
                {
                    Country      = "Bulgaria",
                    City         = "Sofia",
                    Street       = "Ivan Vazov",
                    District     = "Student city",
                    ZipCode      = 1000,
                    PhoneNumber  = "0895335532",
                    EmailAddress = "*****@*****.**"
                }
            };

            await context.Ads.AddAsync(testingAd);

            await context.SaveChangesAsync();

            //Act and assert
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => favoritesService.AddToFavoritesAsync(1));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
 static DigiTransitSearchBox()
 {
     if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
     {
         return;
     }
     _networkService   = ServiceLocator.Current.GetInstance <INetworkService>();
     _settingsService  = ServiceLocator.Current.GetInstance <SettingsService>();
     _favoritesService = ServiceLocator.Current.GetInstance <IFavoritesService>();
 }
Beispiel #19
0
 public MainPageViewModel(IFavoritesService favoritesService, Dispatcher dispatcher)
 {
     if (favoritesService == null || dispatcher == null)
     {
         throw new ArgumentNullException();
     }
     this.favoritesService = favoritesService;
     this.Dispatcher = dispatcher;
     this.favoritesService.GetFavoriteListingsOfUserCompleted += CompletedGetFavorites;
 }
Beispiel #20
0
        public void Favorites_EmptyStringParameter_ReturnsEmptyFavoritesList()
        {
            testFavoriteIdList = new string[] { "" };

            mockService.Setup(fp => fp.getFavorites(testFavoriteIdList)).Returns(getFavorites(testFavoriteIdList));
            favoritesService = mockService.Object;

            FavoritesModel favoritesModel = new FavoritesModel(favoritesService, testFavoriteIdList);
            List<Favorite> favoritesList = favoritesModel.Favorites;
            Assert.IsNotNull(favoritesList);
        }
Beispiel #21
0
        public TripResultViewModel(INetworkService networkService, IMessenger messengerService, SettingsService settings,
                                   IFavoritesService favorites, IFileService fileService)
        {
            _networkService   = networkService;
            _messengerService = messengerService;
            _settingsService  = settings;
            _favoritesService = favorites;
            _fileService      = fileService;

            _messengerService.Register <MessageTypes.PlanFoundMessage>(this, PlanFound);
        }
 public ChangeNodeOperationsService(IAppServiceProvider appServiceProvider, IDbContextFactory <MessengerDbContext> contextFactory)
 {
     createChatsService    = appServiceProvider.CreateChatsService;
     createMessagesService = appServiceProvider.CreateMessagesService;
     updateUsersService    = appServiceProvider.UpdateUsersService;
     createChannelsService = appServiceProvider.CreateChannelsService;
     contactsService       = appServiceProvider.ContactsService;
     groupsService         = appServiceProvider.GroupsService;
     favoritesService      = appServiceProvider.FavoritesService;
     this.contextFactory   = contextFactory;
 }
Beispiel #23
0
        public FavoritesViewModel(INetworkService networkService, IMessenger messengerService,
                                  IFavoritesService favoritesService, ITileService tileService, IDialogService dialogService)
        {
            _networkService   = networkService;
            _messengerService = messengerService;
            _favoritesService = favoritesService;
            _settingsService  = SimpleIoc.Default.GetInstance <SettingsService>();
            _tileService      = tileService;
            _dialogService    = dialogService;

            Favorites.Add(GroupedFavoritePlaces);
            Favorites.Add(GroupedFavoriteRoutes);
        }
Beispiel #24
0
 public ClientController(IClientService clientService, UserManager <IdentityUser> userManager,
                         ILocationService locationService, IOrderService orderService, IFavoritesService favoritesService,
                         ICartProductService cartProductService, IRatingService ratingService, IAdminService adminService)
 {
     this.clientService      = clientService;
     _userManager            = userManager;
     this.locationService    = locationService;
     this.orderService       = orderService;
     this.favoritesService   = favoritesService;
     this.cartProductService = cartProductService;
     this.ratingService      = ratingService;
     this.adminService       = adminService;
 }
 public _ActivityViewComponent(
     IConfiguration config,
     UserManager <User> userManager,
     INotificationService notifyService,
     IMessageService messageService,
     IFavoritesService favouriteService)
 {
     _config           = config;
     _userManager      = userManager;
     _notifyService    = notifyService;
     _messageService   = messageService;
     _favouriteService = favouriteService;
 }
Beispiel #26
0
 public UwpLegacyFileService(
     IDialogService dialogService,
     IFavoritesService favoritesService,
     ICategoriesRepository sourcesRepository,
     ITranslationsService translationsService,
     ISerializationService serializationService)
 {
     _favoritesService     = favoritesService;
     _serializationService = serializationService;
     _translationsService  = translationsService;
     _categoriesRepository = sourcesRepository;
     _dialogService        = dialogService;
 }
Beispiel #27
0
 public AutopartsController(
     IAutopartsService autopartsService,
     ICarsService carsService,
     IAutopartsCharacteristicsService autopartsCharacteristicsService,
     IWebHostEnvironment env,
     IFavoritesService favoritesService)
 {
     this.autopartsService = autopartsService;
     this.carsService      = carsService;
     this.autopartsCharacteristicsService = autopartsCharacteristicsService;
     this.env = env;
     this.favoritesService = favoritesService;
 }
 public ProfileController(
     IAlbumsService albumsService,
     IPhotoService photoService,
     IFavoritesService favoritesService,
     ITopicService topicService,
     UserManager <User> userManager)
 {
     this.albumsService    = albumsService;
     this.photoService     = photoService;
     this.favoritesService = favoritesService;
     this.topicService     = topicService;
     this.userManager      = userManager;
 }
Beispiel #29
0
        public async Task AddToFavoritesAsync_WithValidData_ShouldReturnTrue()
        {
            //Arrange
            var context = InitializeContext.CreateContextForInMemory();

            var moqUserService = new Mock <IUsersService>();

            moqUserService.Setup(x => x.GetCurrentUserAsync())
            .ReturnsAsync(new SellMeUser
            {
                Id       = Guid.NewGuid().ToString(),
                UserName = "******"
            });

            favoritesService = new FavoritesService(context, moqUserService.Object);
            var testingAd = new Ad
            {
                Id                = 1,
                Title             = "Iphone 6s",
                Description       = "PerfectCondition",
                ActiveFrom        = DateTime.UtcNow,
                ActiveTo          = DateTime.UtcNow.AddDays(30),
                AvailabilityCount = 1,
                Price             = 120,
                Condition         = new Condition {
                    Name = "Brand New"
                },
                Address = new Address
                {
                    Country      = "Bulgaria",
                    City         = "Sofia",
                    Street       = "Ivan Vazov",
                    District     = "Student city",
                    ZipCode      = 1000,
                    PhoneNumber  = "0895335532",
                    EmailAddress = "*****@*****.**"
                }
            };

            await context.Ads.AddAsync(testingAd);

            await context.SaveChangesAsync();

            //Act
            var actual = await favoritesService.AddToFavoritesAsync(1);

            //Assert
            Assert.True(actual);
        }
Beispiel #30
0
        public void PrepareShutdownEventHandler(object sender, PrepareShutdownEventArgs e)
        {
            var services = from m in ShellModuleService.Modules
                           select ShellModuleService.GetWorkItem(m).Services.Get <IShellInteractionService>() as ShellInteractionService;

            foreach (ShellInteractionService service in services)
            {
                service.OnShellTerminating(e);

                if (e.Cancel)
                {
                    return;
                }
            }

            if (e.Logout)
            {
                AppDomain.CurrentDomain.SetData("Logout", new object());
            }

            _shellView.ShowProgress();

            try
            {
                SettingsService.SaveSettings();

                IFavoritesService favoritesServices = WorkItem.RootWorkItem.Services.Get <IFavoritesService>();
                favoritesServices.SaveFavorites();
            }
            catch
            {
            }
            finally
            {
                _shellView.HideProgress();

                try
                {
                    foreach (ShellInteractionService service in services)
                    {
                        service.OnShellTerminated(new EventArgs());
                    }
                }
                finally
                {
                    //WorkItem.Services.Get<IChannelFactoryService>().Dispose();
                }
            }
        }
Beispiel #31
0
        public CloudService(IFavoritesService favoritesService)
        {
            _favoritesService = favoritesService;
            _favoritesService.FavoritesUpdated +=
                (s, e) => SaveFavoritesDocument();

            new Thread(
                new ThreadStart(() =>
            {
                var url   = NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null);
                _cloudUrl = url;
            })).Start();

            LoadFavorites();
        }
Beispiel #32
0
        public void Favorites_TestIdListInput_ReturnsFavoritesListWithSameIdsAndOrderAsInput()
        {
            mockService.Setup(fp => fp.getFavorites(testFavoriteIdList)).Returns(getFavorites(testFavoriteIdList));
            favoritesService = mockService.Object;

            FavoritesModel favoritesModel = new FavoritesModel(favoritesService, testFavoriteIdList);
            List<Favorite> favoritesList = favoritesModel.Favorites;

            for (int i = 0; i < testFavoriteIdList.Length; i++)
            {
                var inputId = testFavoriteIdList[i];
                var outputId = favoritesList[i].Id;
                Assert.AreEqual(inputId, outputId);
            }
        }
Beispiel #33
0
        public async Task AddToFavoritesAsync_WithCurrentUserEqualsToNull_ShouldThrowAndInvalidOperationException()
        {
            //Arrange
            var expectedErrorMessage = "Current user can't be null";
            var context = InitializeContext.CreateContextForInMemory();

            var moqUserService = new Mock <IUsersService>();

            favoritesService = new FavoritesService(context, moqUserService.Object);

            //Act and assert
            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => favoritesService.AddToFavoritesAsync(1));

            Assert.Equal(expectedErrorMessage, ex.Message);
        }
Beispiel #34
0
 public PhotoController(
     IWebHostEnvironment hostingEnvironment,
     UserManager <User> userManager,
     ILicenseService licenseService,
     IPhotoService photoService,
     IPhotoAlbumService photoAlbumService,
     IFavoritesService favoritesService)
 {
     this.hostingEnvironment = hostingEnvironment;
     this.userManager        = userManager;
     this.licenseService     = licenseService;
     this.photoService       = photoService;
     this.photoAlbumService  = photoAlbumService;
     this.favoritesService   = favoritesService;
 }
        /// <summary>
        /// Initializes a new instance of the DispatchedFavoritesService class
        /// </summary>
        /// <param name="wrappedService">the wrapped service</param>
        /// <param name="dispatcher">the thread dispatcher</param>
        public DispatchedFavoritesService(IFavoritesService wrappedService, Dispatcher dispatcher)
            : base(dispatcher)
        {
            if (wrappedService == null)
            {
                throw new ArgumentNullException("wrappedService");
            }

            this.wrappedService = wrappedService;

            this.wrappedService.GetFavorersOfListingCompleted += (s, e) => this.DispatchEvent(this.GetFavorersOfListingCompleted, s, e);
            this.wrappedService.GetFavorersOfShopCompleted += (s, e) => this.DispatchEvent(this.GetFavorersOfShopCompleted, s, e);
            this.wrappedService.GetFavoriteListingsOfUserCompleted += (s, e) => this.DispatchEvent(this.GetFavoriteListingsOfUserCompleted, s, e);
            this.wrappedService.GetFavoriteShopsOfUserCompleted += (s, e) => this.DispatchEvent(this.GetFavoriteShopsOfUserCompleted, s, e);
        }
        public FavoritesController(IFavoritesService favorites, IMapper mapper)
        {
            if (favorites == null)
            {
                throw new ArgumentNullException(nameof(favorites));
            }

            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }

            this.mapper    = mapper;
            this.favorites = favorites;
        }
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Favorites);

            // toolbar setup
            var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            favoritesListView = FindViewById<RecyclerView>(Resource.Id.FavoritesList);

            // use this setting to improve performance if you know that changes
            // in content do not change the layout size of the RecyclerView
            favoritesListView.HasFixedSize = true;
            // use a linear layout manager
            var layoutManager = new LinearLayoutManager(this);
            layoutManager.Orientation = (int)Orientation.Vertical;
            favoritesListView.SetLayoutManager(layoutManager);



            _favoritesService = SimpleIoc.Default.GetInstance<IFavoritesService>();
            _favorites = await _favoritesService.GetFavoritesAsync();

       
            // specify an adapter (see also next example)
            mAdapter = new FavoriteListAdapter(this, _favorites, this);
            favoritesListView.SetAdapter(mAdapter);
            favoritesListView.ChildViewRemoved += FavoritesListView_ChildViewRemoved;
            var callback = new SimpleItemTouchHelperCallback((IItemTouchHelperAdapter)mAdapter);
            _itemTouchHelper = new ItemTouchHelper(callback);
            _itemTouchHelper.AttachToRecyclerView(favoritesListView);

            _placeHolder = FindViewById<TextView>(Resource.Id.placeHolder);
            _placeHolderAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.placeholder);
            if (_favorites.Count == 0)
            {
                await Task.Delay(200);
                _placeHolder.StartAnimation(_placeHolderAnimation);
                _placeHolder.Visibility = ViewStates.Visible;
            }
        }
        //private string _parameterText;
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            _locator = CrossGeolocator.Current;
            // New in iOS 9 allowsBackgroundLocationUpdates must be set if you are running a background agent to track location. I have exposed this on the Geolocator via:
            // disable because it drill down the battery very quickly
            _locator.AllowsBackgroundUpdates = false;
            _locator.DesiredAccuracy = 50;
            _locator.PositionChanged -= Locator_PositionChanged;
            _locator.PositionChanged += Locator_PositionChanged;

            // parse params to show any shared location if it exists
            ParseIntent();

            var tintManager = new SystemBarTintManager(this);
            // set the transparent color of the status bar, 30% darker
            tintManager.SetTintColor(Color.ParseColor("#30000000"));
            tintManager.SetNavigationBarTintEnabled(true);
            tintManager.StatusBarTintEnabled = true;

            // prevent the soft keyboard from pushing the view up
            Window.SetSoftInputMode(SoftInput.AdjustNothing);

            // prepare icons for location / compass button
            var iconGenerator = new IconGenerator(this);
            iconGenerator.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_location, null));
            _iconUserLocation = iconGenerator.MakeIcon();
            iconGenerator.SetBackground(ResourcesCompat.GetDrawable(Resources, Resource.Drawable.ic_compass, null));
            _iconCompass = iconGenerator.MakeIcon();
            //var uiOptions = (int)this.Window.DecorView.SystemUiVisibility;
            //var newUiOptions = (int)uiOptions;
            //newUiOptions &= ~(int)SystemUiFlags.LowProfile;
            //newUiOptions &= ~(int)SystemUiFlags.Fullscreen;
            //newUiOptions &= ~(int)SystemUiFlags.HideNavigation;
            //newUiOptions &= ~(int)SystemUiFlags.Immersive;
            //newUiOptions |= (int)SystemUiFlags.ImmersiveSticky;
            //this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;
            //Window.SetFlags(WindowManagerFlags.LayoutNoLimits, WindowManagerFlags.LayoutNoLimits);

            var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            //toolbar.Background.SetAlpha(200);
            ViewCompat.SetElevation(toolbar, 6f);
            SetSupportActionBar(toolbar);

            //Enable support action bar to display hamburger and back arrow
            // http://stackoverflow.com/questions/28071763/toolbar-navigation-hamburger-icon-missing
            _drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            //_drawerToggle = new CustomActionBarDrawerToggle(this, _drawerLayout, toolbar, Resource.String.ApplicationName, Resource.String.ApplicationName);
            //_drawerToggle.DrawerIndicatorEnabled = true;
            _drawerLayout.SetDrawerListener(new CustomDrawerToggle(this));
            //Enable support action bar to display hamburger


            var burgerImage = FindViewById<ImageButton>(Resource.Id.burgerImage);
            burgerImage.SetOnClickListener(new HomeButtonClickListener(this));

            // SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);
            SupportActionBar.SetHomeButtonEnabled(false);
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetDisplayShowCustomEnabled(false);

            navigationView = FindViewById<NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(new NavigationItemSelectedListener(this));

            _bikesButton = FindViewById<FloatingActionButton>(Resource.Id.bikesButton);
            _bikesButton.BackgroundTintList = ColorStateList.ValueOf(Resources.GetColor(Resource.Color.primary_light));
            _bikesButton.Click += BikesButton_Click;

            _parkingButton = FindViewById<FloatingActionButton>(Resource.Id.parkingButton);
            _parkingButton.BackgroundTintList = ColorStateList.ValueOf(Resources.GetColor(Resource.Color.primary_light));
            _parkingButton.Click += ParkingButton_Click;

            _locationButton = FindViewById<FloatingActionButton>(Resource.Id.locationButton);
            _locationButton.BackgroundTintList = ColorStateList.ValueOf(Color.White);
            _locationButton.SetColorFilter(Color.Gray);

            _searchProgressBar = FindViewById<ProgressBar>(Resource.Id.searchProgressBar);

            // Doesn't work on Kitkat 4.4, use SetColorFilter instead
            //_locationButton.ImageTintList = ColorStateList.ValueOf(Color.Black);
            _locationButton.Click += LocationButton_Click;

            _tileButton = FindViewById<FloatingActionButton>(Resource.Id.tileButton);
            _tileButton.BackgroundTintList = ColorStateList.ValueOf(Color.White);
            _tileButton.SetColorFilter(Color.DarkGray);
            _tileButton.Click += TileButton_Click;
            var parent = (View)_tileButton.Parent;

            // Gets the parent view and posts a Runnable on the UI thread. 
            // This ensures that the parent lays out its children before calling the getHitRect() method.
            // The getHitRect() method gets the child's hit rectangle (touchable area) in the parent's coordinates.
            parent.Post(() =>
            {
                var touchRect = new Rect();
                _tileButton.GetHitRect(touchRect);
                touchRect.Top -= 200;
                touchRect.Left -= 200;
                touchRect.Bottom += 200;
                touchRect.Right += 200;


                parent.TouchDelegate = new TouchDelegate(touchRect, _tileButton);
            });

            _currentTileName = FindViewById<TextView>(Resource.Id.currentTileName);
            _currentTileNameAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.placeholder);
            _disappearTileNameAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.disappearAnimation);
            _currentTileNameAnimation.AnimationEnd += _currentTileNameAnimation_AnimationEnd;

            UnStickUserLocation();

            AutoCompleteSearchPlaceTextView = FindViewById<AutoCompleteTextView>(Resource.Id.autoCompleteSearchPlaceTextView);
            AutoCompleteSearchPlaceTextView.ItemClick += AutoCompleteSearchPlaceTextView_ItemClick;
            googlePlacesAutocompleteAdapter = new GooglePlacesAutocompleteAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line);
            AutoCompleteSearchPlaceTextView.Adapter = googlePlacesAutocompleteAdapter;


            Observable.FromEventPattern(AutoCompleteSearchPlaceTextView, "TextChanged")
                .Throttle(TimeSpan.FromMilliseconds(300))
                .Where(x => AutoCompleteSearchPlaceTextView.Text.Length >= 2)
                .Subscribe(async x =>
                {
                    try
                    {
                        RunOnUiThread(() =>
                        {
                            _searchProgressBar.Visibility = ViewStates.Visible;
                        });

                        using (var client = new HttpClient(new NativeMessageHandler()))
                        {
                            var response = await client.GetAsync(strAutoCompleteGoogleApi + AutoCompleteSearchPlaceTextView.Text + "&key=" + strGoogleApiKey).ConfigureAwait(false);
                            var responseBodyAsText = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
                            var predictions = JsonConvert.DeserializeObject<PlaceApiModel>(responseBodyAsText).predictions.ToList();
                            googlePlacesAutocompleteAdapter.Results = predictions;
                            if (AutoCompleteSearchPlaceTextView.Text.Length >= 2)
                            {
                                RunOnUiThread(() =>
                                {
                                    googlePlacesAutocompleteAdapter.NotifyDataSetChanged();
                                    EndPlacesSearch();
                                });
                            }
                        }
                    }
                    catch
                    {
                        RunOnUiThread(() =>
                        {
                            EndPlacesSearch();
                        });
                    }
                });


            //navigationView.NavigationItemSelected += (sender, e) =>
            //{
            //    e.MenuItem.SetChecked(true);
            //    //react to click here and swap fragments or navigate
            //    drawerLayout.CloseDrawers();
            //};

            // trigger the creation of the injected dependencies
            _settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
            _favoritesService = SimpleIoc.Default.GetInstance<IFavoritesService>();
        }
Beispiel #39
0
 public FavoritesModel(IFavoritesService favoritesService, string[] testFavoriteIdList)
 {
     this.Favorites = favoritesService.getFavorites(testFavoriteIdList);
 }
Beispiel #40
0
 public FavoritesController(IFavoritesService favoritesService)
 {
     this.favoritesService = favoritesService;
 }