public void Dispose()
 {
     masterLayout = null;
     progressBar = null;
     listContainer = null;
     gemsList = null;
     mainTitleBar = null;
     masterScroll = null;
     masterStack = null;
     headingLayout = null;
     gemsGoalsObject = null;
     pendingGoalsObject = null;
     GC.Collect();
 }
        public bool SaveCompletedGoalsDetails(GemsGoalsObject completedGoals)
        {
            try
            {
                if (completedGoals == null || completedGoals.resultarray == null)
                {
                    return false;
                }

                List<CompletedGoalsDetailsDB> listCompletedGoalsDetails = new List<CompletedGoalsDetailsDB>();
                List<CompletedActionTitle> listCompletedActionTitle = new List<CompletedActionTitle>();

                foreach (var item in completedGoals.resultarray)
                {

                    // goals details
                    CompletedGoalsDetailsDB goal = new CompletedGoalsDetailsDB()
                    {
                        goal_details = item.goal_details,
                        goal_id = item.goal_id,
                        goal_media = item.goal_media,
                        user_id = item.user_id,
                        code = completedGoals.code,
                        mediapath = completedGoals.mediapath,
                        mediathumbpath = completedGoals.mediathumbpath,
                        noimageurl = completedGoals.noimageurl
                    };
                    listCompletedGoalsDetails.Add(goal);

                    foreach (var itemTitle in item.action_title)
                    {
                        CompletedActionTitle title = new CompletedActionTitle() { goal_id = itemTitle.goal_id,  goalaction_id = itemTitle.goalaction_id, action_title = itemTitle.action_title };
                        listCompletedActionTitle.Add(title);
                    }

                }

                Connection.InsertAll(listCompletedGoalsDetails);
                Connection.InsertAll(listCompletedActionTitle);

                listCompletedActionTitle.Clear();
                listCompletedGoalsDetails.Clear();

                listCompletedActionTitle = null;
                listCompletedGoalsDetails = null;

                return true;
            }
            catch (Exception ex)
            {

                return false;
            }

        }
        async void OnAppearing(object sender, EventArgs e)
        {
			if (gemsGoalsObject != null && gemsGoalsObject.resultarray != null && gemsGoalsObject.resultarray.Count > 0)
				return;

            IProgressBar progress = DependencyService.Get<IProgressBar>();
            progress.ShowProgressbar("Loading pending items..");


            try
            {
			    pendingGoalsObject = await ServiceHelper.GetAllPendingGoalsAndActions ();
				if( pendingGoalsObject == null || pendingGoalsObject.resultarray == null )
				{
					progress.HideProgressbar();
					var success = await DisplayAlert (Constants.ALERT_TITLE, "Error in fetching Pending goals", Constants.ALERT_OK, Constants.ALERT_RETRY);
					if (!success) 
					{
						OnAppearing (sender, EventArgs.Empty);
						return;
					} 
					else
					{
                        if (Device.OS != TargetPlatform.WinPhone)
                            pendingGoalsObject = App.Settings.GetPendingGoalsObject();
						progress.HideProgressbar ();
					}
				}
                else
                {
                    App.Settings.DeleteAllPendingGoals();
                    App.Settings.SavePendingGoalsDetails( pendingGoalsObject );
                }

				gemsGoalsObject = await ServiceHelper.GetAllMyGoals();
				if( gemsGoalsObject == null || gemsGoalsObject.resultarray == null )
				{
					var success = await DisplayAlert (Constants.ALERT_TITLE, "Error in fetching all goals", Constants.ALERT_OK, Constants.ALERT_RETRY);
					if (!success) 
					{
						OnAppearing (sender, EventArgs.Empty);
						return;
					} 
					else
					{
                        if (Device.OS != TargetPlatform.WinPhone)
                            gemsGoalsObject = App.Settings.GetCompletedGoalsObject();
                        progress.HideProgressbar();
					}
				}
                else
                {
                    App.Settings.DeleteAllCompletedGoals();
                    App.Settings.SaveCompletedGoalsDetails(gemsGoalsObject);
                }
				
				if( pendingGoalsObject.resultarray.Count  + gemsGoalsObject.resultarray.Count < 30 )
				{
					#region PENDING GOALS
					CreatePendingGoalsView( true );
					#endregion

					#region ALL GOALS HEADING
					CreateAllGoalsHeading();
					#endregion

					#region ALL GOALS
					CreateAllGoalsView();
					#endregion
				}
				else if( pendingGoalsObject.resultarray.Count > 30 )
				{
					pendingGoalsObject.resultarray = pendingGoalsObject.resultarray.Skip(0).Take(30).ToList();
					#region PENDING GOALS
					CreatePendingGoalsView( true );
					#endregion
				}



                masterScroll.Padding = new Thickness(10, 10, 10, 0);
                masterScroll.Scrolled += OnScroll;
                masterScroll.Content = masterStack;

                masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
                //  masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));
                masterLayout.AddChildToLayout(masterScroll, 0, 10);
                Content = masterLayout;


            }
            catch (Exception)
            {
                
            }
            progress.HideProgressbar();
        }
		public bool SaveAllGoalsGems(  GemsGoalsObject gemsGoals )
		{
			try
			{
				if (gemsGoals == null || gemsGoals.resultarray == null)
				{
					return false;
				}

				List<ActionTitle> listActionTitle = new List<ActionTitle>();
				List<ActionDetail> listActionDetails = new List<ActionDetail>();
				List<ActionMedia> listActionMedia = new List<ActionMedia>();
				List<ActionDatetime> listActionDatetime = new List<ActionDatetime>();
				List<GemsGoalsDetailsDB> listGoals = new List<GemsGoalsDetailsDB>();
				foreach (var item in gemsGoals.resultarray )
				{
					listActionTitle.Clear();
					listActionDetails.Clear();
					listActionMedia.Clear();
					listActionDatetime.Clear();
					listGoals.Clear();

					// Emotion details
					GemsGoalsDetailsDB emotion = new GemsGoalsDetailsDB(){ code = gemsGoals.code, goal_id = item.goal_id, goal_title = item.goal_title,
						mediapath = gemsGoals.mediapath, mediathumbpath = gemsGoals.mediathumbpath, noimageurl = gemsGoals.noimageurl, user_id = item.user_id};
					listGoals.Add(emotion);
					Connection.InsertAll(listGoals);

					if( item.action_title != null && item.action_title.Count > 0 )
					{
						// event title
						foreach (var actionTitleItem in item.action_title)
						{
							actionTitleItem.goal_id= item.goal_id;
							listActionTitle.Add(actionTitleItem);

						}
						Connection.InsertAll(listActionTitle);
					}


					if( item.action_details != null && item.action_details.Count > 0 )
					{
						// event details
						foreach (var actionDetailItem in item.action_details)
						{
							actionDetailItem.goal_id = item.goal_id;
							listActionDetails.Add(actionDetailItem);
						}
						Connection.InsertAll(listActionDetails);
					}

					if( item.action_media != null && item.action_media.Count > 0 )
					{
						// event media
						foreach (var actionMediaItem in item.action_media)
						{
							actionMediaItem.goal_id = item.goal_id;
							listActionMedia.Add(actionMediaItem);
						}
						Connection.InsertAll(listActionMedia);
					}


					if( item.action_datetime != null && item.action_datetime.Count > 0 )
					{
						// event date and time
						foreach (var actionDateItem in item.action_datetime)
						{
							actionDateItem.goal_id = item.goal_id;
							listActionDatetime.Add(actionDateItem);
						}
						Connection.InsertAll(listActionDatetime);
					}


				}

				listGoals.Clear();


				listGoals = null;
				listActionDatetime = null;
				listActionDetails = null;
				listActionMedia = null;
				listActionTitle = null;
				return true;
			}
			catch (Exception ex)
			{

				throw;
			}

		}
        public GemsGoalsObject GetCompletedGoalsObject()
        {
            try
            {
                GemsGoalsObject masterObject = new GemsGoalsObject();

                List<CompletedActionTitle> listCompletedActionTitle = new List<CompletedActionTitle>();
                List<CompletedGoalsDetailsDB> listCompletedDetailsDB = new List<CompletedGoalsDetailsDB>();

                listCompletedActionTitle = (from t in Connection.Table<CompletedActionTitle>() select t).ToList();
                listCompletedDetailsDB = (from t in Connection.Table<CompletedGoalsDetailsDB>() select t).ToList();

                masterObject.resultarray = new List<GemsGoalsDetails>();

                foreach (var item in listCompletedDetailsDB)
                {
                    GemsGoalsDetails resultArray = new GemsGoalsDetails();
                    resultArray.action_title = new List<ActionTitle>();

                    resultArray.user_id = item.user_id;
                    resultArray.goal_id = item.goal_id;
                    resultArray.goal_title = item.goal_title;
                    resultArray.goal_details = item.goal_details;
                    resultArray.goal_media = item.goal_media;
                    masterObject.code = item.code;
                    masterObject.mediapath = item.mediapath;
                    masterObject.mediathumbpath = item.mediathumbpath;
                    masterObject.noimageurl = item.noimageurl;


                    // Title
                    foreach (var titeObject in listCompletedActionTitle)
                    {
                        ActionTitle title = new ActionTitle() { action_title = titeObject.action_title, goal_id = titeObject.goal_id, goalaction_id = titeObject.goalaction_id };
                        if (titeObject.goal_id == item.goal_id)
                            resultArray.action_title.Add(title);
                    }

                    masterObject.resultarray.Add(resultArray);
                }


                masterObject.code = (listCompletedDetailsDB != null && listCompletedDetailsDB.Count > 0) ? listCompletedDetailsDB[0].code : "";
                masterObject.noimageurl = (listCompletedDetailsDB != null && listCompletedDetailsDB.Count > 0) ? listCompletedDetailsDB[0].noimageurl : "";
                masterObject.mediapath = (listCompletedDetailsDB != null && listCompletedDetailsDB.Count > 0) ? listCompletedDetailsDB[0].mediapath : "";
                masterObject.mediathumbpath = (listCompletedDetailsDB != null && listCompletedDetailsDB.Count > 0) ? listCompletedDetailsDB[0].mediathumbpath : "";
                return masterObject;
            }
            catch (Exception)
            {

                return null;
            }

        }
		public GemsGoalsObject GetGemsGoalsObject()
		{
            try
            {
                GemsGoalsObject masterObject = new GemsGoalsObject();


                List<ActionTitle> listActionTitle = new List<ActionTitle>();
                List<ActionDetail> listActionDetails = new List<ActionDetail>();
                List<ActionMedia> listActionMedia = new List<ActionMedia>();
                List<ActionDatetime> listActionDatetime = new List<ActionDatetime>();
                List<GemsGoalsDetailsDB> listGoals = new List<GemsGoalsDetailsDB>();
                List<GemsGoalsDetails> gemsGoals = new List<GemsGoalsDetails>();

                listActionTitle = (from t in Connection.Table<ActionTitle>() select t).ToList();
                listActionDetails = (from t in Connection.Table<ActionDetail>() select t).ToList();
                listActionMedia = (from t in Connection.Table<ActionMedia>() select t).ToList();
                listActionDatetime = (from t in Connection.Table<ActionDatetime>() select t).ToList();
                listGoals = (from t in Connection.Table<GemsGoalsDetailsDB>() select t).ToList();

                masterObject.resultarray = new List<GemsGoalsDetails>();
                foreach (var item in listGoals)
                {
                    GemsGoalsDetails resultArray = new GemsGoalsDetails();

                    resultArray.user_id = item.user_id;
                    resultArray.goal_id = item.goal_id;
                    resultArray.goal_title = item.goal_title;

                    resultArray.action_title = new List<ActionTitle>();
                    resultArray.action_details = new List<ActionDetail>();
                    resultArray.action_datetime = new List<ActionDatetime>();
                    resultArray.action_media = new List<ActionMedia>();

                    // Title
                    foreach (var titeObject in listActionTitle)
                    {
                        if (titeObject.goal_id == item.goal_id)
                            resultArray.action_title.Add(titeObject);
                    }

                    // Details
                    foreach (var detailsObject in listActionDetails)
                    {
                        if (detailsObject.goal_id == item.goal_id)
                            resultArray.action_details.Add(detailsObject);
                    }

                    // date and time
                    foreach (var dateObject in listActionDatetime)
                    {
                        if (dateObject.goal_id == item.goal_id)
                            resultArray.action_datetime.Add(dateObject);
                    }

                    // media
                    foreach (var mediaObject in listActionMedia)
                    {
                        if (mediaObject.goal_id == item.goal_id)
                            resultArray.action_media.Add(mediaObject);
                    }

                    masterObject.resultarray.Add(resultArray);
                }


                masterObject.code = (listGoals != null && listGoals.Count > 0) ? listGoals[0].code : "";
                masterObject.noimageurl = (listGoals != null && listGoals.Count > 0) ? listGoals[0].noimageurl : "";
                masterObject.mediapath = (listGoals != null && listGoals.Count > 0) ? listGoals[0].mediapath : "";
                masterObject.mediathumbpath = (listGoals != null && listGoals.Count > 0) ? listGoals[0].mediathumbpath : "";
                return masterObject;
            }
            catch (Exception)
            {
                
                throw;
            }
		
		}
        async void OnAppearing(object sender, EventArgs e)
        {
			if (commonGoalsObject != null && commonGoalsObject.GoalsDetails != null && commonGoalsObject.GoalsDetails.Count > 0)
				return;

	
			commonGoalsObject = null;
			commonGoalsObject = new CommonGoalsObject ();
			commonGoalsObject.GoalsDetails = new List<CommonGoalsDetails>();

            IProgressBar progress = DependencyService.Get<IProgressBar>();
            progress.ShowProgressbar("Loading pending items..");


            try
            {
			    pendingGoalsObject = await ServiceHelper.GetAllPendingGoalsAndActions ();
				if( pendingGoalsObject == null || pendingGoalsObject.resultarray == null )
				{
					var success = await DisplayAlert (Constants.ALERT_TITLE, "Error in fetching Pending goals", Constants.ALERT_OK, Constants.ALERT_RETRY);
					if (!success) 
					{
						OnAppearing (sender, EventArgs.Empty);
						return;
					} 
					else
					{
                        if (Device.OS != TargetPlatform.WinPhone)
                            pendingGoalsObject = App.Settings.GetPendingGoalsObject();
						progress.HideProgressbar ();
					}
				}
                else
                {

					foreach (var goalItem in pendingGoalsObject.resultarray) 
					{
						CommonGoalsDetails commonGoalsDetails = new CommonGoalsDetails();
						commonGoalsDetails.GoalMedia = goalItem.goal_media;
						commonGoalsDetails.GoalTitle = goalItem.goal_title;
						commonGoalsDetails.GoalID = goalItem.goal_id;
						commonGoalsDetails.GoalDesc = goalItem.goal_details;
						commonGoalsDetails.IsPending = true;
						commonGoalsDetails.ActionTitle = new List<CommonActionTitle>();


						foreach (var actionItem in goalItem.pending_action_title) 
						{
							CommonActionTitle commonTitle = new CommonActionTitle();
							commonTitle.actionstatus_id = actionItem.actionstatus_id;
							commonTitle.action_title = actionItem.action_title;
							commonTitle.goalaction_id = actionItem.goalaction_id;
							commonTitle.goal_id = actionItem.goal_id;
							commonTitle.savedgoal_id = actionItem.savedgoal_id;

							commonGoalsDetails.ActionTitle.Add( commonTitle );						
						}

						if ( null == commonGoalsObject.GoalsDetails.Find( tst => tst.GoalID == commonGoalsDetails.GoalID ))
							commonGoalsObject.GoalsDetails.Add( commonGoalsDetails );
					}
                    App.Settings.DeleteAllPendingGoals();
                    App.Settings.SavePendingGoalsDetails( pendingGoalsObject );
                }

				commonGoalsObject.GoalsDetails.Add( new CommonGoalsDetails{ GoalID="header"} );

				gemsGoalsObject = await ServiceHelper.GetAllMyGoals();
				if( gemsGoalsObject == null || gemsGoalsObject.resultarray == null )
				{
					var success = await DisplayAlert (Constants.ALERT_TITLE, "Error in fetching all goals", Constants.ALERT_OK, Constants.ALERT_RETRY);
					if (!success) 
					{
						OnAppearing (sender, EventArgs.Empty);
						return;
					} 
					else
					{
                        if (Device.OS != TargetPlatform.WinPhone)
                            gemsGoalsObject = App.Settings.GetCompletedGoalsObject();
                        progress.HideProgressbar();
					}
				}
                else
                {
					foreach (var allGoalItem in gemsGoalsObject.resultarray) 
					{
						CommonGoalsDetails commonGoalsDetails = new CommonGoalsDetails();
						commonGoalsDetails.GoalMedia = allGoalItem.goal_media;
						commonGoalsDetails.GoalTitle = allGoalItem.goal_title;
						commonGoalsDetails.GoalID = allGoalItem.goal_id;
						commonGoalsDetails.GoalDesc = allGoalItem.goal_details;
						commonGoalsDetails.ActionTitle = new List<CommonActionTitle>();
						commonGoalsDetails.IsPending = false;

						if( allGoalItem.action_title != null && allGoalItem.action_title.Count > 0 )
						{
							foreach (var allActionItem in allGoalItem.action_title) 
							{
								CommonActionTitle commonTitle = new CommonActionTitle();
								commonTitle.action_title = allActionItem.action_title;
								commonTitle.goalaction_id = allActionItem.goalaction_id;
								commonTitle.goal_id = allActionItem.goal_id;
								commonGoalsDetails.ActionTitle.Add( commonTitle );						
							}
						}


						if ( null == commonGoalsObject.GoalsDetails.Find( tst => tst.GoalID == commonGoalsDetails.GoalID ))
						commonGoalsObject.GoalsDetails.Add( commonGoalsDetails );
					}

                    App.Settings.DeleteAllCompletedGoals();
                    App.Settings.SaveCompletedGoalsDetails(gemsGoalsObject);
                }


				allCommonGoalsObject = new CommonGoalsObject();
				allCommonGoalsObject.GoalsDetails = commonGoalsObject.GoalsDetails.Skip(0).Take( commonGoalsObject.GoalsDetails.Count ).ToList();
			


				/*if( pendingGoalsObject.resultarray.Count  + gemsGoalsObject.resultarray.Count < 30 )
				{
					#region PENDING GOALS
					CreatePendingGoalsView( true );
					#endregion

					#region ALL GOALS HEADING
					CreateAllGoalsHeading();
					#endregion

					#region ALL GOALS
					CreateAllGoalsView();
					#endregion
				}
				else if( pendingGoalsObject.resultarray.Count > 30 )
				{
					pendingGoalsObject.resultarray = pendingGoalsObject.resultarray.Skip(0).Take(30).ToList();
					#region PENDING GOALS
					CreatePendingGoalsView( true );
					#endregion
				}*/

				commonGoalsObject.GoalsDetails = commonGoalsObject.GoalsDetails.Skip(0).Take( MAX_ROWS_AT_A_TIME ).ToList();

				await DownloadMedias();

				RenderGoalsPage( false );



                masterScroll.Padding = new Thickness(10, 10, 10, 0);
                masterScroll.Scrolled += OnScroll;
                masterScroll.Content = masterStack;

                masterLayout.AddChildToLayout(mainTitleBar, 0, 0);
                //  masterLayout.AddChildToLayout(subTitleBar, 0, Device.OnPlatform(9, 10, 10));
                masterLayout.AddChildToLayout(masterScroll, 0, 10);
                Content = masterLayout;


            }
            catch (Exception)
            {
                
            }
            progress.HideProgressbar();
        }
		bool  OnLoadMoreGemsClicked (object sender, EventArgs e)
		{
			try 
			{
				pendingGoalsObject = null;
				gemsGoalsObject = null;

				CommonGoalsDetails lastItem =   commonGoalsObject.GoalsDetails.Last ();

				CommonGoalsObject gemsObj =  new CommonGoalsObject();
				gemsObj.GoalsDetails = allCommonGoalsObject.GoalsDetails.Skip(0).Take( allCommonGoalsObject.GoalsDetails.Count ).ToList();

				int lastRendererItemIndex = gemsObj.GoalsDetails.FindIndex (itm => itm.GoalID == lastItem.GoalID);


				if (lastRendererItemIndex > 0 && ( lastRendererItemIndex + 1 ) < gemsObj.GoalsDetails.Count )
				{
					reachedEnd = false;
					reachedFront = false;
					int itemCountToCopy = gemsObj.GoalsDetails.Count - lastRendererItemIndex;
					itemCountToCopy = (itemCountToCopy > MAX_ROWS_AT_A_TIME) ? MAX_ROWS_AT_A_TIME : itemCountToCopy;
					commonGoalsObject = null;
					commonGoalsObject = new CommonGoalsObject ();
					commonGoalsObject.GoalsDetails = new List<CommonGoalsDetails>();

					commonGoalsObject.GoalsDetails = gemsObj.GoalsDetails.Skip (lastRendererItemIndex).Take (itemCountToCopy).ToList();

					gemsObj = null;


					masterStack.Children.Clear();

					masterScroll.Content = null;
					GC.Collect();




					if( itemCountToCopy < MAX_ROWS_AT_A_TIME )
						RenderGoalsPage( true );
					else
						RenderGoalsPage( false );

					masterScroll.Content = masterStack;
					return true;
				}
				else
				{
					reachedEnd = true;
					return false;
				}

			} 
			catch (Exception ex)
			{
				//DisplayAlert ( Constants.ALERT_TITLE, "Low memory error.", Constants.ALERT_OK );
				return false;
			}

		}
		bool OnLoadPreviousGemsClicked (object sender, EventArgs e)
		{
			try
			{
				pendingGoalsObject = null;
				gemsGoalsObject = null;

				CommonGoalsDetails firstItem =   commonGoalsObject.GoalsDetails.First ();

				CommonGoalsObject gemsObj =  new CommonGoalsObject();
				gemsObj.GoalsDetails = allCommonGoalsObject.GoalsDetails.Skip(0).Take( allCommonGoalsObject.GoalsDetails.Count ).ToList();
			

				int firstRendererItemIndex = gemsObj.GoalsDetails.FindIndex (itm => itm.GoalID == firstItem.GoalID);;//gemsObj.resultarray.IndexOf ( lastItem );
				if (firstRendererItemIndex > 0 && ( firstRendererItemIndex + 1 ) < gemsObj.GoalsDetails.Count )
				{
					reachedEnd = false;
					reachedFront = false;
					int itemCountToCopy = MAX_ROWS_AT_A_TIME;
					commonGoalsObject = null;
					commonGoalsObject = new CommonGoalsObject ();
					commonGoalsObject.GoalsDetails = new List<CommonGoalsDetails>();
					gemsObj.GoalsDetails.RemoveRange( firstRendererItemIndex, gemsObj.GoalsDetails.Count - firstRendererItemIndex );
					if( firstRendererItemIndex > MAX_ROWS_AT_A_TIME )
						gemsObj.GoalsDetails.RemoveRange( 0, firstRendererItemIndex - MAX_ROWS_AT_A_TIME );

					commonGoalsObject.GoalsDetails = gemsObj.GoalsDetails;

					gemsObj = null;

					masterStack.Children.Clear();

					masterScroll.Content = null;
					GC.Collect();

					RenderGoalsPage( false );

					masterScroll.Content = masterStack;
					return true;
				}
				else
				{
					reachedFront = true;
					return false;
				}
			} 
			catch (Exception ex) 
			{
				DisplayAlert ( Constants.ALERT_TITLE, "Low memory error.", Constants.ALERT_OK );
				return false;
			}
		}
        async void OnPendingGoalsTapped(object sender, EventArgs e)
        {
            StackLayout layout = sender as StackLayout;
            if( layout != null && layout.Children != null && layout.Children.Count > 0 )
            {
                Image img = (Image)layout.Children[0];
				if (img != null && img.ClassId != null )
                {
					string[] delimiters = { "&&" };
					string[] clasIDArray = img.ClassId.Split(delimiters, StringSplitOptions.None);
					string selectedSavedGoalID = clasIDArray [1];
					string selectedGoalID = clasIDArray [0];


					if (!string.IsNullOrEmpty (selectedSavedGoalID)) 
					{

						IProgressBar progress = DependencyService.Get<IProgressBar> ();
						progress.ShowProgressbar ( "Completing action...." );

						var change = await ServiceHelper.ChangePendingActionStatus ( selectedSavedGoalID );
						if (!change) 
						{
                            progress.HideProgressbar();
							DisplayAlert (Constants.ALERT_OK, "Failed to complete action", Constants.ALERT_OK);
							return;
						} 
						else
						{
							await DisplayAlert (Constants.ALERT_OK, "Action is completed", Constants.ALERT_OK);
							/*App.masterPage.IsPresented = false;
							App.masterPage.Detail = new NavigationPage(new GoalsPage());
                            await DeletePendingActionRowFromStack(selectedGoalID, selectedSavedGoalID);*/
							masterScroll.Scrolled -= OnScroll;
							commonGoalsObject = null;
							pendingGoalsObject = null;
							gemsGoalsObject = null;
							masterStack.Children.Clear();

							masterScroll.Content = null;

							OnAppearing ( this, EventArgs.Empty );
							masterScroll.Scrolled += OnScroll;

						}
						progress.HideProgressbar ();
					}
	

                }
            }
        }