Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 19
Registered: ‎05-09-2013
My Device: Z10
My Carrier: None

ImageTracker in C++ no fade effect on ImageView

[ Edited ]

Hi,

 

I have got a bb::cascades::ImageTracker class declared in C++. Once I obtain image data form a http url I create a bb::cascades::Image, set it on the ImageTracker and wait for it's ResourceState changed signal to fire. When the State is Loaded, I set the image to the corresponding ImageView. Unfortunately I don't get the Fade Effect. Even specifying an explicit ImageViewLoadEffect.Subtle/FadeZoom, etc. gives no difference.

 

To add more details, I am using a modified class that is inspired by this one:

https://github.com/RileyGB/BlackBerry10-Samples/tree/master/WebImageViewSample/src

 

The major difference is that I have embedded an ImageTracker inside the WebImageView so that I know whether an Image was loaded and decoded correctly:

 

void WebImageView::onReplyFinished() {
	QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
	QNetworkReply::NetworkError error = reply->error();
	if (error != QNetworkReply::OperationCanceledError)
	{
		if (error == QNetworkReply::NoError)
		{
			if (m_url == reply->url())
			{
				m_imageTracker->setImage(bb::cascades::Image(reply->readAll()));
			} 
		}
		else
		{
			m_error = true;
			m_errorReason = reply->errorString();
			m_progress = 0;
			setLoading(false);
		}
	}
	reply->deleteLater();
}

 

void WebImageView::onStateChanged(bb::cascades::ResourceState::Type state)
{
	if(state == bb::cascades::ResourceState::Loaded)
    {
        this->setImage(m_imageTracker->image());
        setLoading(false);
    }
	else if (state == bb::cascades::ResourceState::ErrorNotFound      ||
			 state == bb::cascades::ResourceState::ErrorInvalidFormat ||
			 state == bb::cascades::ResourceState::ErrorMemory)
	{
		m_error = true;
		m_errorReason = "Image Error";
		setLoading(false);
	}
}

 

WebImageView { 
	loadEffect: ImageViewLoadEffect.FadeZoom 
	preferredHeight: 500
	preferredWith: 500
	url: ListItemData.imageUrl 
}