本文整理汇总了C#中Java.JavaCast方法的典型用法代码示例。如果您正苦于以下问题:C# Java.JavaCast方法的具体用法?C# Java.JavaCast怎么用?C# Java.JavaCast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Java
的用法示例。
在下文中一共展示了Java.JavaCast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnLoadFinished
public void OnLoadFinished (Loader loader, Java.Lang.Object data)
{
var cursor = data.JavaCast<ICursor> ();
TextView tv = ((Activity) mContext).FindViewById <TextView> (Resource.Id.sample_output);
// Reset text in case of a previous query
tv.Text = mContext.GetText (Resource.String.intro_message) + "\n\n";
if (cursor.Count == 0) {
return;
}
// Pulling the relevant value from the cursor requires knowing the column index to pull
// it from.
int phoneColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Phone.Number);
int emailColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Email.Address);
int nameColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.DisplayName);
int lookupColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.LookupKey);
int typeColumnIndex = cursor.GetColumnIndex (ContactsContract.CommonDataKinds.Contactables.InterfaceConsts.Mimetype);
cursor.MoveToFirst ();
// Lookup key is the easiest way to verify a row of data is for the same
// contact as the previous row.
String lookupKey = "";
do {
String currentLookupKey = cursor.GetString (lookupColumnIndex);
if (!lookupKey.Equals (currentLookupKey)) {
String displayName = cursor.GetString (nameColumnIndex);
tv.Append (displayName + "\n");
lookupKey = currentLookupKey;
}
// The data type can be determined using the mime type column.
String mimeType = cursor.GetString (typeColumnIndex);
if (mimeType.Equals (ContactsContract.CommonDataKinds.Phone.ContentItemType)) {
tv.Append ("\tPhone Number: " + cursor.GetString (phoneColumnIndex) + "\n");
} else if (mimeType.Equals (ContactsContract.CommonDataKinds.Email.ContentItemType)) {
tv.Append ("\tEmail Address: " + cursor.GetString (emailColumnIndex) + "\n");
}
// Look at DDMS to see all the columns returned by a query to Contactables.
// Behold, the firehose!
foreach (String column in cursor.GetColumnNames ()) {
Log.Debug (TAG, column + column + ": " +
cursor.GetString (cursor.GetColumnIndex (column)) + "\n");
}
} while (cursor.MoveToNext ());
}
示例2: OnNestedScroll
public override void OnNestedScroll(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
{
base.OnNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
var floatingActionButtonChild = child.JavaCast<FloatingActionButton>();
if (dyConsumed > 0 && floatingActionButtonChild.Visibility == ViewStates.Visible)
floatingActionButtonChild.Hide();
else if (dyConsumed < 0 && floatingActionButtonChild.Visibility != ViewStates.Visible)
floatingActionButtonChild.Show();
}
示例3: OnResult
public void OnResult (Java.Lang.Object result)
{
googleApiClient.Disconnect ();
IDataApiDeleteDataItemsResult deleteDataItemsResult;
try
{
deleteDataItemsResult = result.JavaCast<IDataApiDeleteDataItemsResult>();
}
catch {
return;
}
if (!deleteDataItemsResult.Status.IsSuccess)
Log.Error (Tag, "DismissWearableNotification(): Failed to delete IDataItem");
}
示例4: Apply
public void Apply (Java.Lang.Object calendarCell)
{
if (calendarCell.Class.SimpleName == "CalendarMonthCell") {
return;
}
CalendarDayCell dayCell = calendarCell.JavaCast<CalendarDayCell> ();
if (dayCell.CellType != CalendarCellType.Date) {
return;
}
this.calendar.TimeInMillis = dayCell.Date;
if (calendar.Get (CalendarField.DayOfWeek) == Calendar.Saturday) {
dayCell.Selectable = false;
} else {
dayCell.Selectable = true;
}
}
示例5: OnResult
public void OnResult(Java.Lang.Object result)
{
if (state == 0) {
state = 1;
var apiResult = result.JavaCast<INodeApiGetConnectedNodesResult> ();
var nodes = apiResult.Nodes;
var phoneNode = nodes.FirstOrDefault ();
if (phoneNode == null) {
DisplayError ();
return;
}
WearableClass.MessageApi.SendMessage (client, phoneNode.Id,
"/bikenow/SearchNearestStations/" + ActionStatus.ToString (),
new byte[0]).SetResultCallback (this);
} else {
state = 0;
var apiResult = result.JavaCast<IMessageApiSendMessageResult> ();
Android.Util.Log.Info ("SendMessage", apiResult.RequestId.ToString ());
}
}
示例6: OnResult
public void OnResult (Java.Lang.Object result)
{
var ar = result.JavaCast<ILeaderboardsLoadScoresResult>();
if (ar != null) {
var id = ar.Leaderboard.LeaderboardId;
if (!helper.scores.ContainsKey (id)) {
helper.scores.Add (id, new List<ILeaderboardScore> ());
}
helper.scores [id].Clear ();
var count = ar.Scores.Count;
for (int i = 0; i < count; i++) {
var score = ar.Scores.Get(i).JavaCast<ILeaderboardScore> ();
helper.scores [id].Add (score);
}
}
}
示例7: OnResult
public void OnResult(Java.Lang.Object result)
{
var dataItemResult = result.JavaCast<IDataApiDataItemResult> ();
if (dataItemResult.Status.IsSuccess && dataItemResult.DataItem != null) {
var configDataItem = dataItemResult.DataItem;
var dataMapItem = DataMapItem.FromDataItem (configDataItem);
SetupAllPickers (dataMapItem.DataMap);
} else {
SetupAllPickers (null);
}
}
开发者ID:gandersson,项目名称:android-wear-xamarin-watchface,代码行数:11,代码来源:DigitalWatchFaceCompanionConfigActivity.cs
示例8: OnResult
//Follow the same flow as the MainActivity for the Wearable (Wearable/MainActivity has more details).
public void OnResult (Java.Lang.Object raw)
{
Exception nodeException, messageException;
try {
var nodeResult = raw.JavaCast<INodeApiGetConnectedNodesResult> ();
foreach (var node in nodeResult.Nodes)
WearableClass.MessageApi.SendMessage (mGoogleApiClient, node.Id, START_ACTIVITY_PATH, new byte[0])
.SetResultCallback (this);
return;
} catch (Exception e) {
nodeException = e;
}
try {
var messageResult = raw.JavaCast<IMessageApiSendMessageResult> ();
if (!messageResult.Status.IsSuccess)
Log.Error (TAG, "Failed to connect to Google Api Client with status "
+ messageResult.Status);
return;
} catch (Exception e) {
messageException = e;
}
//We should never get to this point
Log.Wtf (TAG, "Unexpected type for OnResult");
Log.Error (TAG, "Node Exception", nodeException);
Log.Error (TAG, "Message Exception", messageException);
}
示例9: OnSuccess
public override void OnSuccess(Java.Lang.Object jObject)
{
PurchaseResult purchaseResult = jObject.JavaCast<PurchaseResult>();
if (null == purchaseResult) {
m_debugText = string.Format ("PurchaseResult is null!");
} else {
m_debugText = string.Format ("Request Purchase: OnSuccess");
Log.Info (TAG, "OnSuccess identiifer"+purchaseResult.ProductIdentifier);
}
}
示例10: OnFinished
public void OnFinished(Kiip p0, Java.Lang.Object p1)
{
ME.Kiip.Api.Resource response = p1.JavaCast<ME.Kiip.Api.Resource>();
example.toast(response.ToString());
}
示例11: OnResult
/// <summary>
/// On Geofence Request Result
/// </summary>
/// <param name="result"></param>
public void OnResult(Java.Lang.Object result)
{
var res = result.JavaCast<IResult>();
int statusCode = res.Status.StatusCode;
string message = string.Empty;
switch (res.Status.StatusCode)
{
case Android.Gms.Location.GeofenceStatusCodes.SuccessCache:
case Android.Gms.Location.GeofenceStatusCodes.Success:
if (CurrentRequestType == RequestType.Add)
{
message = string.Format("{0} - {1}", CrossGeofence.Id, "Successfully added Geofence.");
foreach (GeofenceCircularRegion region in Regions.Values)
{
CrossGeofence.GeofenceListener.OnMonitoringStarted(region.Id);
}
}
else
{
message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence Update Received");
}
break;
case Android.Gms.Location.GeofenceStatusCodes.Error:
message = string.Format("{0} - {1}", CrossGeofence.Id, "Error adding Geofence.");
break;
case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyGeofences:
message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many geofences.");
break;
case Android.Gms.Location.GeofenceStatusCodes.GeofenceTooManyPendingIntents:
message = string.Format("{0} - {1}", CrossGeofence.Id, "Too many pending intents.");
break;
case Android.Gms.Location.GeofenceStatusCodes.GeofenceNotAvailable:
message = string.Format("{0} - {1}", CrossGeofence.Id, "Geofence not available.");
break;
}
System.Diagnostics.Debug.WriteLine(message);
if (statusCode != Android.Gms.Location.GeofenceStatusCodes.Success && statusCode != Android.Gms.Location.GeofenceStatusCodes.SuccessCache && IsMonitoring)
{
// Rather than force killing all running geofences, delegate action on geofence failures to the application.
// This lets the application decide to ignore the error, perform retry logic, stop monitoring as below, or any other behavior.
// StopMonitoringAllRegions();
((GeofenceImplementation)CrossGeofence.Current).LocationHasError = true;
if (!string.IsNullOrEmpty(message))
CrossGeofence.GeofenceListener.OnError(message);
}
}
示例12: OnDependentViewChanged
public override bool OnDependentViewChanged (CoordinatorLayout parent, Java.Lang.Object child, View dependency)
{
// Move the fab vertically to place correctly wrt the info pane
var fab = child.JavaCast<SwitchableFab> ();
var currentInfoPaneY = ViewCompat.GetTranslationY (dependency);
var newTransY = (int)Math.Max (0, dependency.Height - currentInfoPaneY - minMarginBottom - fab.Height / 2);
ViewCompat.SetTranslationY (fab, -newTransY);
// If alternating between open/closed state, change the FAB face
if (wasOpened ^ ((InfoPane)dependency).Opened) {
fab.Switch ();
wasOpened = !wasOpened;
}
return true;
}
示例13: OnResult
public void OnResult(Java.Lang.Object result)
{
var apiResult = result.JavaCast<ICapabilityApiGetCapabilityResult> ();
var nodes = apiResult.Capability.Nodes;
phoneNode = nodes.FirstOrDefault ();
if (phoneNode == null) {
DisplayError ();
return;
}
WearableClass.MessageApi.SendMessage (client, phoneNode.Id,
SearchStationPath + ActionStatus.ToString (),
new byte[0]);
}
示例14: OnResult
public void OnResult(Java.Lang.Object statusRaw)
{
var status = statusRaw.JavaCast<Statuses>();
if (status.IsSuccess) {
var myHandler = new Handler ();
myHandler.Post (() => {
Android.Widget.Toast.MakeText (this, "Geofencing Started.", Android.Widget.ToastLength.Long).Show ();
});
} else {
var myHandler = new Handler ();
myHandler.Post (() => {
Android.Widget.Toast.MakeText (this, "Error Starting Geofencing.", Android.Widget.ToastLength.Long).Show ();
});
}
}
示例15: OnResult
public void OnResult(Java.Lang.Object result)
{
var dataItemResult = result.JavaCast<IDataApiDataItemResult> ();
if (dataItemResult.Status.IsSuccess) {
OnResultAction (dataItemResult);
}
}