I am overriding allowreroutefrom() function from routelistener to pick up my custom route when offroutelistener is detected. I am returning false and starting the new navigation with custom computed route. But I want to show the Rerouting bannerinstruction when reroute happens. How to give our own instruction in banner?
The InstructionView has showRerouteState() and hideRerouteState() methods that you can use:
#Override
public boolean allowRerouteFrom(Point offRoutePoint) {
// Fetch new route
InstructionView instructionView = findViewById(R.id.instructionView);
instructionView.showRerouteState();
return false;
}
Related
When using the reroute listener in HERE maps, I cannot seems to figure out how to modify the RouteResult that is given by onRerouteEnd. When I plot it on the map it goes through bodies of water, which I'm guessing is because the transport mode hasn't been set. Here is what I have attempted:
private NavigationManager.RerouteListener m_reroutinglistener = new
NavigationManager.RerouteListener() {
#Override
public void onRerouteBegin(){
}
#Override
public void onRerouteEnd(RouteResult routeResult){
routeResult.getRoute().getRoutePlan().getRouteOptions().setTransportMode( RouteOptions.TransportMode.PEDESTRIAN );
routeResult.getRoute().getRoutePlan().getRouteOptions().setRouteType( RouteOptions.Type.SHORTEST );
MapRoute newRoute = new MapRoute( routeResult.getRoute() );
newRoute.setColor( Color.CYAN );
map.addMapObject( newRoute );
}
};
You shout not modify routeResult, this object represents result of the route calculation. What you need is to set routeOptions with all its parameters before route is calculated, e.g. like this.
I am building this app, that will recognize painting and will display the info about it with the help of AR.
And I need to call multiple image target but not simultaneously, it will only call the image target if it is detected by AR camera.
*Ive tried creating many scenes with Image target on it but I cant call different imagetarget it keeps on reverting to only 1 imagetarget.
This is wat you can see in menu,
Main menu
Start AR camera(This part should have many image target but not detecting it simultaneously)
Help(how to use the app)
Exit
*Im using vuforia in creating AR
Thanks in advance for those who will help me.
This is the imagetarget and its Database
View post on imgur.com
Run the multi target scene sample. There are three target (stone, wood and road).
Each contains the TrackableBehaviour component.
Grab it and disable it in Start. If you do it in Awake it will be set back to active most likely in the Awake of the component itself or via some other manager.
public class TrackerController:MonoBehaviour
{
private IDictionary<string,TrackableBehaviours> trackers = null;
private void Start()
{
this.trackers = new Dictionary<string,TrackableBehaviour>();
var trackers = FindObjectsOfType<TrackableBehaviour>();
foreach(TrackingBehaviour tb in trackers)
{
this.trackers.Add(tb.TrackableName, tb);
tb.enabled = false;
}
}
public bool SetTracker(string name, bool value)
{
if(string.IsNullOrEmpty(name) == true){ return false; }
if(this.trackers.ContainsKey(name) == false){ return false; }
this.trackers[name].enabled = value;
return true;
}
}
The method finds all TrackableBehaviour and places them in a dictionary for easy access. The setting method return boolean, you can change it to throw exception or else.
Writing an app in Nativescript. The following setup works fine without errors:
// initialize cluster manager
dis.cluster_manager = new dis.clustering.ClusterManager(app.android.context, dis.gMap);
// Instantiate the cluster manager algorithm as is done in the ClusterManager, so we can access cluster items themselves, rather than cluster markers
dis.cluster_manager_algorithm = new dis.clustering.algo.NonHierarchicalDistanceBasedAlgorithm();
dis.cluster_manager.setAlgorithm(dis.cluster_manager_algorithm);
var CustomClusterRenderer = dis.clustering.view.DefaultClusterRenderer.extend({
//constructor
init: function () {},
onBeforeClusterItemRendered: function (item, markerOptions) {
console.log("onBeforeClusterItemRendered");
},
onBeforeClusterRendered: function (cluster, markerOptions) {
console.log("onBeforeClusterRendered!!!!!!!!!!");
}
});
dis.cluster_renderer = new CustomClusterRenderer(app.android.context, dis.gMap, dis.cluster_manager);
dis.cluster_renderer.setMinClusterSize(1);
dis.cluster_manager.setRenderer(dis.cluster_renderer);
dis.gMap.setOnCameraIdleListener(dis.cluster_manager);
// must be called after every unit add/remove
dis.cluster_manager.cluster();
Now, I want to listen to "on cluster clicks" and "on cluster item clicks". Adding the following:
dis.gMap.setOnMarkerClickListener(dis.cluster_manager);
dis.cluster_manager.setOnClusterClickListener(new dis.clustering.ClusterManager.OnClusterClickListener({
onClusterClick: function(cluster) {
console.log("onClusterClick");
}
}));
dis.cluster_manager.setOnClusterItemClickListener(new dis.clustering.ClusterManager.OnClusterItemClickListener({
onClusterItemClick: function(item) {
console.log("onClusterItemClick");
}
}));
It compiles and runs fine, that is, when I click on the cluster marker OR cluster item marker, I get the appropriate console.log, but immediately after the app crashes and I get this error:
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean java.langBoolean.booleanValue()' on a null object reference
Any ideas?
Well great, 2 days wasted, was wondering why the hell does function in source has type boolean:
public interface OnClusterClickListener<T extends ClusterItem> {
public boolean onClusterClick(Cluster<T> cluster);
}
As it turns out, because it's expecting a boolean. No brainer...
dis.cluster_manager.setOnClusterClickListener(new dis.clustering.ClusterManager.OnClusterClickListener({
onClusterClick: function(cluster) {
console.log("onClusterClick");
return true;
}
}));
I want add a marker when I touch the screen. I use osmdroid and no google map.
Moreover, I want get back coordinate of this marker.
for the moment, I can display the osm map and display the location of the user.
thanks !
You can use MapEventsReceiver.
First make sure you have
implementation 'org.osmdroid:osmdroid-mapsforge:6.1.6'
in your build gradle (or newer version).
Then you make you OSMDroid class implement it
public class OSMapClass implements MapEventsReceiver {
// Your map implementation here
#Override
public boolean singleTapConfirmedHelper(GeoPoint p) {
// Here implement single click behaviour
return false;
}
#Override
public boolean longPressHelper(GeoPoint p) {
// Here implement long click behaviour
return false;
}
}
I am using a webview to present some formatted stuff in my app. For some interaction (which are specific to certain dom elements) I use javascript and WebView.addJavascriptInterface(). Now, I want to recognize a long touch. Unfortunately, onLongTouch, in Android 2.3 the handles for text selection are displayed.
How can I turn off this text selection without setting the onTouchListener and return true? (Then, the interaction with the "website" doesn't work anymore.
This worked for me
mWebView.setOnLongClickListener(new OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
return true;
}
});
mWebView.setLongClickable(false);
I have not tested, if you don't want the vibration caused by the long click, you can try this:
mWebView.setHapticFeedbackEnabled(false);
Setting webkit css property -webkit-user-select to none would solve the problem.
Example CSS to disable selection:
* {
-webkit-user-select: none;
}
I figured it out!! This is how you can implement your own longtouchlistener. In the function longTouch you can make a call to your javascript interface.
var touching = null;
$('selector').each(function() {
this.addEventListener("touchstart", function(e) {
e.preventDefault();
touching = window.setTimeout(longTouch, 500, true);
}, false);
this.addEventListener("touchend", function(e) {
e.preventDefault();
window.clearTimeout(touching);
}, false);
});
function longTouch(e) {
// do something!
}
This works.
It appears that cut/paste via long press is turned off if you used
articleView.setWebChromeClient(new WebChromeClient(){...})
See https://bugzilla.wikimedia.org/show_bug.cgi?id=31484
So if you are using setChromeClient and you WANT to have long click to start copy/paste, the do the following:
webView.setWebChromeClient(new WebChromeClient(){
[.... other overrides....]
// #Override
// https://bugzilla.wikimedia.org/show_bug.cgi?id=31484
// If you DO NOT want to start selection by long click,
// the remove this function
// (All this is undocumented stuff...)
public void onSelectionStart(WebView view) {
// By default we cancel the selection again, thus disabling
// text selection unless the chrome client supports it.
// view.notifySelectDialogDismissed();
}
});
An alternative solution is to subclass WebView and Override performLongClick as bellow:
public class AdvanceWebView extends WebView {
//Add constructors...
#Override
public boolean performLongClick() {
return true;
}
}
It seems that the only option is to set onTouchListener and write your own code to detect long-click. Then return true if it's a long-click and false otherwise.
For kotlin i found the following to work:
webView.isLongClickable = false