Exemple #1
0
        private void fillTimesheetLines(int position)
        {
            if (temp != null)
            {
                temp = null;
            }

            if (mPeriodz.numHome > 1)
            {
                mPeriodz.removeItems(mPeriozAdapter);
                mPeriodz.addPeriod(periodTemp, position);
                currentDayPosition = position;
            }

            temp = JsonConvert.DeserializeObject <TimesheetLines.RootObject>(main.offline.ElementAt(currentDayPosition).offlineTimesheetLines);
            for (int i = 0; i < temp.D.Results.Count; i++)
            {
                mPeriodz.addPeriod(temp.D.Results[i].ProjectName,
                                   temp.D.Results[i].TaskName,
                                   temp.D.Results[i].Comment,
                                   temp.D.Results[i].ValidationType.ToString(),
                                   temp.D.Results[i].Status.ToString(),
                                   temp.D.Results[i].TotalWork);
            }
            mPeriozAdapter.NotifyItemRangeInserted(mPeriodz.numHome - 1, temp.D.Results.Count - 1);
        }
Exemple #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.empty_recycleview, container, false);

            main = Activity as MainActivity;

            wtfList.Clear();
            wtfList2.Clear();
            periodTemp.Clear();
            oldPosition    = -1;
            mRecyclerView  = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            mLayoutManager = new LinearLayoutManager(view.Context);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            mPeriodz = new TimesheetPeriodz();
            foreach (var item in main.offline)
            {
                wtfList.Add(JsonConvert.DeserializeObject <TimesheetPeriod.Result>(item.period));
                wtfList2.Add(JsonConvert.DeserializeObject <List <string> >(item.offlineTimesheetWork));
            }
            foreach (var item in wtfList)
            {
                periodTemp.Add(item.Name + ": " + item.Start.ToShortDateString() + " - " + item.End.ToShortDateString());
            }

            mPeriodz.addPeriod(periodTemp, currentDayPosition);
            mPeriozAdapter            = new SavedTimesheetPeriodAdapter(mPeriodz, main, this);
            mPeriozAdapter.itemClick += Adapter_ItemClick;
            mRecyclerView.SetAdapter(mPeriozAdapter);

            return(view);
        }
Exemple #3
0
        public void fillTimesheetLines(int position)
        {
            if (temp != null)
            {
                temp = null;
            }

            if (mPeriodz.numHome > 1)
            {
                mPeriodz.removeItems(mPeriozAdapter);
                mPeriodz.addPeriod(periodTemp, position);
                currentDayPosition = position;
            }

            ThreadPool.QueueUserWorkItem(async state =>
            {
                try {
                    bool success = await core.CreateTimesheet("", periodList.D.Results[position].Id);
                    if (success)
                    {
                        string data = await core.GetTimesheetLines(periodList.D.Results[position].Id);
                        temp        = JsonConvert.DeserializeObject <TimesheetLines.RootObject>(data);

                        for (int i = 0; i < temp.D.Results.Count; i++)
                        {
                            mPeriodz.addPeriod(temp.D.Results[i].ProjectName,
                                               temp.D.Results[i].TaskName,
                                               temp.D.Results[i].Comment,
                                               temp.D.Results[i].LineClass.ToString(),
                                               temp.D.Results[i].Status.ToString(),
                                               temp.D.Results[i].TotalWork);
                        }
                        main.RunOnUiThread(() => { mPeriozAdapter.NotifyItemRangeInserted(mPeriodz.numHome - 1, temp.D.Results.Count - 1); });
                    }
                }
                catch (Exception e) {
                    Log.Info("kfsama", e.Message);
                }
            });
        }
Exemple #4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.empty_recycleview, container, false);

            main        = (Activity as MainActivity);
            core        = main.getCore();
            periodList  = main.getTimesheetPeriods();
            oldPosition = -1;

            periodTemp.Clear();
            TimeSpan span;

            for (int i = 0; i < periodList.D.Results.Count; i++)
            {
                periodTemp.Add(periodList.D.Results[i].Name + ": " + periodList.D.Results[i].Start.ToShortDateString() + " - " + periodList.D.Results[i].End.ToShortDateString());
                span = periodList.D.Results[i].End.Subtract(periodList.D.Results[i].Start);
                for (int j = 0; j <= span.Days; j++)
                {
                    if (periodList.D.Results[i].Start.Date.AddDays(j).Equals(DateTime.Now.Date))
                    {
                        currentDayPosition = i;
                        break;
                    }
                }
            }

            mRecyclerView  = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            mLayoutManager = new LinearLayoutManager(view.Context);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            mPeriodz = new TimesheetPeriodz();
            mPeriodz.addPeriod(periodTemp, currentDayPosition);

            mPeriozAdapter            = new TimesheetPeriodAdapter(mPeriodz, main, this);
            mPeriozAdapter.itemClick += Adapter_ItemClick;
            mRecyclerView.SetAdapter(mPeriozAdapter);
            return(view);
        }