I've a list of waypoint of type STOP_WAYPOINT and onStopoverReached is fired with the wrong index (the var1 parameter). The route has the following coordinates:
latitude:42.896241 longitude:13.894039
latitude:42.897784 longitude:13.894991
latitude:42.89753 longitude:13.892602
latitude:42.896667 longitude:13.893728
It always recognize the first or the second, even if I reach the other ones.
The same function works flawlessly on the iOS SDK. Any clue?
private NavigationManager.NavigationManagerEventListener m_navigationManagerEventListener = new NavigationManager.NavigationManagerEventListener() {
#Override
public void onStopoverReached(int var1)
{
//var1 is the wrong index
}
}
m_navigationManager.addNavigationManagerEventListener( new WeakReference<NavigationManager.NavigationManagerEventListener>(m_navigationManagerEventListener));
In general the index returned from the callback are in sync with the provided Route plan and the same should be used to get the stop over waypoint.
From Documentation: https://developer.here.com/documentation/android-premium/api_reference_java/com/here/android/mpa/guidance/NavigationManager.NavigationManagerEventListener.html#onStopoverReached-int-
public void onStopoverReached(int index)
Callback indicating that a route stopover has been reached.
Note that in addition to this, NavigationManager.ManeuverEventListener.onManeuverEvent() callback will also be received. Furthermore, note that a RouteWaypoint of type RouteWaypoint.Type.VIA_WAYPOINT is not considered to be a route stopover.
Parameters:
index - The index of the stopover that was reached, starting from 0. Stopovers can be retrieved by index from the RoutePlan.
See Also:
RoutePlan.getWaypoint(int)
Related
API calls should be made ~30 times which only differ by one parameter:
https://api.website.com/getProducts?category_id=10
https://api.website.com/getProducts?category_id=11
These calls responds are limited by 100 products per call. If a category has more products, I need to append a offset parameter. The following call will give me the subset from 101-200. A total is also provided in the response so I know when to stop.
https://api.website.com/getProducts?category_id=10&offset=100
https://api.website.com/getProducts?category_id=10&offset=200 <--category has 260 products, I stop here.
I can make the initial calls (no offset) and n-offset calls with Retrofit easily. But from Retrofit I can't register any callbacks when all calls are finished nor return the data as a list to update my UI just once.
So I like to try it with RxJava2. I accomplished the same as with Retrofit already (returning a Observable after each parent call or call with offset).
private Observable<SearchResponse> search(int category, int offset) {
Observable<SearchResponse> call = retrofitSearchService.search(category, offset);
return call.flatMap(new Function<SearchResponse, ObservableSource<?>>() {
#Override
public ObservableSource<SearchResponse> apply(#NonNull SearchResponse searchResponse) throws Exception {
if (searchResponse.getTotal() > (searchResponse.getOffset() + searchResponse.getLimit())) {
search(category, searchResponse.getOffset() + 100); <--recursion here
}
return Observable.just(searchResponse);
}
}).toList().toObservable()
.cast(SearchResponse.class);
}
Returning every response as one makes my UI update like crazy (Android livedata).
I still like to:
return a full list of all categories and children if they have any.
get one callback when all requests are made.
This looks promising (How To Do Recursive Observable Call in RxJava?). But I can't wrap my head around it.
If you can, please disperse of lambda. Function, Consumer, Subscriber gives me more clarity. Great!
Here the Text Area is constantly changing in terms of number and I want to trigger an event when the Text Area gets a particular number example I have tried this -
public void myfunction45(Canvas Panel)
{
if (Indicator = 45) {
Panel.enabled = false;.
}
} //(indicator- www.progress).
But it does not work(it does not read it nothing happens). how do I match the condition as the number is to be specific. please give an example for explanation. Thanks in advance.
That if statement would cause you problems.
You would want:
if(Indicator == 5)
instead. At the moment you're assigning the value without checking it, this would cause a compiler error. If it's just a typo, then update your answer, slightly confusing otherwise.
With regards to checking the text value. You'd have to grab the text value, for that you need a reference to the Text area. This approach assumes that the text area has it's value set by a user. Currently you're not grabbing any text values to compare, as a result, the if statement won't know what to compare.
Here's one approach:
public void myfunction5(Canvas Panel)
{
float result;
string textValue = yourTextArea.text;
if(Single.TryParse(textValue, out result))
{
if(result == Indicator)
{
Panel.enabled = false;
}
}
}
You use TryParse to avoid any potential exceptions that would be thrown if the user entered something that wasn't a number. This method will take the value from your text area, how you get your text area is up to you, and try to parse the text value into a float. The method will return true if the parse was a success, false otherwise.
Here's the reference for the TryParse stuff:
https://msdn.microsoft.com/en-us/library/26sxas5t(v=vs.110).aspx
If you wanted to parse it to an int, then you'd be using the Int32's version of TryParse, https://msdn.microsoft.com/en-us/library/system.int32_methods(v=vs.110).aspx
I'd also recommend having a peak at the Input Field documentation: https://docs.unity3d.com/Manual/script-InputField.html
You can subscribe your method to the Input-fields On Value Changed event, your function will need to tweaked slightly though:
public void myfunction5(string text)
{
float result;
if(Single.TryParse(text, out result))
{
if(result == Indicator)
{
CachedPanel.enabled = false;
}
}
}
Don't forget to store a reference to the panel you want to disable.
Hopefully this is what you're after.
Panel is already a Canvas type, it doesn't make any sense to GetComponent<Canvas> on the same type.
Try using Panel.enabled = false;.
For the rest, we don't know how you get the Indicator reference, or how you built the UI hierarchy, so we can't assess if the problem is there.
Edit: I could I miss the single = baffles me lol. I should avoid answering questions when I'm tired.
My intent is to show the fragment if there is something to show and hide it if there isn't.
My problem is that, given the same coordinates:
On first attempt, mStreetView.getStreetViewPanorama().getLocation() has a non-null response and shows the view. However, the Fragment is black (blank).
On second attempt, mStreetView.getStreetViewPanorama().getLocation() has a null response and the view stays hidden.
My code:
mStreetView.getView().setVisibility(View.GONE);
mStreetView.getStreetViewPanorama().setPosition(customMarker.getPosition());
if (mStreetView.getStreetViewPanorama().getLocation() != null &&
mStreetView.getStreetViewPanorama().getLocation().links != null) {
mStreetView.getView().setVisibility(View.VISIBLE);
}
I'm not sure how to go about debugging this. It seems to me that the results shouldn't vary like this, especially since, even though it has non-null results, the results have (apparently) no valid value to allow something to be displayed.
Edit:
This coordinate functions as expected and shows the view properly populated: 33.6645598,-111.9253126
This coordinate shows the view, but it is black, then later returns null: 33.6492448,-111.9354228
These results are consistent.
Edit2:
I attempted to use the OnStreetViewPanoramaReadyCallback(), however the results were the same.
Code is now:
mStreetView.getView().setVisibility(View.GONE);
mStreetView.getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback() {
#Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetViewPanorama) {
streetViewPanorama.setPosition(customMarker.getPosition());
if (streetViewPanorama.getLocation() != null && streetViewPanorama.getLocation().links != null) {
mStreetView.getView().setVisibility(View.VISIBLE);
}
}
});
In one of my old projects found there is a race condition if you try to access the location too early
what I did was setup a handler and have a post delayed runnable fire after 1000 milliseconds then check the location. Doing this provided consistent results.
I dont know if this is still the current behavior but you can read what I did here
Android StreetView check if there is any view for given location
Edit
there appears to be a onStreetViewPanoramaReady callback now, are you using that?
If you use the 'getLocation()' before the view has been created, it will return null. It is recommended to wait until view has been created. Also, you have to create a callback to let you know when the streetview is ready.
getStreetViewPanoramaAsync(new OnStreetViewPanoramaReadyCallback(){
#Override
public void onStreetViewPanoramaReady(StreetViewPanorama streetViewPanorama) {
}
})
Where is the documentation/sample for all overloads of invokeApi function for Azure Mobile Service client SDK for Android?
I found this article and tried following code, which does not work. There are no compile time or run time errors, invokeApi gets called, but it does not come back to onSuccess or onFailure. If I call invokeApi without order object, everything works as expected
PizzaOrder order = new PizzaOrder();
order.Size = "Large";
order.Flavor = "Four cheeses";
order.UserPhone = "555-555-1234";
ListenableFuture<PizzaOrderResponse> testresult = mClient.invokeApi("bookservice", order, PizzaOrderResponse.class);
Futures.addCallback(testresult, new FutureCallback<PizzaOrderResponse>() {
#Override
public void onFailure(Throwable exc) {
// failure handling code here
}
#Override
public void onSuccess(PizzaOrderResponse testresult) {
// success handling code here
}
});
One of the properties in the data object being returned by the custom API had incorrect data type. I am still not sure where the good documentation is and why custom API call did not fail but at least it is working now.
I am evaluating the Multi-Tracker sample and I want to get hold of the RawValue of the barcode detector once one is available.
I would like to dismiss the Tracker once a valid RawValue has been obtained and use the value elsewhere.
Any suggestions on the items below will be helpful.
How to dismiss the tracker once a detection has been made
How to hold and pass the RawValue up the the activity. For example, echo it in a Toast
Thanks
See the discussion in this thread about passing the RawValue to the activity:
How to capture barcode values using the new Barcode API in Google Play Services?
The tracker is active as long as the associated CameraSource/Detector is active (i.e., the release() method has not been called). But if you want to avoid receiving updates beyond the initial detection, you could have the tracker suppress sending updates beyond the first one. For example:
#Override
public void onUpdate(Detector.Detections<Barcode> detectionResults, Barcode item) {
if (!mFoundCalled) {
mCallback.onFound(item.rawValue);
mFoundCalled = true;
}
...
}
And you also can use the callback in: onNewItem
#Override
public void onNewItem(int id, Barcode item) {
mGraphic.setId(id);
callback.onBarcodeFound(item.rawValue);
}