Graphics deprecation in blackberry game development - blackberry

I had a problem on this matter, I'm using Eclipse with JDK 6.0
How can I resolve this problem:
Here's my code
public void processLevel(){
OBJ tempObjects;
if(mygfx.getBackPos() % 25 == 0){
tempObjects = new EnemyDrone(rndGenerator.nextInt() % Graphics.getScreenWidth(), 0 );
tempObjects.setY(tempObjects.getY() - tempObjects.getmybitmap().getHeight() + 3);
gameObjects.addElement(tempObjects);
}
}
the error says that "The method getScreenWidth() from the type Graphics is deprecated"
Thanks in advance guys.!!

Well, you should still be able to compile it with that code; deprecation is just a warning that the current way of doing something isn't the recommended way of doing it, and that there is a newer method that might have additional functionality or is better supported. In this case, you want to use Display.getWidth() to get the current width of the screen.
In general the documentation will say what method a deprecated method has been replaced with. For example, if you check out the documentation for the Graphics class in BB 6.0, it will say to use the static getWidth method of the Display class instead.

You should now use getWidth() of Display in net.rim.device.api.system.Display. The Deprecated API page is also useful.

Related

#iOSFindBy is displayed as deprecated, what can I use instead (using pagefactory for Hybrid usage of Android and iOS device))

I have no experience with iOS, but I am trying to redesign my Android Project for the iOS Guys to use it as well for iOS.
After search in internet I find out that this can happens by using the page factory and locating elements by #iOSFindBy,
After trying to use #iOSFindby for locating element using the page factory method, the compiler indicate that it is deprecated.
#iOSFindBy (Accessibility = "button_login")
#AndroidFindBy(id = "net.myApp.int:id/loginBtn")
private MobileElement login_Button2;
what Can I use instead of this?
I saw also in Appium java client (https://static.javadoc.io/io.appium/java-client/7.0.0/index.html?deprecated-list.html) :
*io.appium.java_client.pagefactory
Annotation Type iOSFindBy
Deprecated.
UIAutomation is going to get deprecated. Use iOSXCUITFindBy instead It is recommended to use XCUITest
#Retention(value=RUNTIME) #Target(value={FIELD,TYPE})
#Repeatable(value=iOSFindBySet.class) public #interface iOSFindBy
Used to mark a field on a Page Object to indicate an alternative mechanism for locating the element or a list of elements. Used in conjunction with PageFactory this allows users to quickly and easily create PageObjects. using iOS UI selectors, accessibility, id, name, class name, tag and xpath*
but I dont know if this is the solution and how to use
If I use it in my Code also get Error:
#iOSXCUITFindBy Accessibility = "button_login"
#AndroidFindBy(id = "net.myApp.int:id/loginBtn")
private MobileElement login_Button1;
Annotation are not allowed here.
Thanks for any Tip in advance
The best way to know how things work is to check related tests in appium-java-client repository on github:
#iOSXCUITFindBy(accessibility = "IntegerB")
private MobileElement textField2;
So in your case, it should be:
#iOSXCUITFindBy(accessibility = "button_login")
#AndroidFindBy(id = "net.myApp.int:id/loginBtn")
private MobileElement login_Button1;

migrating cocos2dx to v2.1.5

First of all, I know this is such an outdated version. But I really need an answer. I'm very new to iOS and cocos2dx, I just got some old code and I'm trying to update cocos2dx to v2.1.5.
My problem is CCMutableArray has been deprecated, replaced with CCArray. I know that in the latest version CCArray has also been deprecated.
But my question is how do I properly update this part of the code without getting unexpected results...
static CCMutableArray<CCString*>* getCsvList(string path);
CCMutableArray<GiftInfo*>* giftList;
I believe I can't just do a drop-in replace like:
static CCArray<CCString*>* csvList(string path);
CCArray<GiftInfo*>* giftList;
Thanks.
you can use CCArray like this
static CCArray* csvList( string path );
CCArray* giftList;
CCArray* stringList;
//
//
//you can add object of CCObject class or derived from CCObject class to CCArray
//example
GiftInfo* gift = GiftInfo::create();
giftList->addObject(gift); //GiftInfo must derived from CCObject class
CCString* myString = CCString::create("new string");
stringList.addObject(myString);
//when getting value from CCArray, it will return object of CCObject, you have to cast it to your class
CCString* getValue = (CCString*)stringList.objectAtIndex( index );
GiftInfo* getGift = (GiftInfo*)giftList.objectAtIndex( index );
for more information see CCArray class inside cocos2d-x code.
Note: It is better to updatre to version 2.2.6 instead of 2.1.5, Its is latest version of cocos2d-x 2.x series.

MvvmCross vNext: ObservableColletion is defined in an assembly that is not referenced

I have got my PCL model to build now, which took a bit of time making plug-ins, however now in my Android UI project I get two errors when building it.
First error is:
The type 'System.Collections.ObjectModel.ObservableCollection`1<T0>' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e,
Retargetable=Yes'. C:\ENM\Main\src\prod\Mobile\Stakeholder\UI.Android.vNext\Views\LocationsMapView.cs 40 32 UI.Android.vNext
The second error is:
foreach statement cannot operate on variables of type
'System.Collections.ObjectModel.ObservableCollection`1<BK.EMS.Stakeholder.Model.ViewModels.LocationViewModel>'
because 'System.Collections.ObjectModel.ObservableCollection`1<BK.EMS.Stakeholder.Model.ViewModels.LocationViewModel>'
does not contain a public definition for 'GetEnumerator'
C:\ENM\Main\src\prod\Mobile\Stakeholder\UI.Android.vNext\Views\LocationsMapView.cs 40 32 UI.Android.vNext
I have referenced the System.Windows assembly from the System.Windows.Droid project, which is supposed to forward ObservableCollection<>.
The lines where the error occurs:
private void AddLocationOverlays()
{
if (_itemizedOverlay.Size() > 0) _itemizedOverlay.ClearOverlayItems();
RunOnUiThread(() =>
{
foreach (var location in ViewModel.Locations)
{
_itemizedOverlay.AddOverlayItem(location);
}
_mapView.Invalidate();
});
}
The Locations property in my ViewModel looks like this:
public ObservableCollection<LocationViewModel> Locations
{
get { return _locations; }
set
{
_locations = value;
RaisePropertyChanged(() => Locations);
}
}
Nothing too complicated and works fine in the non-PCL models...
So how do I get around and fix this?
We now have a solution to this problem - see fix from Daniel Plaisted in Portable Class Library strong assembly reference problems in MonoTouch/MonoDroid
This fix is checked in at https://github.com/slodge/MvvmCross/commit/f6a88048467838e5ac5ca687744dc0b2d1958aa8
Update : See other answer. It appears we now have a solution to this problem!
I believe this is linked to this problem - Portable Class Library strong assembly reference problems in MonoTouch/MonoDroid
Which is linked to: https://github.com/slodge/MvvmCross/issues/41
This is raised with Xamarin as a bug: https://bugzilla.xamarin.com/show_bug.cgi?id=8035 and
I'm afraid I don't understand the recommended Strong Signing solutions right now.
Please upvote the bug report to alert the Microsoft PCL and Xamarin teams about this. The MS and Xamarin teams are talking to each other on this (albeit through me!), and I am hopeful we will find a way for either Microsoft or Xamarin to ship some signed DLLs.
In the meantime, some possible workarounds are:
Use IEnumerable access instead of ObservableCollection - the collection can still be an ObservableCollection instance, just don't reference it as an ObservableCollection in the UI code.
Try putting your iterating code in a class library rather than in an application project - bizarre as it feels, the compiler seems perfectly happy building the same code when its in a library rather than in an application
Try building in MonoDevelop with the Mono compiler - this doesn't seem to have the same strong name reference checks.
Looking at your sample code I would just try:
private ObservableCollection<LocationViewModel> _locations;
public IEnumerable<LocationViewModel> Locations
{
get { return _locations; }
set
{
if (value != null && !(value is ObservableCollection<LocationViewModel>)
{
throw new Exception("You must Set an ObservableCollection");
}
_locations = (ObservableCollection<LocationViewModel>)value;
RaisePropertyChanged(() => Locations);
}
}
then AddLocationOverlays could stay the same.
The only problem with this would be if you then wanted to bind to INotifyCollectionChanged on this collection - but I think you can find a way around this too if needed - e.g. you could somehow expose another INotifyCollectionChanged hook, or you could try using a hack involving an intermediary class library.
I accept that for now these are workarounds not solutions :/

Set Index- / Search-Parameters of FlannBasedMatcher

I have a question concerning javaCVs FlannBasedMatcher. In the openCV documentation, it is possible to supply an index / search parameter to the constructor, in java it doesn't work. So how can i do it if not via the constructor?
FlannBasedMatcher flannMatcher = new FlannBasedMatcher(indexParams, searchParams); // Doesn't work for me
Ok so the lines that enable the constructor to use the index- and searchParameters were commented out. The new release of javaCV will have that constructor as well!

T4MVC 2.6.65 and UseLowercaseRoutes=true error

Good day!
I'm using latest T4MVC from 2.6.65 from NuGet (upgraded from 2.6.64), I've set
// If true, use lower case tokens in routes for the area, controller and action names
static bool UseLowercaseRoutes = true;
And I got error:
The expression being assigned to '....' must be constant ...\T4MVC.cs
Here is the the generated code that triggers error:
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNameConstants {
public const string Calc = ("Calc").ToLowerInvariant();
}
Is this a bug?
Ah sorry, the previous change broke it. I just pushed a new build of T4MVC (2.6.66) which addresses this. Well, it's more of a workaround as it basically doesn't generate the constant tokens when UseLowercaseRoutes is used. But that'll get us going for now.
The root of the problem is that C# doesn't support using .ToLowerInvariant() in constant strings. Ideally, it would just evaluate that at compile time, but it's not that smart :)

Resources