Пример #1
0
result UsersPanel::Construct(const Tizen::Graphics::Rectangle & rect) {
	result r = E_SUCCESS;
	String searchFriendsText;
	_pLetterNav = new HashMap();
	_pLetterNav->Construct(70);

	RelativeLayout layout;
	r = layout.Construct();
	TryCatch(r == E_SUCCESS, , "Failed layout.Construct");

	r = Panel::Construct(layout, rect, GROUP_STYLE_NONE);
	TryCatch(r == E_SUCCESS, , "Failed Panel::Construct");

	_pIUserSelectedListeners = new ArrayList();
	r = _pIUserSelectedListeners->Construct(1);
	TryCatch(r == E_SUCCESS, , "Failed _pIUserSelectedListeners->Construct");

	_pSearchBar = new SearchBar();
	_pSearchBar->Construct(Rectangle(0, 0, rect.width, 90));
	TryCatch(r == E_SUCCESS, , "Failed _pIUserSelectedListeners->Construct");

	VKUApp::GetInstance()->GetAppResource()->GetString(L"IDS_SEARCH_FRIENDS", searchFriendsText);
	_pSearchBar->SetGuideText(searchFriendsText);
	_pSearchBar->AddSearchBarEventListener(*this);
	_pSearchBar->AddTextEventListener(*this);

	_pTableView = new GroupedTableView();
	_pTableView->Construct(Rectangle(0, 0, rect.width, rect.height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL);
	TryCatch(r == E_SUCCESS, , "Failed _pTableView->Construct");
//	r = _pTableView->SetFastScrollIndex(L"abcdefghijklmnopqrstuvwxyzабвгдежзиклмнопрстуфхцчшщ", false);
	TryCatch(r == E_SUCCESS, , "Failed _pTableView->SetFastScrollIndex");
	_pTableView->SetItemProvider(this);
	_pTableView->AddFastScrollListener(*this);
	_pTableView->AddGroupedTableViewItemEventListener(*this);

	r = AddControl(_pSearchBar);
	TryCatch(r == E_SUCCESS, , "Failed AddControl _pSearchBar");
	r = AddControl(_pTableView);
	TryCatch(r == E_SUCCESS, , "Failed AddControl _pTableView");

	layout.SetRelation(*_pSearchBar, this, RECT_EDGE_RELATION_TOP_TO_TOP);
	layout.SetHorizontalFitPolicy(*_pSearchBar, FIT_POLICY_PARENT);

	layout.SetRelation(*_pTableView, _pSearchBar, RECT_EDGE_RELATION_TOP_TO_BOTTOM);
	layout.SetVerticalFitPolicy(*_pTableView, FIT_POLICY_PARENT);
	layout.SetHorizontalFitPolicy(*_pTableView, FIT_POLICY_PARENT);

	_pCurrentModel = null;

	return r;
CATCH:
	AppLogException("UsersPanel::Construct is failed. %s", GetErrorMessage(r));
	return r;
}
result
ShoppingListTab1::OnInitializing(void)
{
	result r = E_SUCCESS;

	pItemContext = new (std::nothrow) ListContextItem();
	pItemContext->Construct();
	pItemContext->AddElement(ID_CNTX_BTN_DELETE, "Delete");

	// Layout setting
	const Form* pForm = dynamic_cast< Form* >(GetParent());
	if (pForm)
	{
		RelativeLayout* pRelativeLayout = dynamic_cast< RelativeLayout* >(pForm->GetLandscapeLayoutN());
		if (pRelativeLayout)
		{
			pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
			pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
			delete pRelativeLayout;
		}
		pRelativeLayout = dynamic_cast< RelativeLayout* >(pForm->GetPortraitLayoutN());
		if (pRelativeLayout)
		{		
			pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
			pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
			delete pRelativeLayout;
		}
	}

	pListview1 = static_cast<ListView*>(GetControl(IDC_LISTVIEW1));
	if(pListview1)
	{
		pListview1->AddListViewItemEventListener(*this);
		pListview1->SetItemProvider(*this);
	}

	theTableLists.SetRowBulder(this);

	GetLists();


	return r;
}
Пример #3
0
result
ProjectGiraffeTab4::OnInitializing(void)
{
	result r = E_SUCCESS;

	// Layout setting
	const Form* pForm = dynamic_cast<Form*>(GetParent());
	RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
	pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
	pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
	delete pRelativeLayout;
	pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
	pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
	pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
	delete pRelativeLayout;

	User::currentUser()->addListener(this);

	return r;
}
Пример #4
0
result
ProjectGiraffeTab1::OnInitializing(void)
{
	result r = E_SUCCESS;

	// Layout setting
	const Form* pForm = dynamic_cast<Form*>(GetParent());
	Rectangle formBounds = pForm->GetClientAreaBounds();
	RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
	pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
	pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
	delete pRelativeLayout;
	pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
	pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
	pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
	delete pRelativeLayout;

	// Create tableView
	_tableView = new TableView();
	_tableView->Construct(Rectangle(0,0,formBounds.width, formBounds.height), \
			true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
	_tableView->SetItemProvider(this);
	_tableView->AddTableViewItemEventListener(*this);
	AddControl(*_tableView);


	_items = new (std::nothrow) ArrayList();

	_pValueList = new (std::nothrow) LinkedList();

	_pJsonKeyList = new (std::nothrow) ArrayList();
	_pJsonKeyList->Construct();
	_isArray = 0;
	_loadingPopupThread =  new (std::nothrow) LoadingPopupThread();
	//_loadingPopupThread->Construct();

	return r;
}
result VKUDialogsPanel::OnInitializing(void) {
	result r = E_SUCCESS;

	// Layout setting
	const Form* pForm = dynamic_cast<Form*>(GetParent());
	RelativeLayout* pRelativeLayout =
			dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
	pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
	pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
	delete pRelativeLayout;
	pRelativeLayout =
			dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
	pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
	pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
	delete pRelativeLayout;

	pDialogTableView = static_cast<TableView*>(GetControl(IDC_TABLEVIEW_DIALOGS));


	_searchBar = static_cast<SearchBar*>(GetControl(IDC_SEARCHBAR1));
	_searchBar->AddSearchBarEventListener(*pProvider);
	_searchBar->AddTextEventListener(*pProvider);

	Panel * pPullToRefreshBar = dynamic_cast<Panel *>(GetControl(IDC_PANEL_PULL_PROGRESS));

	pProvider->Construct(pDialogTableView);
	pDialogTableView->SetItemProvider(pProvider);
	pDialogTableView->AddTableViewItemEventListener(*pProvider);

	pProvider->LoadData();

	_pullToRefresh.Construct(pDialogTableView, pPullToRefreshBar, this, PULL_TO_REFRESH_DIRECTION_TOP);
	SetPropagatedTouchEventListener(&_pullToRefresh);

	return r;
}
result MessageDocElement::Construct(const Tizen::Graphics::Rectangle & rect, JsonObject * docObject, int out) {
	result r = E_SUCCESS;

	_pDocObject = docObject->CloneN();

	RelativeLayout layout;
	layout.Construct();

	AppResource* pAppResource = VKUApp::GetInstance()->GetAppResource();

	String docName;
	JsonParseUtils::GetString(*docObject, L"title", docName);

	int size;
	JsonParseUtils::GetInteger(*docObject, L"size", size);

	r = Panel::Construct(layout, rect);
	r = SetSize(Dimension(rect.width, rect.height));

	const String filename = (out == 1) ? L"doc_out.#.png" : L"doc_in.#.png";

	_pBitmap = pAppResource->GetBitmapN(filename);
//	TryCatch(GetLastResult() == E_SUCCESS, r = GetLastResult(), "Failed pAppResource->GetBitmapN");

	_pIcon = new LocalImageView();
	_pIcon->Construct(Rectangle(0, 0, 72, 72), L"icon_document.png");

	r = AddControl(_pIcon);

	Label *docLabel = new Label();
	docLabel->Construct(Rectangle(0, 0, rect.width-72, 35), docName);
	docLabel->SetMargin(0, 0);
	docLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
	docLabel->SetTextConfig(30, LABEL_TEXT_STYLE_BOLD);

	r = AddControl(docLabel);

	Label *sizeLabel = new Label();
	sizeLabel->Construct(Rectangle(0, 0, rect.width-72, 30), GetSizeString(size));
	sizeLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
	sizeLabel->SetTextConfig(25, LABEL_TEXT_STYLE_NORMAL);
	sizeLabel->SetMargin(0, 0);

	r = AddControl(sizeLabel);

	layout.SetRelation(*_pIcon, this, RECT_EDGE_RELATION_LEFT_TO_LEFT);
	layout.SetCenterAligned(*_pIcon, CENTER_ALIGN_VERTICAL);
	layout.SetMargin(*_pIcon, 0, 0, 0, 0);

	layout.SetRelation(*docLabel, this, RECT_EDGE_RELATION_TOP_TO_TOP);
	layout.SetRelation(*docLabel, this, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
	layout.SetRelation(*docLabel, _pIcon, RECT_EDGE_RELATION_LEFT_TO_RIGHT);
	layout.SetMargin(*docLabel, 0, 10, 10, 0);
	layout.SetHorizontalFitPolicy(*docLabel, FIT_POLICY_CONTENT);

	layout.SetRelation(*sizeLabel, docLabel, RECT_EDGE_RELATION_TOP_TO_BOTTOM);
	layout.SetRelation(*sizeLabel, _pIcon, RECT_EDGE_RELATION_LEFT_TO_RIGHT);
	layout.SetMargin(*sizeLabel, 0, 10, 5, 0);
	layout.SetHorizontalFitPolicy(*sizeLabel, FIT_POLICY_CONTENT);

	SetSize(Dimension(rect.width, 90));

	SetPropagatedTouchEventListener(this);

	return r;
}
TableViewItem* VKUMessagesListItemProvider::CreateItem(int index, int itemWidth) {
	result r;
	AppLog("VKUMessagesListItemProvider::CreateItem");

	RoundedAvatar *pAvatar; // NOTE: used only if chat and message is out==0
	MessageBubble* pMessageBubble;
	RelativeLayout itemLayout;
	Color bgColor;

	JsonObject *itemObject;
	IJsonValue *itemValue;
	TableViewItem* pItem;
	JsonNumber outNumber;

	ArrayList *pMessageElements;

	Label *pTimeStamp;
	String timespampText;
	int timestampValue;

	String messageText(L"no text????");
	int out = 0, readState = 0;

	// reverse list
	int reversedIndex = _messagesJson->GetCount() - 1 - index;
	AppLog("Item %d of %d", reversedIndex, GetItemCount());

	// get message string
	r = _messagesJson->GetAt(reversedIndex, itemValue);
	TryCatch(r == E_SUCCESS, , "Failed GetAt");
	itemObject = static_cast<JsonObject *>(itemValue);

	JsonParseUtils::GetInteger(*itemObject, L"out", out);
	JsonParseUtils::GetInteger(*itemObject, L"date", timestampValue);
	JsonParseUtils::GetInteger(*itemObject, L"read_state", readState);

	TimeUtils::GetDialogsTime(timestampValue, timespampText);

	// create rich text panel
	AppLog("Message is %d == out", out);
	pMessageBubble = new MessageBubble();
	r = pMessageBubble->Construct(Dimension(itemWidth, LIST_HEIGHT));
	TryCatch(r == E_SUCCESS, , "Failed Construct RichTextPanel");

	pMessageBubble->SetOut(out);
	AppLog("RTPanel created and constructed");
	itemLayout.Construct();

	// get available elements
	pMessageElements = GetMessageElementsN(itemObject, itemWidth);

	// message text element
	for (int i=0; i<pMessageElements->GetCount(); i++) {
		AppLog("Adding element %d to pItem", i);
		MessageElement *pElement = static_cast<MessageElement *>(pMessageElements->GetAt(i));
		pMessageBubble->AddElement(pElement);
		AppLog("Added element %d to pItem with size of %dx%d", i, pElement->GetWidth(), pElement->GetHeight());
	}

	// timestamp label
	pTimeStamp = new Label();
	pTimeStamp->Construct(Rectangle(0, 0, 100, 28), timespampText);
	pTimeStamp->SetTextConfig(28, LABEL_TEXT_STYLE_NORMAL);
	pTimeStamp->SetTextColor(Color(TIMESTAMP_TEXT_COLOR, false));

	// create table item
	pItem = new TableViewItem();
	r = pItem->Construct(itemLayout, Dimension(itemWidth, pMessageBubble->GetHeight() + 2*BUBBLE_VERTICAL_MARGIN));
	TryCatch(r == E_SUCCESS, , "Failed GetAt");

	if (out == 0 && _peerId > 2000000000) {
		int fromId;
		JsonParseUtils::GetInteger(*itemObject, L"from_id", fromId);
		AppLog("Finding avatar for %d", fromId);

		pAvatar = new RoundedAvatar(AVATAR_NORMAL);
		String * avatarUrl = static_cast<String *>(_pUserIdAvatarMap->GetValue(Integer(fromId)));

		pAvatar->Construct(Rectangle(0, 0, 80, 80), *avatarUrl);
		r = pItem->AddControl(pAvatar);
		itemLayout.SetRelation(*pAvatar, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
		itemLayout.SetRelation(*pAvatar, pItem, RECT_EDGE_RELATION_TOP_TO_TOP);
		itemLayout.SetMargin(*pAvatar, 10, 0, 10, 0);
	}

	// add rich text panel to table item
	r = pItem->AddControl(pMessageBubble);
	TryCatch(r == E_SUCCESS, , "Failed AddControl");
	r = pItem->AddControl(pTimeStamp);

	itemLayout.SetCenterAligned(*pMessageBubble, CENTER_ALIGN_VERTICAL);
	itemLayout.SetHorizontalFitPolicy(*pTimeStamp, FIT_POLICY_CONTENT);

	if (out == 1) {
		itemLayout.SetRelation(*pMessageBubble, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
		itemLayout.SetMargin(*pMessageBubble, 0, 10, 0, 0);

		itemLayout.SetRelation(*pTimeStamp, *pMessageBubble, RECT_EDGE_RELATION_RIGHT_TO_LEFT);
		itemLayout.SetRelation(*pTimeStamp, *pItem, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
		itemLayout.SetMargin(*pTimeStamp, 0, 10, 0, 30);
	} else {
		if (_peerId > 2000000000) {
			itemLayout.SetRelation(*pMessageBubble, pAvatar, RECT_EDGE_RELATION_LEFT_TO_RIGHT);
			itemLayout.SetMargin(*pMessageBubble, 10, 0, 0, 0);
		} else {
			itemLayout.SetRelation(*pMessageBubble, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
			itemLayout.SetMargin(*pMessageBubble, 10, 0, 0, 0);
		}

		itemLayout.SetRelation(*pTimeStamp, *pMessageBubble, RECT_EDGE_RELATION_LEFT_TO_RIGHT);
		itemLayout.SetRelation(*pTimeStamp, *pItem, RECT_EDGE_RELATION_BOTTOM_TO_BOTTOM);
		itemLayout.SetMargin(*pTimeStamp, 10, 0, 0, 30);
	}

	// colors
	if (out == 1 && readState == 0) {
		bgColor = Color(LIST_ITEM_UNREAD_COLOR, false);
	} else {
		bgColor = Color::GetColor(COLOR_ID_BLACK);
	}

	pItem->SetBackgroundColor(bgColor, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
	pItem->SetBackgroundColor(bgColor, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
	pItem->SetBackgroundColor(bgColor, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);

	pItem->RequestRedraw(true);

	AppLog("Returning item");
	return pItem;

CATCH:
	AppLogException("$${Function:CreateItem} is failed. %s", GetErrorMessage(r));
	return null;
}