Esempio n. 1
0
        public void OnItemSelected(AdapterView parent, View view, int position, long id)
        {
            string goalTime = (string)Singleton.Instance.GoalSpinner.SelectedItem;

            if (goalTime == "Day")
            {
                Singleton.Instance.MonthSpinner.Visibility = ViewStates.Visible;
            }
            else
            {
                Singleton.Instance.MonthSpinner.Visibility = ViewStates.Gone;
            }

            GoalTimeDao.Update(goalTime);
            var obj = new GoalFragmentAdapter(Singleton.Instance.GoalActivity.SupportFragmentManager);

            Singleton.Instance.GoalViewPager.Adapter = obj;
            Singleton.Instance.GoalViewPager.AddOnPageChangeListener(new GoalFragmentPagerChangeListener());
            var instance = Singleton.Instance;

            for (int i = 0; i < obj.Count; i++)
            {
                GoalContext goalContext = GoalContextDao.GetGoalContext(i);
                if (goalContext.IsViewCreated)
                {
                    goalContext.UpdateTextView();
                }
                else
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        public void OnClick(IDialogInterface dialog, int which)
        {
            var resGoalTime = GoalTimeDao.GetGoalTime();

            if (resGoalTime == null)
            {
                return;
            }
            switch (resGoalTime.Name)
            {
            case "Year":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalDao.Delete(item.IDGoal);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Month":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfMonthDao.Delete(item.IDGoal);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Day":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfDayDao.Delete(item.IDGoal);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;
            }
        }
Esempio n. 3
0
        public void OnPageSelected(int position)
        {
            switch (GoalTimeDao.GetGoalTime().Name)
            {
            case "Year":
                Singleton.Instance.tvGoalTitle.Text = "2018";
                break;

            case "Month":
                Singleton.Instance.tvGoalTitle.Text = MonthDao.GetMonth(position + 1).Title;
                break;

            case "Day":
                Singleton.Instance.tvGoalTitle.Text = (position + 1).ToString();
                break;
            }
        }
Esempio n. 4
0
        public GoalFragmentAdapter(Android.Support.V4.App.FragmentManager fm) : base(fm)
        {
            switch (GoalTimeDao.GetGoalTime().Name)
            {
            case "Year":
                Singleton.Instance.tvGoalTitle.Text = "2018";
                break;

            case "Month":
                Singleton.Instance.tvGoalTitle.Text = "Jan";
                break;

            case "Day":
                Singleton.Instance.tvGoalTitle.Text = "1";
                break;
            }
        }
Esempio n. 5
0
        public void UpdateTextView()
        {
            switch (GoalTimeDao.GetGoalTime().Name)
            {
            case "Year":
                tvContent.Text = GoalUtils.GetGoalsYear();
                break;

            case "Month":
                tvContent.Text = GoalUtils.GetGoalsMonth(ID + 1);
                break;

            case "Day":
                tvContent.Text = GoalUtils.GetGoalsDay(MonthDao.GetSelectedMonth().ID, ID + 1);
                break;
            }
        }
Esempio n. 6
0
        public void OnClick(IDialogInterface dialog, int which)
        {
            var resGoalTime = GoalTimeDao.GetGoalTime();

            if (resGoalTime == null)
            {
                return;
            }
            switch (resGoalTime.Name)
            {
            case "Year":
                InputMethodManager imm = (InputMethodManager)Singleton.Instance.GoalActivity.GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(Singleton.Instance.AddGoalView.WindowToken, HideSoftInputFlags.None);

                GoalDao.Insert(Singleton.Instance.AddGoalEditText.Text);
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Month":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfMonthDao.Insert(item.IDGoal, Singleton.Instance.IDMonth);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;

            case "Day":
                foreach (var item in Singleton.Instance.GoalCheckBoxs)
                {
                    CheckBox chk = item.CheckBox;
                    if (chk.Checked)
                    {
                        GoalOfDayDao.Insert(item.IDGoal, Singleton.Instance.IDDay);
                    }
                }
                //GoalUtils.GetGoal();
                dialog.Dismiss();
                break;
            }
        }
Esempio n. 7
0
        public static void DeleteGoal()
        {
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            var resGoalTime = GoalTimeDao.GetGoalTime();

            if (resGoalTime == null)
            {
                return;
            }
            switch (resGoalTime.Name)
            {
            case "Year":
                Singleton.Instance.GoalCheckBoxs = new List <ProjectData.GoalCheckBox>();
                Singleton.Instance.DeleteGoalDialog.SetTitle("Goal of Month");
                var resGoals = SelfJournalDbContext.Instance.Goals;
                for (int i = 0; i < resGoals.Count; i++)
                {
                    RelativeLayout rl = new RelativeLayout(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lp
                    };
                    Singleton.Instance.DGLinearLayout.AddView(rl);

                    RelativeLayout.LayoutParams lpTv = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
                    lpTv.AddRule(LayoutRules.AlignParentLeft);
                    TextView tv = new TextView(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lpTv,
                        Text             = resGoals[i].Name,
                        TextSize         = 15
                    };
                    rl.AddView(tv);

                    RelativeLayout.LayoutParams lpChk = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
                    lpChk.AddRule(LayoutRules.AlignParentRight);
                    CheckBox chk = new CheckBox(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lpChk
                    };
                    rl.AddView(chk);

                    Singleton.Instance.GoalCheckBoxs.Add(new ProjectData.GoalCheckBox {
                        IDGoal = resGoals[i].ID, CheckBox = chk
                    });
                }
                break;

            case "Month":
                Singleton.Instance.GoalCheckBoxs = new List <ProjectData.GoalCheckBox>();
                Singleton.Instance.DeleteGoalDialog.SetTitle("Goal of Month");
                var resGoalOfMonths = GoalOfMonthDao.GetGoalOfMonths(Singleton.Instance.IDMonth);
                for (int i = 0; i < resGoalOfMonths.Count; i++)
                {
                    RelativeLayout rl = new RelativeLayout(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lp
                    };
                    Singleton.Instance.DGLinearLayout.AddView(rl);

                    RelativeLayout.LayoutParams lpTv = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
                    lpTv.AddRule(LayoutRules.AlignParentLeft);
                    TextView tv = new TextView(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lpTv,
                        Text             = GoalDao.GetGoal(resGoalOfMonths[i].IDGoal).Name,
                        TextSize         = 15
                    };
                    rl.AddView(tv);

                    RelativeLayout.LayoutParams lpChk = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
                    lpChk.AddRule(LayoutRules.AlignParentRight);
                    CheckBox chk = new CheckBox(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lpChk
                    };
                    rl.AddView(chk);

                    Singleton.Instance.GoalCheckBoxs.Add(new ProjectData.GoalCheckBox {
                        IDGoal = resGoalOfMonths[i].ID, CheckBox = chk
                    });
                }
                break;

            case "Day":
                Singleton.Instance.GoalCheckBoxs = new List <ProjectData.GoalCheckBox>();
                Singleton.Instance.DeleteGoalDialog.SetTitle("Goal of Day");
                var resGoalOfDays = GoalOfDayDao.GetGoalOfDays(0, Singleton.Instance.IDDay);
                for (int i = 0; i < resGoalOfDays.Count; i++)
                {
                    RelativeLayout rl = new RelativeLayout(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lp
                    };
                    Singleton.Instance.DGLinearLayout.AddView(rl);

                    RelativeLayout.LayoutParams lpTv = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
                    lpTv.AddRule(LayoutRules.AlignParentLeft);
                    TextView tv = new TextView(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lpTv,
                        Text             = GoalDao.GetGoal(GoalOfMonthDao.GetGoalOfMonth(resGoalOfDays[i].IDGoalOfMonth).IDGoal).Name,
                        TextSize         = 15
                    };
                    rl.AddView(tv);

                    RelativeLayout.LayoutParams lpChk = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
                    lpChk.AddRule(LayoutRules.AlignParentRight);
                    CheckBox chk = new CheckBox(Singleton.Instance.GoalActivity)
                    {
                        LayoutParameters = lpChk
                    };
                    rl.AddView(chk);

                    Singleton.Instance.GoalCheckBoxs.Add(new ProjectData.GoalCheckBox {
                        IDGoal = resGoalOfDays[i].ID, CheckBox = chk
                    });
                }
                break;
            }
        }