本文整理汇总了C#中Android.App.Activity.RunOnUiThread方法的典型用法代码示例。如果您正苦于以下问题:C# Activity.RunOnUiThread方法的具体用法?C# Activity.RunOnUiThread怎么用?C# Activity.RunOnUiThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.App.Activity
的用法示例。
在下文中一共展示了Activity.RunOnUiThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FriendAdapter
public FriendAdapter(Activity context, FriendsViewModel viewModel)
{
this.context = context;
this.viewModel = viewModel;
viewModel.Friends.CollectionChanged += (sender, e) => context.RunOnUiThread (NotifyDataSetChanged);
}
示例2: MakeCall
public static void MakeCall(CallEntity callEntity, Activity activity)
{
var category = callEntity.Category;
var choice = callEntity.Choice ?? "";
var detail = callEntity.Detail ?? "";
new AlertDialog.Builder(activity)
.SetTitle(category + " " + choice + " " + detail)
.SetMessage(Strings.CallSendMessage)
.SetPositiveButton(Strings.CallSend, delegate
{
ThreadPool.QueueUserWorkItem(o =>
{
activity.RunOnUiThread(() =>
{
dialog = new ProgressDialog(activity);
dialog.SetMessage(Strings.SpinnerDataSending);
dialog.SetCancelable(false);
dialog.Show();
});
try
{
ICall patientCall = new PatientCall();
// Assign the callid with the returned MongoDB id
callEntity._id = patientCall.MakeCall(callEntity);
activity.RunOnUiThread(() =>
{
// Call successfull, take the user to myCalls
activity.ActionBar.SelectTab(activity.ActionBar.GetTabAt(1));
SetNewCalls(callEntity);
dialog.Hide();
});
}
catch (Exception ex)
{
Console.WriteLine("ERROR making call: " + ex.Message);
activity.RunOnUiThread(() =>
{
dialog.Hide();
new AlertDialog.Builder(activity).SetTitle(Strings.Error)
.SetMessage(Strings.ErrorSendingCall)
.SetPositiveButton(Strings.OK,
delegate { }).Show();
});
}
});
})
.SetNegativeButton(Strings.Cancel, delegate {/* Do nothing */ })
.Show();
}
示例3: start
public void start(ProcessButton button,Activity activity) {
activity.RunOnUiThread (() => {
action = ()=> UpdateProgress(button,0);
messageHandler.PostDelayed(action,generateDelay());
});
}
示例4: SetIcon
public void SetIcon(Item item, ImageView view, Activity activity)
{
var path = GetIconPath(item);
if (File.Exists(path))
{
var icon = BitmapFactory.DecodeFile(path);
if (view != null & activity != null)
{
activity.RunOnUiThread(
() => view.SetImageBitmap(BitmapFactory.DecodeFile(path)));
}
}
_iconsToLoad.Enqueue
(
new IconToLoad
{
Item = item,
ImageView = view,
Activity = activity
}
);
lock (_backgroundWorker)
{
if (!_backgroundWorker.IsBusy)
{
_backgroundWorker.RunWorkerAsync();
}
}
}
示例5: ProtoPadServer
private ProtoPadServer(View window, int? overrideListeningPort = null, string overrideBroadcastedAppName = null)
{
_window = window;
_contextActivity = window.Context as Activity;
_httpServer = new SimpleHttpServer(responseBytes =>
{
var response = "{}";
var remoteCommandDoneEvent = new AutoResetEvent(false);
_contextActivity.RunOnUiThread(() => Response(responseBytes, remoteCommandDoneEvent, ref response));
remoteCommandDoneEvent.WaitOne();
return response;
});
IPAddress broadCastAddress;
using (var wifi = _contextActivity.GetSystemService(Android.Content.Context.WifiService) as WifiManager)
{
_mcLock = wifi.CreateMulticastLock("ProtoPadLock");
_mcLock.Acquire();
broadCastAddress = GetBroadcastAddress(wifi);
}
BroadcastedAppName = overrideBroadcastedAppName ?? String.Format("ProtoPad Service on ANDROID Device {0}", Android.OS.Build.Model);
ListeningPort = overrideListeningPort ?? 8080;
LocalIPAddress = Helpers.GetCurrentIPAddress();
_udpServer = new UdpDiscoveryServer(BroadcastedAppName, String.Format("http://{0}:{1}/", LocalIPAddress, ListeningPort), broadCastAddress);
}
示例6: Alert
public static void Alert(Activity context, string title, string message, bool CancelButton, Action<Result> callback = null)
{
context.RunOnUiThread(() =>
{
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.SetTitle(title);
builder.SetMessage(message);
if (callback != null)
{
builder.SetPositiveButton("Ok", (sender, e) =>
{
callback(Result.Ok);
});
if (CancelButton)
{
builder.SetNegativeButton("Cancel", (sender, e) =>
{
callback(Result.Canceled);
});
}
}
else
{
builder.SetPositiveButton("OK", (sender, e) => { });
}
builder.Show();
});
}
示例7: ConverstationAdapter
public ConverstationAdapter(Activity context, ConversationsViewModel viewModel)
{
this.context = context;
this.viewModel = viewModel;
viewModel.Conversations.CollectionChanged += (sender, e) => context.RunOnUiThread (NotifyDataSetChanged);
}
示例8: AvatarAdapter
public AvatarAdapter(Activity context, ProfileViewModel viewModel)
{
this.context = context;
this.viewModel = viewModel;
viewModel.Avatars.CollectionChanged += (sender, e) => context.RunOnUiThread (NotifyDataSetChanged);
}
示例9: ButtonItem
public ButtonItem (Activity oActivity, Game oGame)
{
this.oActivity = oActivity;
this.oGame = oGame;
oImageButton = oActivity.FindViewById<ImageButton> (Int32.Parse( Game.buttons[nahodnik.Next(0,Game.buttons.Length-1)].ToString()));
seznamVisibleButtons.Add (this);
oActivity.RunOnUiThread (() => oImageButton.Visibility = ViewStates.Visible);
oActivity.RunOnUiThread (() => oImageButton.Enabled = true);
if (OptionsHodnoty.TouchMode)
{
//oImageButton.Touch += HandleClick;
//oImageButton.SetOnTouchListener (this);
} else {
oImageButton.Click += HandleClick;
}
}
示例10: ShowEmptyHistory
public void ShowEmptyHistory(Activity activity)
{
activity.RunOnUiThread(() =>
{
var item = new DataObject(string.Empty);
var items = new List<DataObject> { item };
Items = items;
});
}
示例11: Initialize
/// <summary>
/// Initialize the binding manager for an activity.
/// </summary>
/// <param name="bindings">The binding manager for the activity.</param>
/// <param name="activity">The activity that owns the binding manager.</param>
public static void Initialize(this BindingManager bindings, Activity activity)
{
UpdateScheduler.Initialize(action =>
{
ThreadPool.QueueUserWorkItem(delegate(Object obj)
{
activity.RunOnUiThread(action);
});
});
}
示例12: CloseDialog
public static void CloseDialog(Activity currentActivity)
{
currentActivity.RunOnUiThread(() =>
{
if (_currentDialog != null && _currentDialog.IsShowing)
{
_currentDialog.Dismiss();
}
});
}
示例13: MakeErrorPopUp
public static void MakeErrorPopUp(Activity activity, ErrorType error)
{
if (activity == null) throw new ArgumentNullException("activity");
activity.RunOnUiThread(() =>
{
_errorDialog = new AlertDialog.Builder(activity)
.SetPositiveButton(Resource.String.TryAgainButtonText, OnTryAgainButtonClicked)
.SetTitle(ResolveErrorTitle(error))
.SetMessage(ResolveErrorMessage(error))
.Create();
_errorDialog.Show();
});
}
示例14: ProtoPadServer
private ProtoPadServer(Activity activity, int? overrideListeningPort = null, string overrideBroadcastedAppName = null)
{
_contextActivity = activity;
BroadcastedAppName = overrideBroadcastedAppName ?? String.Format("ProtoPad Service on ANDROID Device {0}", Android.OS.Build.Model);
ListeningPort = overrideListeningPort ?? 8080;
LocalIPAddress = Helpers.GetCurrentIPAddress();
var mainMonodroidAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name.ToLower() == "mono.android");
var requestHandlers = new Dictionary<string, Func<byte[], string>>
{
{"GetMainXamarinAssembly", data => mainMonodroidAssembly.FullName},
{"WhoAreYou", data => "Android"},
{"ExecuteAssembly", data =>
{
var response = "{}";
var remoteCommandDoneEvent = new AutoResetEvent(false);
_contextActivity.RunOnUiThread(() => Response(data, remoteCommandDoneEvent, ref response));
remoteCommandDoneEvent.WaitOne();
return response;
}
}
};
_httpServer = new SimpleHttpServer(ListeningPort, requestHandlers);
IPAddress broadCastAddress;
using (var wifi = _contextActivity.GetSystemService(Android.Content.Context.WifiService) as WifiManager)
{
try
{
_mcLock = wifi.CreateMulticastLock("ProtoPadLock");
_mcLock.Acquire();
}
catch (Java.Lang.SecurityException e)
{
Debug.WriteLine("Could not optain Multicast lock: {0}. Did you enable CHANGE_WIFI_MULTICAST_STATE permission in your app manifest?", e.Message);
}
broadCastAddress = GetBroadcastAddress(wifi);
}
var inEmulator = Build.Brand.Equals("generic", StringComparison.InvariantCultureIgnoreCase);
_udpServer = new UdpDiscoveryServer(BroadcastedAppName, String.Format("http://{0}:{1}/", inEmulator ? "localhost" : LocalIPAddress.ToString(), inEmulator ? "?" : ListeningPort.ToString()), broadCastAddress);
}
示例15: LoadAd
/// <summary>
/// Refreshed the ad for the view
/// </summary>
/// <param name="view"></param>
public static void LoadAd(Activity activity, View view)
{
if (String.IsNullOrEmpty (activity.GetText(Resource.String.AdPublisherID)))
{
view.Visibility = ViewStates.Gone;
return;
}
Logging.Log (null, Logging.LoggingTypeDebug, "LoadAd()");
Task.Factory.StartNew (() => {
activity.RunOnUiThread(() => {
view.Visibility = ViewStates.Visible;
IntPtr methodId = JNIEnv.GetStaticMethodID (_helperClass, "loadAd", "(Landroid/view/View;)V");
JNIEnv.CallStaticVoidMethod (_helperClass, methodId, new JValue (view));
});
});
}