{
case ID_FOOTER_EDIT:
{
- Person* pPerson = __pAddressbookMgr->GetPersonN(__pPerson->GetId());
- if (pPerson == null)
+ if (!IsPersonExistProcess())
{
- MessageBox messageBox;
- messageBox.Construct(L"Error", "The person doesn't exist.", MSGBOX_STYLE_OK, 0);
- int doModal;
- messageBox.ShowAndWait(doModal);
-
- pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
-
break;
}
- delete pPerson;
-
ArrayList* pPersonIdList = new (std::nothrow) ArrayList();
AppAssert(pPersonIdList);
case ID_FOOTER_DELETE:
{
+ if (!IsPersonExistProcess())
+ {
+ break;
+ }
+
MessageBox messageBox;
int doModal;
messageBox.Construct(L"Warning", "Do you really want to delete?", MSGBOX_STYLE_OKCANCEL, 0);
{
r = RemovePerson();
TryReturnVoid(!IsFailed(r), "Failed to remove the person (%s).", GetErrorMessage(r));
+
if (__previousSceneId == SCENE_EDIT_CONTACT_FORM)
{
pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
{
__previousSceneId = previousSceneId;
- result r = E_SUCCESS;
-
Integer* pRecordId = static_cast <Integer*> (pArgs->GetAt(0));
AppAssert(pRecordId);
PersonId personId = pRecordId->ToInt();
+
pArgs->RemoveAll(true);
delete pArgs;
}
__pPerson = __pAddressbookMgr->GetPersonN(personId);
- r = GetLastResult();
- TryReturnVoid(!IsFailed(r), "Failed to get the Person (%s).", GetErrorMessage(r));
-
- GetContactsDetail();
+ if (__pPerson != null)
+ {
+ GetContactsDetail();
+ }
}
}
result r = E_SUCCESS;
Header* pHeader = GetHeader();
- Person* pPerson = __pAddressbookMgr->GetPersonN(__pPerson->GetId());
- if (pPerson == null)
+ if (!IsPersonExistProcess())
{
- SceneManager* pSceneManager = SceneManager::GetInstance();
- AppAssert(pSceneManager);
-
- MessageBox messageBox;
- messageBox.Construct(L"Error", "The person doesn't exist.", MSGBOX_STYLE_OK, 0);
- int doModal;
- messageBox.ShowAndWait(doModal);
-
- pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
-
- return r;
+ return E_FAILURE;
}
- if (pPerson->IsFavorite() == true)
+ if (__pPerson->IsFavorite() == true)
{
- r = pPerson->SetAsFavorite(false);
- delete pPerson;
+ r = __pPerson->SetAsFavorite(false);
TryReturn(!IsFailed(r), r, "Failed to set person as favorite. (%s)", GetErrorMessage(r));
pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, __normalTextColor);
else
{
- r = pPerson->SetAsFavorite(true);
- delete pPerson;
+ r = __pPerson->SetAsFavorite(true);
TryReturn(!IsFailed(r), r, "Failed to set person as favorite. (%s)", GetErrorMessage(r));
pHeader->SetButtonTextColor(BUTTON_ITEM_STATUS_NORMAL, __favoriteTextColor);
return r;
}
+
+result
+DetailViewForm::IsPersonExistProcess(void)
+{
+ Person* pPerson = null;
+
+ if (__pPerson != null)
+ {
+ pPerson = __pAddressbookMgr->GetPersonN(__pPerson->GetId());
+ __pPerson = pPerson;
+ }
+
+ if (pPerson == null)
+ {
+ SceneManager* pSceneManager = SceneManager::GetInstance();
+ AppAssert(pSceneManager);
+
+ MessageBox messageBox;
+ messageBox.Construct(L"Error", "The person doesn't exist.", MSGBOX_STYLE_OK, 0);
+ int doModal;
+ messageBox.ShowAndWait(doModal);
+
+ if (__previousSceneId == SCENE_EDIT_CONTACT_FORM)
+ {
+ pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_FORM, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+ }
+ else
+ {
+ pSceneManager->GoBackward(BackwardSceneTransition(__previousSceneId, SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
+ }
+
+ return false;
+ }
+
+ return true;
+}