public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            Debug.WriteLine("Time Log Detail : " + "We are in On create view");

            // Use this to return your custom view for this Fragment
            var v = inflater.Inflate(Resource.Layout.TimeLogEntry, container, false);

            _tn            = v.FindViewById <TextView>(Resource.Id.TimeLogEdit_TaskName);
            _pn            = v.FindViewById <TextView>(Resource.Id.TimeLogEdit_ProjectName);
            _interruptTime = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_InterruptTime);
            _comment       = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_Comment);
            _startTime     = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_StartTime);
            _deltaTime     = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_DeltaTime);

            _startTime.Focusable     = false;
            _deltaTime.Focusable     = false;
            _interruptTime.Focusable = false;
            _comment.Focusable       = false;

            _startTime.Clickable     = true;
            _deltaTime.Clickable     = true;
            _interruptTime.Clickable = true;
            _comment.Clickable       = true;

            if (_timeLog != null)
            {
                _oldLoggedTime    = _timeLog.LoggedTime;
                _oldInterruptTime = _timeLog.InterruptTime;
            }
            else
            {
                _oldLoggedTime    = 0;
                _oldInterruptTime = 0;
            }


            _deltaTime.Click += (sender, args) =>
            {
                LinearLayout ll = new LinearLayout(Activity);
                ll.Orientation = (Orientation.Horizontal);

                NumberPicker aNumberPicker = new NumberPicker(Activity);
                // TODO: Should there be a maximum for the hour column ?
                aNumberPicker.MaxValue = (100);
                aNumberPicker.MinValue = (0);

                double temp = 0;
                if (!_deltaTime.Text.Equals(""))
                {
                    temp = Convert.ToDouble(TimeSpan.ParseExact(_deltaTime.Text, @"hh\:mm", CultureInfo.InvariantCulture).TotalMinutes);
                }

                //temp = Double.Parse(_deltaTime.Text);

                aNumberPicker.Value = TimeSpan.FromMinutes(temp).Hours;

                NumberPicker aNumberPickerA = new NumberPicker(Activity)
                {
                    MaxValue = (59),
                    MinValue = (0),
                    Value    = TimeSpan.FromMinutes(temp).Minutes
                };


                LinearLayout.LayoutParams parameters = new LinearLayout.LayoutParams(50, 50);
                parameters.Gravity = GravityFlags.Center;

                LinearLayout.LayoutParams numPicerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                numPicerParams.Weight = 1;

                LinearLayout.LayoutParams qPicerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                qPicerParams.Weight = 1;

                ll.LayoutParameters = parameters;
                ll.AddView(aNumberPicker, numPicerParams);
                ll.AddView(aNumberPickerA, qPicerParams);


                AlertDialog.Builder np = new AlertDialog.Builder(Activity).SetView(ll);

                np.SetTitle("Update Delta Time");
                np.SetNegativeButton("Cancel", (s, a) =>
                {
                    np.Dispose();
                });

                np.SetPositiveButton("Ok", (s, a) =>
                {
                    //Update Planned Time
                    string number = aNumberPicker.Value.ToString("D2") + ":" + aNumberPickerA.Value.ToString("D2");
                    Debug.WriteLine(number);
                    double val = Convert.ToDouble(TimeSpan.ParseExact(number, @"hh\:mm", CultureInfo.InvariantCulture).TotalMinutes);
                    Debug.WriteLine("The updated val is :" + val);
                    var updatedLoggedTime = val - _oldLoggedTime;
                    try
                    {
                        if (_timeLog != null)
                        {
                            ((MainActivity)Activity).Ctrl.UpdateTimeLog(AccountStorage.DataSet, "" + _timeLog.Id, null, null, _taskId, updatedLoggedTime, null, false);
                        }
                    }
                    catch (CannotReachServerException)
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                        builder.SetTitle("Unable to Connect")
                        .SetMessage("Please check your network connection and try again")
                        .SetNeutralButton("Okay", (sender2, args2) =>
                        {
                            builder.Dispose();
                            ((MainActivity)Activity).FragmentManager.PopBackStack();
                        })
                        .SetCancelable(false);
                        AlertDialog alert = builder.Create();
                        alert.Show();
                    }
                    catch (WebException we)
                    {
                        if (we.Status == WebExceptionStatus.ProtocolError)
                        {
                            var response = we.Response as HttpWebResponse;
                            if (response != null)
                            {
                                Console.WriteLine("HTTP Status Code: " + (int)response.StatusCode);
                                if (response.StatusCode == HttpStatusCode.Forbidden)
                                {
                                    try
                                    {
                                        Toast.MakeText(this.Activity, "Username and password error.", ToastLength.Long).Show();
                                        System.Diagnostics.Debug.WriteLine("We are about to logout");
                                        AccountStorage.ClearStorage();
                                        System.Diagnostics.Debug.WriteLine("Main Activity is :" + Activity == null);
                                        System.Diagnostics.Debug.WriteLine("Items in the backstack :" + Activity.FragmentManager.BackStackEntryCount);
                                        System.Diagnostics.Debug.WriteLine("Main Activity is :" + Activity == null);
                                        Activity.FragmentManager.PopBackStack(null, PopBackStackFlags.Inclusive);
                                        System.Diagnostics.Debug.WriteLine("Items in the backstack 2 :" + Activity.FragmentManager.BackStackEntryCount);
                                        ((MainActivity)(Activity)).SetDrawerState(false);
                                        ((MainActivity)(Activity)).SwitchToFragment(MainActivity.FragmentTypes.Login);
                                    }
                                    catch (System.Exception e)
                                    {
                                        System.Diagnostics.Debug.WriteLine("We encountered an error :" + e.Message);
                                    }
                                }
                            }
                            else
                            {
                                // no http status code available
                                Toast.MakeText(Activity, "Unable to load the data. Please restart the application.", ToastLength.Short).Show();
                            }
                        }
                        else
                        {
                            // no http status code availableToast.MakeText(Activity, "Unable to load the data. Please restart the application.", ToastLength.Short).Show();
                        }
                    }
                    catch (StatusNotOkayException se)
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                        builder.SetTitle("An Error has occured")
                        .SetMessage("Error :" + se.GetMessage())
                        .SetNeutralButton("Okay", (sender2, args2) =>
                        {
                            builder.Dispose();
                        })
                        .SetCancelable(false);
                        AlertDialog alert = builder.Create();
                        alert.Show();
                    }
                    catch (Exception e)
                    {
                        // For any other weird exceptions
                        AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                        builder.SetTitle("An Error has occured")
                        .SetNeutralButton("Okay", (sender2, args2) =>
                        {
                            builder.Dispose();
                        })
                        .SetMessage("Error :" + e.Message)
                        .SetCancelable(false);
                        AlertDialog alert = builder.Create();
                        alert.Show();
                    }


                    _deltaTime.Text = "" + TimeSpan.FromMinutes(val).ToString(@"hh\:mm");
                    Toast.MakeText(Activity, "Delta Time Updated", ToastLength.Short).Show();
                    np.Dispose();
                });
                np.Show();
            };

            _startTime.Click += (sender, args) =>
            {
                DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime time)
                {
                    //TODO: DEBUG: Check whether this is causing any issues.
                    _startTime.Text = time.ToString(CultureInfo.InvariantCulture);
                    Toast.MakeText(Activity, "Start Date Updated", ToastLength.Short).Show();
                    TimePickerFragment frag2 = TimePickerFragment.NewInstance(delegate(int hour, int min)
                    {
                        Toast.MakeText(Activity, "Start Time Updated", ToastLength.Short).Show();
                        DateTime output = new DateTime(time.Year, time.Month, time.Day, hour, min, 0);
                        _startTime.Text = output.ToString("g");
                    });

                    frag2.chosenDate = time;
                    if (_timeLog != null)
                    {
                        frag2.StartHour   = _timeLog.StartDate.Hour;
                        frag2.StartMinute = _timeLog.StartDate.Minute;
                    }
                    else
                    {
                        frag2.StartHour   = time.Hour;
                        frag2.StartMinute = time.Minute;
                    }

                    frag2.Show(FragmentManager, TimePickerFragment.TAG);
                });
                //frag.StartTime = DateTime.SpecifyKind(DateTime.Parse(""+output[2].value), DateTimeKind.Local);

                frag.StartTime = _timeLog != null ? _timeLog.StartDate : DateTime.Now;

                Debug.WriteLine(frag.StartTime);
                frag.Show(FragmentManager, DatePickerFragment.TAG);
            };

            _interruptTime.Click += (sender, args) =>
            {
                LinearLayout ll = new LinearLayout(Activity);
                ll.Orientation = (Orientation.Horizontal);

                NumberPicker aNumberPicker = new NumberPicker(Activity);
                // TODO: Should there be a maximum for the hour column ?
                aNumberPicker.MaxValue = (100);
                aNumberPicker.MinValue = (0);

                double temp = 0;
                if (!_interruptTime.Text.Equals(""))
                {
                    temp = Convert.ToDouble(TimeSpan.ParseExact(_interruptTime.Text, @"hh\:mm", CultureInfo.InvariantCulture).TotalMinutes);
                }

                //temp = Double.Parse(_deltaTime.Text);

                aNumberPicker.Value = TimeSpan.FromMinutes(temp).Hours;

                NumberPicker aNumberPickerA = new NumberPicker(Activity)
                {
                    MaxValue = (59),
                    MinValue = (0),
                    Value    = TimeSpan.FromMinutes(temp).Minutes
                };


                LinearLayout.LayoutParams parameters = new LinearLayout.LayoutParams(50, 50);
                parameters.Gravity = GravityFlags.Center;

                LinearLayout.LayoutParams numPicerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                numPicerParams.Weight = 1;

                LinearLayout.LayoutParams qPicerParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                qPicerParams.Weight = 1;

                ll.LayoutParameters = parameters;
                ll.AddView(aNumberPicker, numPicerParams);
                ll.AddView(aNumberPickerA, qPicerParams);


                AlertDialog.Builder np = new AlertDialog.Builder(Activity).SetView(ll);

                np.SetTitle("Update Interrupt Time");
                np.SetNegativeButton("Cancel", (s, a) =>
                {
                    np.Dispose();
                });

                np.SetPositiveButton("Ok", (s, a) =>
                {
                    //Update Planned Time
                    string number = aNumberPicker.Value.ToString("D2") + ":" + aNumberPickerA.Value.ToString("D2");
                    Debug.WriteLine(number);
                    double val = Convert.ToDouble(TimeSpan.ParseExact(number, @"hh\:mm", CultureInfo.InvariantCulture).TotalMinutes);
                    Debug.WriteLine("The updated val is :" + val);
                    var updatedInterruptTime = val - _oldInterruptTime;
                    if (_timeLog != null)
                    {
                        // This is an update operation
                        try
                        {
                            if (_timeLog != null)
                            {
                                ((MainActivity)Activity).Ctrl.UpdateTimeLog(AccountStorage.DataSet, "" + _timeLog.Id, null,
                                                                            null, _taskId, null, updatedInterruptTime, false);
                            }
                        }
                        catch (CannotReachServerException)
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                            builder.SetTitle("Unable to Connect")
                            .SetMessage("Please check your network connection and try again")
                            .SetNeutralButton("Okay", (sender2, args2) =>
                            {
                                builder.Dispose();
                                ((MainActivity)Activity).FragmentManager.PopBackStack();
                            })
                            .SetCancelable(false);
                            AlertDialog alert = builder.Create();
                            alert.Show();
                        }
                        catch (WebException we)
                        {
                            if (we.Status == WebExceptionStatus.ProtocolError)
                            {
                                var response = we.Response as HttpWebResponse;
                                if (response != null)
                                {
                                    Console.WriteLine("HTTP Status Code: " + (int)response.StatusCode);
                                    if (response.StatusCode == HttpStatusCode.Forbidden)
                                    {
                                        try
                                        {
                                            Toast.MakeText(this.Activity, "Username and password error.",
                                                           ToastLength.Long).Show();
                                            System.Diagnostics.Debug.WriteLine("We are about to logout");
                                            AccountStorage.ClearStorage();
                                            System.Diagnostics.Debug.WriteLine("Main Activity is :" + Activity == null);
                                            System.Diagnostics.Debug.WriteLine("Items in the backstack :" +
                                                                               Activity.FragmentManager
                                                                               .BackStackEntryCount);
                                            System.Diagnostics.Debug.WriteLine("Main Activity is :" + Activity == null);
                                            Activity.FragmentManager.PopBackStack(null, PopBackStackFlags.Inclusive);
                                            System.Diagnostics.Debug.WriteLine("Items in the backstack 2 :" +
                                                                               Activity.FragmentManager
                                                                               .BackStackEntryCount);
                                            ((MainActivity)(Activity)).SetDrawerState(false);
                                            ((MainActivity)(Activity)).SwitchToFragment(
                                                MainActivity.FragmentTypes.Login);
                                        }
                                        catch (System.Exception e)
                                        {
                                            System.Diagnostics.Debug.WriteLine("We encountered an error :" + e.Message);
                                        }
                                    }
                                }
                                else
                                {
                                    // no http status code available
                                    Toast.MakeText(Activity, "Unable to load the data. Please restart the application.",
                                                   ToastLength.Short).Show();
                                }
                            }
                            else
                            {
                                // no http status code availableToast.MakeText(Activity, "Unable to load the data. Please restart the application.", ToastLength.Short).Show();
                            }
                        }
                        catch (StatusNotOkayException se)
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                            builder.SetTitle("An Error has occured")
                            .SetMessage("Error :" + se.GetMessage())
                            .SetNeutralButton("Okay", (sender2, args2) =>
                            {
                                builder.Dispose();
                            })
                            .SetCancelable(false);
                            AlertDialog alert = builder.Create();
                            alert.Show();
                        }
                        catch (Exception e)
                        {
                            // For any other weird exceptions
                            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                            builder.SetTitle("An Error has occured")
                            .SetNeutralButton("Okay", (sender2, args2) =>
                            {
                                builder.Dispose();
                            })
                            .SetMessage("Error :" + e.Message)
                            .SetCancelable(false);
                            AlertDialog alert = builder.Create();
                            alert.Show();
                        }
                    }
                    _interruptTime.Text = "" + TimeSpan.FromMinutes(val).ToString(@"hh\:mm");
                    Toast.MakeText(Activity, "Interrupt Time Updated", ToastLength.Short).Show();
                    np.Dispose();
                });
                np.Show();
            };

            _comment.Click += (sender, args) =>
            {
                LinearLayout ll = new LinearLayout(Activity);
                ll.Orientation = (Orientation.Horizontal);

                EditText et = new EditText(Activity);
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MatchParent,
                    LinearLayout.LayoutParams.WrapContent);
                et.LayoutParameters = lp;
                //et.LayoutParams = (lp);
                ll.AddView(et);

                et.Focusable = (true);


                if (!_comment.Text.Equals("-"))
                {
                    et.Text = _comment.Text;
                }

                AlertDialog.Builder np = new AlertDialog.Builder(Activity).SetView(ll);

                np.SetTitle("Update Comments");
                np.SetNegativeButton("Cancel", (s, a) =>
                {
                    np.Dispose();
                });

                np.SetPositiveButton("Ok", (s, a) =>
                {
                    //Update Comments
                    string value = et.Text;
                    if (_timeLog != null)
                    {
                        // This is an update operation
                        try
                        {
                            if (_timeLog != null)
                            {
                                ((MainActivity)Activity).Ctrl.UpdateTimeLog(AccountStorage.DataSet, "" + _timeLog.Id, value,
                                                                            null, _taskId, null, null, false);
                            }
                        }
                        catch (CannotReachServerException)
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                            builder.SetTitle("Unable to Connect")
                            .SetMessage("Please check your network connection and try again")
                            .SetNeutralButton("Okay", (sender2, args2) =>
                            {
                                builder.Dispose();
                                ((MainActivity)Activity).FragmentManager.PopBackStack();
                            })
                            .SetCancelable(false);
                            AlertDialog alert = builder.Create();
                            alert.Show();
                        }
                        catch (WebException we)
                        {
                            if (we.Status == WebExceptionStatus.ProtocolError)
                            {
                                var response = we.Response as HttpWebResponse;
                                if (response != null)
                                {
                                    Console.WriteLine("HTTP Status Code: " + (int)response.StatusCode);
                                    if (response.StatusCode == HttpStatusCode.Forbidden)
                                    {
                                        try
                                        {
                                            Toast.MakeText(this.Activity, "Username and password error.",
                                                           ToastLength.Long).Show();
                                            AccountStorage.ClearStorage();
                                            Activity.FragmentManager.PopBackStack(null, PopBackStackFlags.Inclusive);
                                            ((MainActivity)(Activity)).SetDrawerState(false);
                                            ((MainActivity)(Activity)).SwitchToFragment(
                                                MainActivity.FragmentTypes.Login);
                                        }
                                        catch (System.Exception e)
                                        {
                                            System.Diagnostics.Debug.WriteLine("We encountered an error :" + e.Message);
                                        }
                                    }
                                }
                                else
                                {
                                    // no http status code available
                                    Toast.MakeText(Activity, "Unable to load the data. Please restart the application.",
                                                   ToastLength.Short).Show();
                                }
                            }
                            else
                            {
                                // no http status code available
                                Toast.MakeText(Activity, "Unable to load the data. Please restart the application.", ToastLength.Short).Show();
                            }
                        }
                        catch (StatusNotOkayException se)
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                            builder.SetTitle("An Error has occured")
                            .SetMessage("Error :" + se.GetMessage())
                            .SetNeutralButton("Okay", (sender2, args2) =>
                            {
                                builder.Dispose();
                            })
                            .SetCancelable(false);
                            AlertDialog alert = builder.Create();
                            alert.Show();
                        }
                        catch (Exception e)
                        {
                            // For any other weird exceptions
                            AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                            builder.SetTitle("An Error has occured")
                            .SetNeutralButton("Okay", (sender2, args2) =>
                            {
                                builder.Dispose();
                            })
                            .SetMessage("Error :" + e.Message)
                            .SetCancelable(false);
                            AlertDialog alert = builder.Create();
                            alert.Show();
                        }
                    }

                    _comment.Text = value;
                    Toast.MakeText(Activity, "Comment Updated", ToastLength.Short).Show();
                    np.Dispose();
                });
                np.Show();
            };

            if (_taskName != null && _projectName != null)
            {
                _tn.Text = _taskName;
                _pn.Text = _projectName;
            }

            if (_timeLog == null)
            {
                return(v);
            }

            string c = Util.GetInstance().GetLocalTime(_timeLog.StartDate).ToString("g");

            _startTime.Text     = (c);
            _interruptTime.Text = "" + TimeSpan.FromMinutes(_timeLog.InterruptTime).ToString(@"hh\:mm");
            _comment.Text       = _timeLog.Comment ?? "-";
            _deltaTime.Text     = "" + TimeSpan.FromMinutes(_timeLog.LoggedTime).ToString(@"hh\:mm");

            return(v);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            Debug.WriteLine("Time Log Detail : " + "We are in On create view");

            // Use this to return your custom view for this Fragment
            var v = inflater.Inflate(Resource.Layout.TimeLogEntry, container, false);

            _tn            = v.FindViewById <TextView>(Resource.Id.TimeLogEdit_TaskName);
            _pn            = v.FindViewById <TextView>(Resource.Id.TimeLogEdit_ProjectName);
            _interruptTime = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_InterruptTime);
            _comment       = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_Comment);
            _startTime     = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_StartTime);
            _deltaTime     = v.FindViewById <EditText>(Resource.Id.TimeLogEdit_DeltaTime);


            _startTime.Click += (sender, args) =>
            {
                DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime time)
                {
                    //TODO: DEBUG: Check whether this is causing any issues.
                    _startTime.Text = time.ToString(CultureInfo.InvariantCulture);
                    Toast.MakeText(Activity, "Start Date Updated", ToastLength.Short).Show();
                    TimePickerFragment frag2 = TimePickerFragment.NewInstance(delegate(int hour, int min)
                    {
                        Toast.MakeText(Activity, "Start Time Updated", ToastLength.Short).Show();
                        DateTime output = new DateTime(time.Year, time.Month, time.Day, hour, min, 0);
                        _startTime.Text = output.ToString("g");
                    });

                    if (_timeLog != null)
                    {
                        frag2.StartHour   = _timeLog.StartDate.Hour;
                        frag2.StartMinute = _timeLog.StartDate.Minute;
                    }
                    else
                    {
                        frag2.StartHour   = time.Hour;
                        frag2.StartMinute = time.Minute;
                    }

                    frag2.Show(FragmentManager, TimePickerFragment.TAG);
                });
                //frag.StartTime = DateTime.SpecifyKind(DateTime.Parse(""+output[2].value), DateTimeKind.Local);

                frag.StartTime = _timeLog != null ? _timeLog.StartDate : DateTime.Now;

                Debug.WriteLine(frag.StartTime);
                frag.Show(FragmentManager, DatePickerFragment.TAG);
            };


            if (_timeLog != null)
            {
                _oldLoggedTime    = _timeLog.LoggedTime;
                _oldInterruptTime = _timeLog.InterruptTime;
            }
            else
            {
                _oldLoggedTime    = 0;
                _oldInterruptTime = 0;
            }

            if (_taskName != null && _projectName != null)
            {
                _tn.Text = _taskName;
                _pn.Text = _projectName;
            }

            if (_timeLog == null)
            {
                return(v);
            }

            string c = Util.GetInstance().GetLocalTime(_timeLog.StartDate).ToString("g");

            _startTime.Text     = (c);
            _interruptTime.Text = "" + TimeSpan.FromMinutes(_timeLog.InterruptTime).ToString(@"hh\:mm");
            _comment.Text       = _timeLog.Comment ?? "-";
            _deltaTime.Text     = "" + TimeSpan.FromMinutes(_timeLog.LoggedTime).ToString(@"hh\:mm");
            return(v);
        }