コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.full_details);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            dialogs = new DialogHelpers();

            id = Intent.GetStringExtra("Id");
            projectServerJson = Intent.GetStringExtra("projectServer");
            projectDataJson = Intent.GetStringExtra("projectData");
            projectTitle = Intent.GetStringExtra("title");
            core = JsonConvert.DeserializeObject<PsCore>(Intent.GetStringExtra("core"));
            core.setClient();
            core.setClient2(Intent.GetStringExtra("formDigest"));
            
            SupportActionBar.Title = projectTitle;

             GetTeamAsync();
             GetProjectTasks();
            //retrieving data
            SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, new LoaderFragment())
                        .Commit();

        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.timesheet_line_dialog);


            if (Intent.GetBooleanExtra("identifier", false))
            {
                rtFa    = Intent.GetStringExtra("rtFa");
                FedAuth = Intent.GetStringExtra("FedAuth");
                string formDigest = Intent.GetStringExtra("FormDigest");
                core = new PsCore(rtFa, FedAuth);
                core.setClient();
                core.setClient2(formDigest);
            }
            periodId = Intent.GetStringExtra("periodId");
            lineId   = Intent.GetStringExtra("lineId");
            days     = JsonConvert.DeserializeObject <List <DateTime> >(Intent.GetStringExtra("days"));
            work     = JsonConvert.DeserializeObject <TimesheetWork.RootObject>(Intent.GetStringExtra("lineWork"));

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.Title = Intent.GetStringExtra("taskName");

            RecyclerView recyclerView = FindViewById <RecyclerView>(Resource.Id.rvTimesheetLineHours);

            RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
            recyclerView.SetLayoutManager(layoutManager);

            workz = new TimesheetWorkz();
            for (int i = 0; i < days.Count; i++)
            {
                workz.addWork(days[i], "0h", "0h");
            }

            for (int i = 0; i < work.D.Results.Count; i++)
            {
                workz.updateWork(work.D.Results[i].Start, work.D.Results[i].ActualWork, work.D.Results[i].PlannedWork);
            }

            TimesheetWorkAdapter adapter = new TimesheetWorkAdapter(workz, this);

            recyclerView.SetAdapter(adapter);
        }
コード例 #3
0
        private async void init(Bundle savedInstanceState)
        {
            drawerLayout = this.FindViewById <DrawerLayout>(Resource.Id.drawer_layout);

            //Set hamburger items menu
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu);

            //setup navigation view
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetCheckedItem(Resource.Id.nav_home_1);
            userName = navigationView.GetHeaderView(0).FindViewById <TextView>(Resource.Id.tvName);
            TextView userEmail = navigationView.GetHeaderView(0).FindViewById <TextView>(Resource.Id.tvEmail);

            //handle navigation
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);

                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_home_1:
                    ListItemClicked(0);
                    break;

                case Resource.Id.nav_home_2:
                    ListItemClicked(1);
                    break;

                case Resource.Id.nav_home_3:
                    ListItemClicked(2);
                    break;

                case Resource.Id.nav_home_4:
                    ListItemClicked(3);
                    break;

                case Resource.Id.nav_home_5:
                    ListItemClicked(4);
                    break;

                case Resource.Id.nav_home_6:
                    ListItemClicked(5);
                    break;
                }
                drawerLayout.CloseDrawers();
            };
            //if first time you will want to go ahead and click first item.
            //if (savedInstanceState == null)
            //{
            //    ListItemClicked(0);
            //}


            fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.SetVisibility(ViewStates.Gone);
            fab.Click += delegate {
                fabFunctions();
            };

            refresh = FindViewById <SwipeRefreshLayout>(Resource.Id.refresher);
            refresh.SetColorScheme(Resource.Color.refresher_1, Resource.Color.refresher_2);
            refresh.Refresh += delegate {
                refreshData(refreshIdentifier);
            };

            //setting the cookies
            var rtFa    = Intent.GetStringExtra("rtFa");
            var FedAuth = Intent.GetStringExtra("FedAuth");

            online     = Intent.GetBooleanExtra("connection", false);
            core       = new PsCore(rtFa, FedAuth);
            helpDialog = new DialogHelpers();

            //setting formDigest
            prefs = PreferenceManager.GetDefaultSharedPreferences(this);

            core.setClient();
            if (online)
            {
                string context = await core.GetFormDigest("");

                ThreadPool.QueueUserWorkItem(state =>
                {
                    try
                    {
                        var data = JsonConvert.DeserializeObject <AndroidApp1.FormDigestModel.RootObject>(context);
                        core.setClient2(data.D.GetContextWebInformation.FormDigestValue);
                        core.FormDigest = data.D.GetContextWebInformation.FormDigestValue;
                    }
                    catch (Exception e)
                    {
                        RunOnUiThread(() =>
                        {
                            mText = "You have no acces on this site";
                            switchFragment(new OfflineFragment());
                            willSwitch = true;
                        });
                    }
                });

                ThreadPool.QueueUserWorkItem(async state =>
                {
                    var data2       = await core.GetCurrentUser();
                    var currentUser = JsonConvert.DeserializeObject <CurrentUser.RootObject>(data2);
                    RunOnUiThread(async() =>
                    {
                        userName.Text  = currentUser.D.Title;
                        userEmail.Text = currentUser.D.Email;
                        if (prefs.GetString("userName", "").Equals("") && prefs.GetString("email", "").Equals(""))
                        {
                            ISharedPreferencesEditor editor = prefs.Edit();
                            editor.PutString("userName", currentUser.D.Title);
                            editor.PutString("email", currentUser.D.Email);
                            editor.Apply();
                            //prefs.Edit().PutString("userName", currentUser.D.Title).Apply();
                            //prefs.Edit().PutString("email", currentUser.D.Email).Apply();
                        }
                        hasAccess = await checkUserAccess(currentUser.D.Title);
                        if (hasAccess)
                        {
                            checkDataAsync(PROJECT_DATA);
                        }
                        else
                        {
                            mText = "You have no acces on this site";
                            switchFragment(new OfflineFragment());
                            willSwitch = true;
                        }
                    });
                });
            }
            else
            {
                if (!prefs.GetString("userName", "").Equals(null) && !prefs.GetString("email", "").Equals(null))
                {
                    userName.Text  = prefs.GetString("userName", "");
                    userEmail.Text = prefs.GetString("email", "");
                }
                switchFragment(new OfflineFragment());
                willSwitch = true;
            }

            tasksWithResource = new List <string> {
            };
            //checkDataAsync(PROJECT_DATA);
        }