Esempio n. 1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            ActivityInstance = this;
            progress         = new ProgressDialogHelper(this);
            signInService    = new SignInService();
            bitmapService    = new BitmapOperationService();
            appSettings      = SharedPreferencesHelper.GetAppSettings(this);
            if (!appSettings.ChatDisabled)
            {
                this.chatHubClientService = ChatHubClientService.GetServiceInstance(bearerToken);
            }
            this.messagesService = new MessagesService(bearerToken);
            SetContentView(Resource.Layout.ConversationActivity);
            SetupViews(savedInstanceState);
            SetupConversationToolbar();
            pageNumber = 0;
            GetExtras();
            player = new MediaPlayer();
            player.SetDataSource(this, Android.Net.Uri.Parse("android.resource://" + this.PackageName + "/raw/" + Resource.Raw.message_sound));
            player.Prepare();
            progress.ShowProgressDialog("Trwa pobieranie wiadomoœci...");
            await SetupIntelocutorInfo();
            await GetAndDisplayMesages(savedInstanceState);

            coversationsLayoutWrapper.Visibility = ViewStates.Visible;
            progress.CloseProgressDialog();
        }
Esempio n. 2
0
 public NavigationViewMenu(BaseActivityWithNavigationDrawer activity, SharedPreferencesHelper sharedPreferencesHelper)
 {
     this.activity = activity;
     signInService = new SignInService();
     this.bitmapOperationService  = new BitmapOperationService();
     this.progressDialogHelper    = new ProgressDialogHelper(activity);
     this.sharedPreferencesHelper = sharedPreferencesHelper;
     this.gpsService           = GpsLocationService.GetServiceInstance(activity);
     this.googleMapsAPIService = new GoogleMapsAPIService();
     this.categoriesHelper     = new CategoriesSelectingHelper(activity, (string)this.sharedPreferencesHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN));
     this.sizeSelectingHelper  = new SizeSelectingHelper(activity);
     this.appSettings          = SharedPreferencesHelper.GetAppSettings(activity);
     SetupViews(activity);
 }
        protected override void OnStart()
        {
            base.OnStart();
            var settingsModel = SharedPreferencesHelper.GetAppSettings(this);

            if (settingsModel != null)
            {
                WakeUpAlarmReceiver.SetWakeUpAlarmRepeating(this.ApplicationContext, AlarmManager.IntervalHour);
                if (!settingsModel.ChatDisabled && !MessengerService.ServiceIsRunning)
                {
                    StartService(new Intent(this.ApplicationContext, typeof(MessengerService)));
                }
            }
            IsInStack = true;
        }
Esempio n. 4
0
        private async Task <List <AdvertisementItemShort> > GetAdvertisements()
        {
            this.advertisementsSearchModel.Page = advertisementsPage;

            switch (this.advertisementsSearchModel.AdvertisementsKind)
            {
            case AdvertisementsKind.AdvertisementsAroundUserCurrentLocation:
                try
                {
                    this.advertisementsSearchModel.CoordinatesModel = this.gpsLocationService.GetCoordinatesModel(advertisementsSearchModel.CoordinatesModel.MaxDistance);
                }
                catch (Exception exc)
                {
                    return(new List <AdvertisementItemShort>());
                }

                break;

            case AdvertisementsKind.AdvertisementsArounUserHomeLocation:
                var settingsMOdel = SharedPreferencesHelper.GetAppSettings(this);
                if (settingsMOdel != null && settingsMOdel.LocationSettings.Latitude > 0.0D)
                {
                    this.advertisementsSearchModel.CoordinatesModel.Latitude  = settingsMOdel.LocationSettings.Latitude;
                    this.advertisementsSearchModel.CoordinatesModel.Longitude = settingsMOdel.LocationSettings.Longitude;
                }
                else
                {
                    AlertsService.ShowLongToast(this, "Nie masz ustawionej lokalizacji domowej. Mo¿esz to zrobiæ w lewym panelu");
                    return(new List <AdvertisementItemShort>());
                }
                break;
            }

            var list = default(List <AdvertisementItemShort>);

            list = await this.advertisementItemService.GetAdvertisements(this.advertisementsSearchModel);

            return(list);
        }
        public override async void OnReceive(Context context, Intent intent)
        {
            bearerToken = SharedPreferencesHelper.GetBearerToken(context);
            if (bearerToken == null)
            {
                return;
            }
            var isUserConnectedToInternet = await DoesUserHasInternetConnection(bearerToken);

            if (!isUserConnectedToInternet)
            {
                return;
            }
            this.context = context.ApplicationContext;
            var powerManager = (PowerManager)context.GetSystemService(Context.PowerService);

            _wakeLock = powerManager.NewWakeLock(WakeLockFlags.Partial, "MSH");
            _wakeLock.Acquire();
            timerTick     = 1;
            timerInterval = 1000 * 5;
            timer         = new System.Threading.Timer(new TimerCallback(TimerCallBackMethod));
            timer.Change(timerInterval, timerInterval);

            this.appsettings = SharedPreferencesHelper.GetAppSettings(this.context);
            if (!appsettings.ChatDisabled)
            {
                MessengerService.AddOutsidePendingWork();
                chatHubServiceInstance = ChatHubClientService.GetServiceInstance(bearerToken);
            }
            if (!appsettings.NotificationsDisabled)
            {
                SetCheckingNewAdvertisementsAction(context);
                checkingNewAdvertsAction();
            }
            else
            {
                checkingNewAdvertsFinished = true;
            }
        }
 private void SetCheckingNewAdvertisementsAction(Context context)
 {
     checkingNewAdvertsAction = async() =>
     {
         try
         {
             searchModelForNotifications   = new AdvertisementsSearchModelForNotifications();
             this.appsettings              = SharedPreferencesHelper.GetAppSettings(this.context);
             this.advertisementItemService = new AdvertisementItemService(bearerToken);
             this.gpsLocationService       = new GpsLocationService(context.ApplicationContext, null);
             var coordinates = await CheckNewAdvertisementsAroundUserCurrentLocation();
             await CheckNewAdvertisementsAroundUserHomeLocation(coordinates);
         }
         catch
         {
         }
         finally
         {
             checkingNewAdvertsFinished = true;
         }
     };
 }