set icon uri gives me error in maps bb10 - dictionary

I am developing a bb10 app with maps .
I need to set pin on map but when i use:
flag.setIconUri(bb::UIToolkitSupport::absolutePathFromUrl(QUrl("asset:///images/pin.png")));
the project gives an error an is not built.
Does anyone know why this is happening?
void ApplicationUI::addPinAtCurrentMapCenter() {
qDebug("addPinAtCurrentMapCenter");
QmlDocument *qml =
QmlDocument::create("asset:///NearMeMapsController.qml").parent(
this);
qml->setContextProperty("app", this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
QObject* mapViewAsQObject = root->findChild<QObject*>(
QString("mapViewObj"));
if (mapViewAsQObject) {
mapView = qobject_cast<bb::cascades::maps::MapView*>(mapViewAsQObject);
if (mapView) {
GeoLocation* newDrop = new GeoLocation();
newDrop->setLatitude(30.0188);
newDrop->setLongitude(31.4128);
newDrop->setName("Dropped Pin");
newDrop->setDescription("doaa");
Marker flag;
flag.setIconUri(bb::UIToolkitSupport::absolutePathFromUrl(QUrl("asset:///images/pin.png")));
flag.setIconSize(QSize(60, 60));
flag.setLocationCoordinate(QPoint(20, 59));
flag.setCaptionTailCoordinate(QPoint(20, 1));
newDrop->setMarker(flag);
mapView->mapData()->add(newDrop);
}
}
}

Related

How to change the Status Bar in Xamarin Forms ContentPage using AppShell?

I am using the new concept AppShell, and I am doing the following flow
App.MainPage = new AppShell();
then I do
protected async override void OnStart()
{
await Shell.Current.GoToAsync($"//{nameof(LoginPage)}");
}
With this I have a ForgetPasswordPage, from LoginViewModel I do
await Shell.Current.GoToAsync($"//{nameof(ForgetPasswordPage)}");
The point is if I do this
var color = new Color(33, 150, 243);
Xamarin.Essentials.Platform.CurrentActivity.Window.SetStatusBarColor(color);
Inside the Create method from Android the StatusBar has the color I defined.
Now where is the method for iOS, like this?
I tried theses solutions
How to change the status bar color without a navigation page
Xamarin.Forms.Shell: how to manage StatusBar color
https://github.com/georgemichailou/ShaXam/
Without succeed...
Someone can explain, how to change the status code but I would like to set it inside my ContentPage, I could use a style, or a simple line of code like this
Xamarin.Essentials.Platform.CurrentActivity.Window.SetStatusBarColor(color);
Which is used in Android project.
I did the steps from the other posts, and I got:
Foundation.MonoTouchException: 'Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.
Native stack trace:
0 CoreFoundation 0x00007fff20422fba __exceptionPreprocess + 242
System.Reflection.TargetInvocationException Message=Exception has been thrown by the target of an invocation
You can take a look at my video here that walks through in details: https://www.youtube.com/watch?v=GKJRR8_DSSs
In general:
Android -
public void SetStatusBarColor(System.Drawing.Color color, bool darkStatusBarTint)
{
if (Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.Lollipop)
return;
var activity = Platform.CurrentActivity;
var window = activity.Window;
window.AddFlags(Android.Views.WindowManagerFlags.DrawsSystemBarBackgrounds);
window.ClearFlags(Android.Views.WindowManagerFlags.TranslucentStatus);
window.SetStatusBarColor(color.ToPlatformColor());
if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.M)
{
var flag = (Android.Views.StatusBarVisibility)Android.Views.SystemUiFlags.LightStatusBar;
window.DecorView.SystemUiVisibility = darkStatusBarTint ? flag : 0;
}
}
iOS:
public void SetStatusBarColor(System.Drawing.Color color, bool darkStatusBarTint)
{
if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
{
var statusBar = new UIView(UIApplication.SharedApplication.KeyWindow.WindowScene.StatusBarManager.StatusBarFrame);
statusBar.BackgroundColor = color.ToPlatformColor();
UIApplication.SharedApplication.KeyWindow.AddSubview(statusBar);
}
else
{
var statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
{
statusBar.BackgroundColor = color.ToPlatformColor();
}
}
var style = darkStatusBarTint ? UIStatusBarStyle.DarkContent : UIStatusBarStyle.LightContent;
UIApplication.SharedApplication.SetStatusBarStyle(style, false);
Xamarin.Essentials.Platform.GetCurrentUIViewController()?.SetNeedsStatusBarAppearanceUpdate();
}

Createvector is undefined p5js

UPDATE: Forgot to say, I'm using the p5.js editor. The rest of the sketch works, and loads the image.
When I run this code in the browser I get 'createVector is undefined'. According to the reference for p5.js I'm using the correct syntax.
Any ideas what is wrong?
var img;
var bg = 100;
var velocity = createVector(0,0);
var acceleration = createVector(0,0);
function setup() {
createCanvas(720, 400);
img = loadImage("assets/bb8body.png");
}
function keyPressed() {
if (keyIsPressed === true) {
if (key === 'd') {
acceleration++;
velocity.add(acceleration);
console.log(vx);
}
}
}
function damping(){
}
function draw() {
keyPressed();
background(bg);
image(img, velocity, 0);
damping();
}
I'm not 100% why, but createVector() works in setup() (not outside).
Additionally, I've spotted two small errors:
acceleration++;
This won't work as js doesn't support overloaded operators like c++, but you can use p5.Vector's add() function.
Also, the vx variable doesn't exist in the rest of your code.
Here's a modified version of your code using p5.Vector instances, but drawing a small box instead of the image, for testing purposes. You can run the demo bellow:
var img;
var bg = 100;
var velocity;// = createVector(0,0);
var acceleration;// = createVector(0,0);
function setup() {
createCanvas(720, 400);
velocity = createVector(0,0);
acceleration = createVector(0,0);
//img = loadImage("assets/bb8body.png");
}
function keyPressed() {
if (keyIsPressed === true) {
if (key === 'd') {
//acceleration++;
acceleration.add(1,1);
velocity.add(acceleration);
//console.log(vx);
console.log(velocity.x);
}
}
}
function damping(){
}
function draw() {
keyPressed();
background(bg);
rect(velocity.x,velocity.y,20,20)
//image(img, velocity, 0);
damping();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.22/p5.min.js"></script>

use phonon crash in phonon_ds9d4.dll

use code :
Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::MusicCategory, NULL);
QObject::connect(player, SIGNAL(finished()), player, SLOT(deleteLater()));
player->play(Phonon::MediaSource("c:/yaodong.mkv"));
but crash.
env is win7 and vs2008, qt 4.7.1
windows sdk is 7.1
dx sdk is Microsoft DirectX SDK (March 2009)
and i find the stack is
mediaobject.cpp (line 233) graph is null
} else if (!m_currentWork.url.isEmpty()) {
//let's render a url (blocking call)
hr = m_currentWork.graph->RenderFile(reinterpret_cast<const wchar_t *>(m_currentWork.url.utf16()), 0);
}
then i find run step to the function:
quint16 WorkerThread::addUrlToRender(const QString &url)
{
QMutexLocker locker(&m_mutex);
Work w;
w.task = Render;
//we create a new graph
w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder);
w.url = url;
w.url.detach();
w.id = m_currentWorkId++;
m_queue.enqueue(w);
m_waitCondition.set();
return w.id;
}
the line : w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder);
w.graph is null.
but i wrote the code outside :
IGraphBuilder *pGraph = NULL;
::CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER, IID_IGraphBuilder,
reinterpret_cast<void**>(&pGraph));
the pGraph is not null.
help. thanks!

Problem displaying QGraphicsGeoMap

I'm new to Qt, and I'm trying to display the Ovi map.
Unfortunately, my program just crashes. Here is my code:
MapView::MapView(QWidget *parent, const char *name) {
mappingManager = 0;
QGeoServiceProvider *serviceProvider = new QGeoServiceProvider("nokia");
// QGeoSearchManager *searchManager = 0;
// QGeoServiceProvider serviceProvider("nokia");
//QGeoRoutingManager *routingManager = 0;
//routingManager = serviceProvider.routingManager();
if (serviceProvider->error() == QGeoServiceProvider::NoError) {
mappingManager = serviceProvider->mappingManager();
// searchManager = serviceProvider.searchManager();
QGraphicsScene *scene = new QGraphicsScene(this);
QGraphicsView *view = new QGraphicsView(scene, this);
mapGraphics = new QGraphicsGeoMap(mappingManager);
mapGraphics->setMapType(QGraphicsGeoMap::StreetMap);
mapGraphics->setConnectivityMode(QGraphicsGeoMap::HybridMode);
// scene->addText("Map view");
scene->addItem(mapGraphics);
view->show();
} else {
QMessageBox::information(this, "Map", "Service provider error");
}
}
I've commented out the line which I think is causing the crash - the scene->addItem(mapGraphics);
How should I add the mapGraphics so I can see it on screen?
I'd really appreciate a hand with this.
Thankyou in advance, J
Have a look at Maps Demo tutorial.
The source code is found in {QtSDK}\Examples\4.7\mobile\mapsdemo\ or on qt.gitorious.org

Flex 4.5 mobile Resize textarea with animation on soft keyboard activate event?

I'm using Flex 4.5.1 with AIR 2.7 (and Flash Builder 4.5.1) to build an app for the Blackberry Playbook.
The app has a large textarea that needs to be resized when the soft keyboard shows up. I am able to hook into the soft keyboard events and do things there.
Now, I want to resize the textarea to fit the remaining part of the screen when the keyboard shows up. I know the current and destination size and want to use a smooth animation to show the textarea resizing. (I can't already set the height and can see the textarea being correctly resized in the keyboard_activating event - but I want to do it through an animation). I've tried using the Animate class, the spark.effects.Move class and none of them seem to work in this case. They seem to run the animation but the screen does not get refreshed!
I don't want to use the built-in resizeAppForKeyboard property on the ViewNavigatorApplication. I have set to 'none' in the app descriptor so that part of it is fine.
Any ideas / thoughts? Is my approach correct at all? How would one go about resizing the textarea using an animation in the keyboard activating event? My code looks like:
In the main view (onCreationComplete event): (txNote is the textarea in question)
txNote.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, function(e:SoftKeyboardEvent):void {
toggleEditMode(true);
});
txNote.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, function(e:SoftKeyboardEvent):void {
toggleEditMode(false);
});
private function toggleEditMode(keyboardActivated:Boolean):void {
trace("toggle edit: " + editMode + ", kb activating: " + keyboardActivated + ", txNote height = " + txNote.height);
editMode = keyboardActivated;
//we handle resize manually, because we want a nice animation happening and we want to resize only the text area - nothing else.
var y:Number = editMode ? -38 : 0;
var height:Number = editMode ? 218 : 455;
txNote.moveAndSize(y, height);
}
The code in txNote.moveAndSize:
public function moveAndSize(newY:Number, newHeight:Number):void {
//parent group uses BasicLayout
//(this.parent as Group).autoLayout = false;
//resizePath.valueFrom = this.height;
//resizePath.valueTo = newHeight;
//movePath.valueFrom = this.y;
//movePath.valueTo = newY;
//resizeEffect.heightFrom = this.height;
//resizeEffect.heightTo = height;
this.top = newY;
moveEffect.xFrom = this.x;
moveEffect.xTo = this.x;
moveEffect.yFrom = this.y;
moveEffect.yTo = newY;
moveEffect.end();
moveEffect.play([ this ]);
//this.move(x, newY);
//animate.play([ this ]);
//this.height = height;
//this.y = y;
//setLayoutBoundsSize(width, height);
//setLayoutBoundsPosition(x, y);
}
The moveEffect / movePath / animate various things I tried are set up in the txNote constructor as follows:
public class NotesArea extends TextArea {
// private var animate:Animate;
// private var movePath:SimpleMotionPath;
// private var resizePath:SimpleMotionPath;
private var moveEffect:Move;
// private var resizeEffect:Resize;
public function NotesArea() {
super();
// animate = new Animate();
// var paths:Vector.<MotionPath> = new Vector.<MotionPath>();
// movePath = new SimpleMotionPath("top");
// resizePath = new SimpleMotionPath("height");
// paths.push(movePath);
//paths.push(resizePath);
// animate.duration = 300;
// animate.motionPaths = paths;
// animate.addEventListener(EffectEvent.EFFECT_UPDATE, function(e:EffectEvent):void {
// trace("y = " + y);
// invalidateDisplayList();
// });
// animate.addEventListener(EffectEvent.EFFECT_END, function(e:EffectEvent):void {
// trace("EFFECT ended: y = " + y);
// });
moveEffect = new Move();
moveEffect.duration = 250;
moveEffect.repeatCount = 1;
moveEffect.addEventListener(EffectEvent.EFFECT_END, function (e:EffectEvent):void {
//(this.parent as Group).autoLayout = true;
trace("move effect ran. y = " + y + ", top = " + top);
});
//this.setStyle("moveEffect", moveEffect);
//
// resizeEffect = new Resize();
// resizeEffect.duration = 250;
// this.setStyle("resizeEffect", resizeEffect);
}
}
yourTextField.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, onActivating);
yourTextField.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATING, onActivating);
yourTextField.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, onActivating);
// in the event listener to the textField IE :
private function onActivating(event:SoftKeyboardEvent):void
{
//listen to the event; make your move here.
}

Resources