How to use the extended properties to filter the events using list google calendar API? - google-apis-explorer

I am using List Google calendar API to filter the events which are created with the extended properties in an android app. There is no documentation as to how to use it in the list API. API explorer allows to use it as a query parameter but the java code doesn't show how to filter with extended properties. Please help. TIA.
mService = new com.google.api.services.calendar.Calendar.Builder(
HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName("Google Calendar API Android Quickstart")
.build();
mService.Events.list("primary");
How do i use the query parameters for the list command?

Class Calendar.Events.List
List<String> sharedList = new ArrayList<>();
sharedList.add("key=value");
String pageToken = null;
do {
Events events = mService.events().list("primary")
.setSharedExtendedProperty(sharedList)
.setPageToken(pageToken).execute();
List<Event> items = events.getItems();
for (Event event : items) {
// doActiofiltered events
}
pageToken = events.getNextPageToken();
} while (pageToken != null);

Related

How to click on a marker on the google map for Xamarin UITest

I write Xamarin UITest for Android app. In the app uses google map. Help me please, how to click on a marker on the map?
markers are not showing within the tree of views, my guess is that they're drawn on screen within the map framelayout.
given that the marker is at the center of the map, you could tap it using something like this :
(with a map fragment of id "map")
var map = app.Query("map")
var middleX = (map.First().Rect.Width + map.First().Rect.X) / 2
var middleY = (map.First().Rect.Height + map.First().Rect.Y) / 2
app.TapCoordinates(middleX, middleY)
but I think that's all you can do within the map itself.
If you're building the app yourself, I suggest checking out backdoor methods. These are methods that you can build into the app and then call from the test.
There are plenty of examples for Obj-C and Java apps. Here's an example for C# backdoor methods, which you'd put in either your MainActivity or AppDelegate classes: http://danatxamarin.com/2015/05/07/configuring-backdoor-methods-in-c-for-xamarin-test-cloud/
I'd create a backdoor to return whatever data you need about the map, and then use app.Invoke("myNewMethod"); which will return a string (which could be json). This string could contain screen coordinates, which you could then pass to app.TapCoordinates(x, y);.
The short answer is, Google Maps on Android doesn't really expose objects in an automatable way, so the second best option is backdoors.
If you have a custom renderer for android you can simulate a click inside, the main trick is to access markers inside the renderer:
var field = this.GetType().BaseType.GetField("_markers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
var markers = (List<Marker>)field.GetValue(this);
now for any element in markers as you cannot send a real click you can just simulate it. Pasting the code from my live project:
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == "ExternalClickedPin")
{
if (FormsControl.ExternalClickedPin != null)
{
var pin = Map.Pins.FirstOrDefault(x => x.MarkerId == FormsControl.ExternalClickedPin.MarkerId);
if (pin != null)
{
var field = this.GetType().BaseType.GetField("_markers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
var hiddenMarkers = (List<Marker>)field.GetValue(this);
var marker = hiddenMarkers.FirstOrDefault(x => x.Id == pin.MarkerId.ToString());
if (marker != null)
{
//simulating click
//1 invoke clicked event
// pin.SendMarkerClick(); // <- if needed for tests
//2 show info on map
marker.ShowInfoWindow(); //just what i was needing
//3 center pin on map
//Map.MoveToRegion(...); <- not here, im calling this from Forms subclassed control
}
}
FormsControl.ExternalClickedPin = null;
}
}
}

Using Gamepads in Google Dart

I'm looking for code examples for the Gamepad API for Google Dart.
I've tried relying on the API doc directly and attempted to write out an instance for it.
//Gamepad Example:
Gamepad g = new Gamepad();
g.id.toString(); // This doesn't seem to return anything...
If anyone has any code examples for this that would be fantastic!
I tried this and it worked for me :
import "dart:html";
main(){
window.animationFrame.then(runAnimation);
}
runAnimation(timestamp){
var gamepads = window.navigator.getGamepads();
for (var pad in gamepads)
{
if(pad != null){
querySelector("#buttons").setInnerHtml("${pad.buttons.join(" ")}</br>${pad.axes.join(" ")}");
}
}
window.requestAnimationFrame(runAnimation);
}
I don't have a gamepad to try but
Gamepad g = new Gamepad();
doesn't work because Gamepade has no public constructor.
Try
var gp = window.navigator.getGamepads();
//or
// haven't tried because I don't know how to provoke this event without a gamepad
window.on['gamepadconnected'].listen((e) {
var gamepad = e.gamepad;
});
instead.
I get an empty list so I can't examine more.
see also:
- https://developer.mozilla.org/en-US/docs/Web/Guide/API/Gamepad
- https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html

Set Current Location for searchinng Nearby Hospital to the user

I am using bing maps for Windows Phone app, On one Button Tap I want to show all the nearby Hospitals to me, I implemented but it not shows the my nearby hospitals.
private void Nearest_Hospital_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
MapsTask mapsTask = new MapsTask();
mapsTask.SearchTerm = "hospital";
mapsTask.ZoomLevel = 2;
mapsTask.Show();
}
I want to send the User's Current Location to this so that app will help the user to find the Hospitals nearby to the user.
You can get the users location using the GeoLocation API in Windows Phone. You can then use these coordinates to set the center value of the MapTask.
This code will return the user's current location, use this as the center value of the MapTask.
Geolocator myGeolocator = new Geolocator();
Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
var lat = myGeoposition.Coordinate.Latitude;
var long = myGeoposition.Coordinate.Longitude;

Ignore hidden features returned by identifyTask

I am building an app using javascript, google maps v2 and ESRI 10.1.
I have a DynamicMapServiceLayer and a single layer in my ESRI map service. I dynamically show or hide features on the layer using the ESRI setLayerDefinitions function based on filter values selected by the user at runtime.
When the user clicks on the map I use the ESRI IdentifyTask object to find what the user clicked on. I want to show an infowindow for the feature the user clicked on. My code is sort of working but it opens infowindows for features that are filtered out (not visible) on the layer.
How can I check to see if the user clicked on a visible feature and stop opening infowindows for hidden features? Or how can I get IdentifyTask to stop including hidden features in the response object it returns?
This is my identifyParameters task invoke set up
// set the identify parameters
var identifyParameters = new esri.arcgis.gmaps.IdentifyParameters();
identifyParameters.geometry = latLng; // where the user clicked on the map
identifyParameters.tolerance = 3;
identifyParameters.layerIds = [OUTAGES_LAYER];
identifyParameters.layerOption = 'all';
identifyParameters.bounds = map.getBounds();
var mapSize = map.getSize();
identifyParameters.width = mapSize.width;
identifyParameters.height = mapSize.height;
// execute the identify operation
identifyTask.execute(identifyParameters, function(response, error) {
if (hasErrorOccurred(error)) return;
addResultToMap(response, latLng);
});
UPDATE
I have upgraded to Google maps v3. Now the identify parameters support passing layerdef information as follows below. For example I can limit the identify operation to those features where FISCAL_YEAR = 2014. My problem is solved.
function identify(evt) {
dynamicMap.getMapService().identify({
'geometry': evt.latLng,
'tolerance': 3,
'layerIds': [12],
'layerOption': 'all',
'layerDefs': {12 : 'FISCAL_YEAR = 2014'},
'bounds': map.getBounds(),
'width': map.getDiv().offsetWidth,
'height': map.getDiv().offsetHeight
}, function(results, err) {
if (err) {
alert(err.message + err.details.join('\n'));
} else {
addResultToMap(results, evt.latLng);
}
});
}

Binding JSON string to ListView in Metro apps?

I have a metro application(HTML5 & WinJS) in which am trying to display service data . Actually here am retrieving JSON data from my service but am unable to bind this data into listview . Anyone give me some working example.
Thank you.
You can use the WinJS.xhr() for this. You can read more about it on this link https://msdn.microsoft.com/pt-br/library/windows/apps/br229787.aspx and here is an example:
var path = "data/file.json";
function getData(path) {
WinJS.xhr({ url: path }).then(
function (response) {
var json = JSON.parse(response.responseText);
// Since this is an asynchronous function, you can't
// return the data, so you can:
// 1) retrieve the data to a namespace once the app loads.
var list = new WinJS.Binding.List(json);
Somenomespace.data = list;
// 2) or do all the binding inside the function.
var listView = document.getElementById("listViewID");
listView.winControl.itemDataSource = list.dataSource;
});
}
If you use the built in JSON.parse(jsonString) function you can loop through the content using a normal for loop as it then is a normal object and add it as usuall. Just remember to process or render the data.
Her is an example from code i had in a search page using listview:
var response = JSON.parse(data) ;
var originalResults = new WinJS.Binding.List();
for (x in response) {
originalResults.push(response[x]);
}
this.populateFilterBar(element, originalResults);
this.applyFilter(this.filters[0], originalResults);