Пример #1
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
     modelActivity = new GenericActivityModel()
     {
         dbGenericActivity = new GenericActDA(SQLite_Android.DB.dataBase),
         gps       = GPS.GetGPSTracker(ApplicationContext),
         myToolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar)
     };
     controller = new GenericCon(modelActivity);
     HockeyApp.Android.Metrics.MetricsManager.Register(Application);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var modelGeneric = new GenericModel
            {
                dbGenericActivity = new GenericActDA(Sqlite_IOS.DB.dataBase)
            };

            genController = new GenericCon(modelGeneric);
            modelPCL      = new MenuPdvsModel
            {
                dbGenericActivity = new GenericActDA(Sqlite_IOS.DB.dataBase),
                dbPdvs            = new MenuPdvsDA(Sqlite_IOS.DB.dataBase)
            };
            modelPCL.infoUsuario = modelPCL.dbPdvs.GetUserInfoLogged();
            controllerPCL        = new MenuPdvsCon(modelPCL);

            var userInfo = modelPCL.dbPdvs.GetUserInfoLogged();

            nomeUsuario.Text   = userInfo[0].NOME;
            cargoPromotor.Text = userInfo[0].CARGO;
            if (userInfo[0].AVATAR != null)
            {
                profileAvatar.SetImage(GetBitMap(userInfo[0].AVATAR), UIControlState.Normal);
            }
            profileAvatar.Layer.CornerRadius    = profileAvatar.Frame.Size.Width / 2;
            profileAvatar.Layer.BorderWidth     = 1.0f;
            profileAvatar.Layer.BorderColor     = UIColor.White.CGColor;
            profileAvatar.ClipsToBounds         = true;
            profileAvatar.ImageView.ContentMode = UIViewContentMode.ScaleAspectFill;

            profileAvatar.TouchDown -= ClickCamera();
            profileAvatar.TouchDown += ClickCamera();

            tabBarMenuPdvs.ItemSelected -= ClickTabBar();
            tabBarMenuPdvs.ItemSelected += ClickTabBar();

            headerView.Layer.ShadowColor   = UIColor.Black.CGColor;
            headerView.Layer.ShadowOffset  = new CGSize(0.0f, 2.6f);
            headerView.Layer.ShadowOpacity = 0.6f;
            PopulateProgressBar(false);
            UpdateData();
        }
        void InitPresentation()
        {
            tarefas = new List <Tarefa>();
            var modelPDV = new MenuPdvsModel
            {
                dbGenericActivity = new GenericActDA(Sqlite_IOS.DB.dataBase),
                dbPdvs            = new MenuPdvsDA(Sqlite_IOS.DB.dataBase)
            };

            modelPDV.infoUsuario = modelPDV.dbGenericActivity.GetUsersIDsLogged();

            var modelGeneric = new GenericModel
            {
                dbGenericActivity = new GenericActDA(Sqlite_IOS.DB.dataBase)
            };

            genericController = new GenericCon(modelGeneric);

            var visita = modelPDV.dbPdvs.GetVisitaAtual();

            if (visita != null)
            {
                if (visita.Count > 0)
                {
                    listIdsPDVs = new List <ListTypePDV>();
                    foreach (var item in visita)
                    {
                        listIdsPDVs.Add(new ListTypePDV(item.ID));
                    }
                    listIdsUsers = new List <string>();
                    foreach (var itemUser in modelPDV.infoUsuario)
                    {
                        listIdsUsers.Add(itemUser.ID);
                    }
                }
            }

            PopulateTarefas();
            ReloadList();

            tabBarTarefas.ItemSelected += delegate
            {
                if (tabBarTarefas.SelectedItem.Title == tabItemAlmoco.Title)
                {
                    PopUpAlmoco("Gostaria de iniciar o horario de almoco em seu ponto eletronico ?");
                }
                else if (tabBarTarefas.SelectedItem.Title == tabItemConcluir.Title)
                {
                    PopUpForceCheckOut();
                }
            };

            searchBarTarefas.TextChanged += delegate
            {
                if (string.IsNullOrEmpty(searchBarTarefas.Text))
                {
                    PopulateTarefas();
                    ReloadList();
                }
            };

            searchBarTarefas.SearchButtonClicked += delegate
            {
                PopulateTarefas();
                tarefas.RemoveAll(tarefa => (!tarefa.Categoria.ToUpper().Contains(searchBarTarefas.Text.ToUpper()) &&
                                             !tarefa.DescricaoDaTarefa.ToUpper().Contains(searchBarTarefas.Text.ToUpper())));
                ReloadList();
            };

            if (tarefas != null && tarefas.Count < 1)
            {
                PopUpCheckOutAutomatico();
            }
        }