当前位置: 首页>>代码示例>>C#>>正文


C# Activity.RunOnUiThread方法代码示例

本文整理汇总了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);

		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:7,代码来源:FriendAdapter.cs

示例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();
	    }
开发者ID:dsb92,项目名称:patientcare,代码行数:56,代码来源:Call.cs

示例3: start

		public void start(ProcessButton button,Activity activity) {
 
			activity.RunOnUiThread (() => {
				action = ()=> UpdateProgress(button,0);
				messageHandler.PostDelayed(action,generateDelay());
			}); 
		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:7,代码来源:ProgressGenerator.cs

示例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();
                }
            }
        }
开发者ID:vecode,项目名称:GW2Trader,代码行数:31,代码来源:IconStore.cs

示例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);
        }
开发者ID:slodge,项目名称:ProtoPad,代码行数:28,代码来源:ProtoPadServer.cs

示例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();
            });
        }
开发者ID:payinsights,项目名称:samples,代码行数:31,代码来源:Helpers.cs

示例7: ConverstationAdapter

		public ConverstationAdapter(Activity context, ConversationsViewModel viewModel)
		{
			this.context = context;
			this.viewModel = viewModel;
			viewModel.Conversations.CollectionChanged += (sender, e) => context.RunOnUiThread (NotifyDataSetChanged);

		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:7,代码来源:ConversationAdapter.cs

示例8: AvatarAdapter

		public AvatarAdapter(Activity context, ProfileViewModel viewModel)
		{
			this.context = context;
			this.viewModel = viewModel;
			viewModel.Avatars.CollectionChanged += (sender, e) => context.RunOnUiThread (NotifyDataSetChanged);

		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:7,代码来源:AvatarAdapter.cs

示例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;
			}
		}
开发者ID:OndrejMikulec,项目名称:Buttons,代码行数:18,代码来源:ButtonItem.cs

示例10: ShowEmptyHistory

		public void ShowEmptyHistory(Activity activity)
		{
			activity.RunOnUiThread(() =>
			{
				var item = new DataObject(string.Empty);
				var items = new List<DataObject> { item };
				Items = items;
			});
			
		}
开发者ID:mdanz92,项目名称:teco.SkillStore,代码行数:10,代码来源:HistoryTabFragment.cs

示例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);
         });
     });
 }
开发者ID:MrXemiu,项目名称:Assisticant.Starter,代码行数:15,代码来源:BindingManagerExtensions.cs

示例12: CloseDialog

 public static void CloseDialog(Activity currentActivity)
 {
     currentActivity.RunOnUiThread(() =>
     {
         if (_currentDialog != null && _currentDialog.IsShowing)
         {
             _currentDialog.Dismiss();
         }
     });
 }
开发者ID:jardar,项目名称:AndroidBluetoothLE,代码行数:10,代码来源:DialogView.cs

示例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();
			});
		}
开发者ID:mdanz92,项目名称:teco.SkillStore,代码行数:14,代码来源:ErrorPopUpFactory.cs

示例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);
        }
开发者ID:tluyben,项目名称:ProtoPad,代码行数:47,代码来源:ProtoPadServer.cs

示例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));
                });
            });
        }
开发者ID:00091701,项目名称:FullscreenPresentation-Mono,代码行数:23,代码来源:AdMobHelper.cs


注:本文中的Android.App.Activity.RunOnUiThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。